-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.rb
95 lines (89 loc) · 1.74 KB
/
bot.rb
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
require "sinatra/base"
require "../mvc2.rb"
class WhatsAppBot < Sinatra::Base
# use Rack::TwilioWebhookAuthentication, ENV['TWILIO_AUTH_TOKEN'], '/bot'
CHARACTER = %w{
Blackheart
Cable
Captain America
Colossus
Cyclops
Doctor Doom
Gambit
Hulk
Ice Man
Iron Man
Juggernaut
Magneto
Marrow
Omega Red
Psylocke
Rogue
Sabretooth
Sentinel
Shuma-Gorath
Silver Samurai
Spider-Man
Spiral
Storm
Thanos
Venom
War Machine
Wolverine
Akuma
Amingo
Anakaris
Baby Bonnie Hood
Cammy
Captain Commando
Charlie
Chun-Li
Dan
Dhalsim
Felicia
Guile
Hayato
Jill
Ken
Vega
Mega Man
Morrigan
Roll
Ruby Heart
Ryu
Sakura
Servbot
SonSon
Strider
Tron Bonne
Zangief
}
get '/' do
end
post '/bot' do
body = params["Body"].downcase
response = Twilio::TwiML::MessagingResponse.new
found = false
response.message do |message|
words = body.split(" ")
puts words
words.each do |character|
if CHARACTER.include?(character.capitalize)
found = true
character = MVC2.new(character.capitalize)
message.media(character.image)
message.body("Character: #{character.name}")
message.body("Universe: #{character.universe}")
break
else
next
end
end
if (!found)
message.body("Couldn't find character")
end
end
content_type "text/xml"
response.to_xml
end
end