Module: Telegram::Bot::Tasks

Extended by:
Tasks
Included in:
Tasks
Defined in:
lib/telegram/bot/tasks.rb

Instance Method Summary collapse

Instance Method Details

#closeObject



39
40
41
42
43
44
# File 'lib/telegram/bot/tasks.rb', line 39

def close
  each_bot do |key, bot|
    say("Closing #{key}...")
    bot.close
  end
end

#delete_webhookObject



25
26
27
28
29
30
# File 'lib/telegram/bot/tasks.rb', line 25

def delete_webhook
  each_bot do |key, bot|
    say("Deleting webhook for #{key}...")
    bot.delete_webhook(drop_pending_updates: drop_pending_updates)
  end
end

#log_outObject



32
33
34
35
36
37
# File 'lib/telegram/bot/tasks.rb', line 32

def log_out
  each_bot do |key, bot|
    say("Logging out #{key}...")
    bot.log_out
  end
end

#set_webhookObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/telegram/bot/tasks.rb', line 8

def set_webhook
  routes = Rails.application.routes.url_helpers
  cert_file = ENV['CERT']
  cert = File.open(cert_file) if cert_file
  each_bot do |key, bot|
    route_name = RoutesHelper.route_name_for_bot(bot)
    url = routes.send("#{route_name}_url")
    say("Setting webhook for #{key}...")
    bot.set_webhook(
      url: url,
      certificate: cert,
      ip_address: ENV['IP_ADDRESS'],
      drop_pending_updates: drop_pending_updates,
    )
  end
end