-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathtest.rb
More file actions
executable file
·41 lines (33 loc) · 837 Bytes
/
test.rb
File metadata and controls
executable file
·41 lines (33 loc) · 837 Bytes
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
#!/usr/bin/env ruby
require_relative 'lib/slackbotsy/bot'
require_relative 'lib/slackbotsy/helper'
require_relative 'lib/slackbotsy/message'
require 'sinatra'
config = {
'channel' => '#default',
'name' => 'botsy',
# 'incoming_webhook' => 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX',
'outgoing_token' => '123',
'slash_token' => '123',
}
bot = Slackbotsy::Bot.new(config) do
hear /ping/i do
'pong'
end
hear /botsy ping/i do
'pang'
end
hear /test (.+)/ do |mdata, str|
"mdata: #{mdata}, str: #{str}"
end
hear /echo\s+(.+)/ do |_, str|
"I heard #{user_name} say '#{str}' in #{channel_name}"
end
end
post '/' do
if params[:command]
bot.handle_slash_command(params)
else
bot.handle_outgoing_webhook(params)
end
end