forked from elanthia-online/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplay-guild.lic
69 lines (55 loc) · 1.62 KB
/
display-guild.lic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
=begin
Documentation: https://elanthipedia.play.net/Lich_script_repository#display-guild
=end
no_pause_all
no_kill_all
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' }
]
]
args = parse_args(arg_definitions)
$debug_mode_cc = args.debug
#Load contacts from dependency
Contacts = load_contactsmanager_contacts
Names = Contacts.map {|row| row[0]}
echo "***Successfully loaded " + Names.length.to_s + " contacts."
#DEBUG INFO
echo "---Base Contacts---" if $debug_mode_cc
echo Contacts.inspect if $debug_mode_cc
echo Contacts.class if $debug_mode_cc
echo "---Names Array---" if $debug_mode_cc
echo Names.inspect if $debug_mode_cc
echo Names.class if $debug_mode_cc
class Stalker
@@subs = {}
def self.subs
@@subs
end
def self.clear
@@subs = {}
end
def self.add(target, result)
@@subs[/#{target}/] = result
end
end
action = proc do |client_string|
matches = Stalker.subs.select { |key, _| key =~ client_string }
matches.each { |target, result| client_string.gsub!(target, result) }
client_string
end
DownstreamHook.remove('stalker')
DownstreamHook.add('stalker', action)
before_dying do
DownstreamHook.remove('stalker')
end
Names.each do |name|
if (Contacts[name]['guild'] == 'Thief')
Contacts[name]['guild'] = 'X'
end
if (Contacts[name]['guild'] == 'Bard')
Contacts[name]['guild'] = 'D'
end
Stalker.add((name.capitalize),"#{Contacts[name]['guild'].chr}:#{name.capitalize}")
end
clear until script.gets.nil?