-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.rb
More file actions
29 lines (26 loc) · 741 Bytes
/
app.rb
File metadata and controls
29 lines (26 loc) · 741 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
require 'sinatra'
require 'line/bot'
require './event_handler'
require './commands'
require './util'
def client
@client ||= Line::Bot::Client.new do |config|
config.channel_secret = ENV['LINE_CHANNEL_SECRET']
config.channel_token = ENV['LINE_CHANNEL_TOKEN']
end
end
# Add new command
new_command = CommandHandler.new
new_command.regist_keyword_and_function('使い方', method(:help_message))
post '/callback' do
body = request.body.read
signature = request.env['HTTP_X_LINE_SIGNATURE']
unless client.validate_signature(body, signature)
error 400 do
error_log('Bad Request')
end
end
events = client.parse_events_from(body)
event_handler = EventHandler.new
event_handler.execute(events, client)
end