-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbot.rb
executable file
·72 lines (56 loc) · 2.38 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
#!/usr/bin/env ruby
$:.unshift File.join(File.dirname(__FILE__), '../lib')
require 'scamp'
scamp = Scamp.new(:api_key => "YOUR API KEY", :subdomain => "37s")
scamp.behaviour do
# Match some regex limited to a room condition based on a room id
match /^room id (.+)$/, :conditions => {:room => 401839} do
# Reply in the current room
say "Match some regex limited to a room condition based on a room id"
end
# Limit a match to a room condition based on a string
match "room name check", :conditions => {:room => "Monitoring"} do
say "Limit a match to a room condition based on a string"
end
# Limit a match to a user condition based on a string
match /^user name (.+)$/, :conditions => {:user => "Will Jessop"} do
say "Limit a match to a user condition based on a string"
end
# Limit a match to a user condition based on a string
match "user id check", :conditions => {:user => 774016} do
say "Limit a match to a user condition based on an ID"
end
# Limit a match to a room & user condition combined
match /^something (.+)$/, :conditions => {:room => "Monitoring", :user => "Will Jessop"} do
# Reply in the current room
say "Limit a match to a room & user condition combined"
end
# Match text with a regex, access the captures from the match object
match /^repeat (\w+), (\w+)$/ do
say "You said #{matches[0]} and #{matches[1]}"
end
# Match text with a regex, access the named captures as a method
match /^say (?<yousaid>.+)$/ do
say "You said #{yousaid}"
end
# Simple string match, interpolating the room and user in response.
match "something" do |data|
# Send the response to a different room
say "#{user} said something in room #{room}", "Robot Army"
# Send the response to a different room, using the room ID
say "#{user} said something in room #{room}", 293788
# Send the response to the originating room
say "#{user} said something in room #{room}"
end
# Play some sounds
match "ohmy" do
play "yeah"
play "drama"
end
match "multi-condition match", :conditions => {:room => [401839, "Monitoring"], :user => ["Will Jessop", "Noah Lorang"]} do
# Reply in the current room
say "multi-condition match"
end
end
# FIXME: this does if the room doesn't exist. Need a better error.
scamp.connect!([293788, "Monitoring"])