forked from rpherbig/dr-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-validation.lic
73 lines (56 loc) · 2.22 KB
/
common-validation.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
70
71
72
73
# quiet
=begin
Documentation: https://elanthipedia.play.net/Lich_script_development#common-validation
=end
custom_require.call(%w[common])
class CharacterValidator
include DRC
def initialize(announce, sleep, greet, name)
waitrt?
fput('sleep') if sleep
@lnet = (Script.running + Script.hidden).find { |val| val.name == 'lnet' }
@validated_characters = []
@greet = greet
@name = name
@lnet.unique_buffer.push("chat #{@name} is up and running in room #{Room.current.id}! Whisper me 'help' for more details.") if announce
end
def send_slack_token(character)
message = "slack_token: #{UserVars.slack_token || 'Not Found'}"
echo "Attempting to DM #{character} with message: #{message}"
@lnet.unique_buffer.push("chat to #{character} #{message}")
end
def validate(character)
return if valid?(character)
echo "Attempting to validate: #{character}"
@lnet.unique_buffer.push("who #{character}")
end
def confirm(character)
return if valid?(character)
echo "Successfully validated: #{character}"
@validated_characters << character
return unless @greet
put "whisper #{character} Hi! I'm your friendly neighborhood #{@name}. Whisper me 'help' for more details. Don't worry, I've memorized your name so you won't see this message again."
end
def valid?(character)
@validated_characters.include?(character)
end
def send_bankbot_balance(character, balance)
message = "Current Balance: #{balance}"
echo "Attempting to DM #{character} with message: #{message}"
@lnet.unique_buffer.push("chat to #{character} #{message}")
end
def send_bankbot_location(character)
message = "Current Location: #{Room.current.id}"
echo "Attempting to DM #{character} with message: #{message}"
@lnet.unique_buffer.push("chat to #{character} #{message}")
end
def send_bankbot_help(character, messages)
messages.each do |message|
echo "Attempting to DM #{character} with message: #{message}"
@lnet.unique_buffer.push("chat to #{character} #{message}")
end
end
def in_game?(character)
bput("find #{character}", 'There are no adventurers in the realms that match the names specified', "^ #{character}.$") == " #{character}."
end
end