-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.rb
34 lines (27 loc) · 976 Bytes
/
app.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
require_relative 'lib/daily_bot'
STEP_CLASSES = {
'clarinete_news' => ClarineteNewsMessageStep,
'covid' => CovidStep,
'dollar' => DollarStep,
'random_gif' => RandomGifStep,
'random_message' => RandomMessageStep,
'squanchy_message' => SquanchyMessageStep,
'vaccines' => VaccinesStep,
'weather' => WeatherStep,
'weather_forecast' => WeatherForecastStep
}.freeze
config_filename = ARGV.first || 'config.yml'
config_hash = YAML.load_file(config_filename)
DailyBot.configure do |config|
config.telegram_token = config_hash['telegram']['token']
config.telegram_chat_id = config_hash['telegram']['chat_id']
config.giphy_token = config_hash['giphy']['token']
config.openweather_token = config_hash['openweather']['token']
end
steps = config_hash['script'].map do |payload|
type = payload['type']
step_class = STEP_CLASSES[type]
raise "Class not defined for step #{type}" unless step_class
step_class.new(payload)
end
steps.each(&:handle_step)