forked from markolson/linkbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.rb
More file actions
67 lines (58 loc) · 1.39 KB
/
test.rb
File metadata and controls
67 lines (58 loc) · 1.39 KB
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
load "linkbot.rb"
class TestConsole
def initialize
@user_id = 0
@user_name = "UserName"
@type = MessageType::MESSAGE
@connector = "debug"
puts "Commands - !!set - set message vars"
puts " - !!show - show message vars"
puts " - !!exit"
end
def set_message
puts "\nHit enter to skip.\n\n"
puts "Message Type: (currently '#{@type}') (options: #{MessageType.constants.join(',')})"
set_var(@type, gets.chomp)
puts "Message User ID: (currently '#{@user_id}')"
set_var(@user_id, gets.chomp)
puts "Message User Name: (currently '#{@user_name}')"
set_var(@user_name, gets.chomp)
puts "\n"
true
end
def set_var(var, input)
var.replace input if !input.empty?
end
def show_message
puts "\n"
puts "Type: #{@type}"
puts "User ID: #{@user_id}"
puts "User Name: #{@user_name}"
puts "\n"
true
end
def send_body
puts "Input:"
msg = gets.chomp
if !check_commands(msg)
message = Message.new(msg, @user_id, @user_name, @connector, @type, {})
puts Linkbot::Plugin.handle_message(message)
end
send_body
end
def check_commands(msg)
case msg
when "!!set"
set_message
when "!!show"
show_message
when "!!exit"
abort("Vaya con Dios.")
else
false
end
end
end
app = TestConsole.new()
Linkbot::Plugin.collect
app.send_body