Class: TelegramChatbot::TelegramBot

Inherits:
ApplicationRecord show all
Defined in:
app/models/telegram_chatbot/telegram_bot.rb

Instance Method Summary collapse

Instance Method Details

#post_webhook_to_telegramObject



10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/telegram_chatbot/telegram_bot.rb', line 10

def post_webhook_to_telegram
  bot = Telegram::Bot::Client.new(token: token, username: username)

  begin
    request = bot.set_webhook(url: ENV["TELEGRAM_CALLBACK_URL"])

    self.actived = request["ok"]
  rescue
    self.actived = false
  end
end