forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates in response to Pull Request comments
-Started each script with documentation block -Used string interpolation for YAML files -Incorporated debug arguments into both scripts to print debug info -Changed 'puts' to either 'echo' or 'respond' -Fixed name of script in documentation block -Changed for loop to 'Names.each do'
- Loading branch information
1 parent
d237280
commit ef9ac30
Showing
2 changed files
with
92 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,70 @@ | ||
=begin | ||
Documentation: https://elanthipedia.play.net/Lich_script_repository#yellowpages | ||
=end | ||
|
||
arg_definitions = [ | ||
[ | ||
{ name: 'debug', regex: /debug/i, optional: true, description: 'Very verbose, may cause lich to hang for several seconds if using large contact files' }, | ||
{ name: 'search', regex: /[a-zA-Z]/, optional: true, description: 'Name of player to look up in contacts.' } | ||
] | ||
] | ||
args = parse_args(arg_definitions) | ||
$debug_mode_cc = args.debug | ||
|
||
#DEBUG INFO | ||
echo args.debug if $debug_mode_cc | ||
echo args.search if $debug_mode_cc | ||
|
||
#Load base contacts YAML | ||
Contacts = YAML.load_file('./scripts/data/base-contacts.yaml') | ||
Contacts = YAML.load_file("./scripts/data/base-contacts.yaml") | ||
Contacts = Contacts['contacts'] | ||
|
||
#DEBUG INFO | ||
#puts "---Base Contacts---" | ||
#puts Contacts.inspect | ||
#puts Contacts.class | ||
echo "---Base Contacts---" if $debug_mode_cc | ||
echo Contacts.inspect if $debug_mode_cc | ||
echo Contacts.class if $debug_mode_cc | ||
|
||
#Check for <CharName>-contacts.yaml file and merges it if exists | ||
if File.exist?('./scripts/profiles/'+checkname+'-contacts.yaml') | ||
puts "Personal Contact file found! Now importing!" | ||
if File.exist?("./scripts/profiles/#{checkname}-contacts.yaml") | ||
##DEBUG | ||
echo "Personal Contact file found! Now importing!" if $debug_mode_cc | ||
|
||
Personal_Contacts = YAML.load_file('./scripts/profiles/'+checkname+'-contacts.yaml') | ||
Personal_Contacts = YAML.load_file("./scripts/profiles/#{checkname}-contacts.yaml") | ||
Personal_Contacts = Personal_Contacts['contacts'] | ||
|
||
#DEBUG INFO | ||
#puts "---Personal Contacts---" | ||
#puts Personal_Contacts.inspect | ||
#puts Personal_Contacts.class | ||
echo "---Personal Contacts---" if $debug_mode_cc | ||
echo Personal_Contacts.inspect if $debug_mode_cc | ||
echo Personal_Contacts.class if $debug_mode_cc | ||
|
||
Contacts.merge!(Personal_Contacts) | ||
end | ||
|
||
#DEBUG INFO | ||
#puts "---Merged Contacts---" | ||
#puts Contacts.inspect | ||
#puts Contacts.class | ||
#puts "-----" | ||
|
||
echo "---Merged Contacts---" if $debug_mode_cc | ||
echo Contacts.inspect if $debug_mode_cc | ||
echo Contacts.class if $debug_mode_cc | ||
echo "-----" if $debug_mode_cc | ||
|
||
arg_definitions = [ | ||
[ | ||
{ name: 'search', regex: /[a-zA-Z]/, optional: false, description: 'Name of player to look up in contacts.' } | ||
] | ||
] | ||
args = parse_args(arg_definitions) | ||
|
||
#DEBUG INFO | ||
#puts args.search | ||
#puts args.class | ||
|
||
Record = Contacts[args.search] | ||
if Record.nil? | ||
puts "User not found in contacts" | ||
if args.search.nil? | ||
echo "What user do you wish to search for?" | ||
else | ||
#puts Record.inspect | ||
puts "Information for " + args.search | ||
puts " " | ||
puts "Guild: " + Record['guild'].inspect.gsub(/nil/,'') | ||
puts "Race: " + Record['race'].inspect.gsub(/nil/,'') | ||
puts "Circle: " + Record['circle'].inspect.to_s.gsub(/nil/,'') | ||
puts "Relationship: " + Record['relationship'].inspect.gsub(/nil/,'') | ||
puts "Notes: " + Record['notes'].inspect.gsub(/nil/,'') | ||
puts "Alts: " + Record['alts'].inspect.gsub(/nil/,'') | ||
|
||
Record = Contacts[args.search] | ||
if Record.nil? | ||
echo "User not found in contacts" | ||
else | ||
#DEBUG | ||
echo Record.inspect if $debug_mode_cc | ||
|
||
#Print contact information | ||
respond "Information for " + args.search | ||
respond " " | ||
respond "Guild: " + Record['guild'].inspect.gsub(/nil/,'') | ||
respond "Race: " + Record['race'].inspect.gsub(/nil/,'') | ||
respond "Circle: " + Record['circle'].inspect.to_s.gsub(/nil/,'') | ||
respond "Relationship: " + Record['relationship'].inspect.gsub(/nil/,'') | ||
respond "Notes: " + Record['notes'].inspect.gsub(/nil/,'') | ||
respond "Alts: " + Record['alts'].inspect.gsub(/nil/,'') | ||
end | ||
end |