Created
December 4, 2020 15:08
-
-
Save MauroEldritch/9ed15c3f41dc4bf460bac4ba98262731 to your computer and use it in GitHub Desktop.
Telegram_Bot.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'telegram/bot' | |
$api_telegram = "" #Your bot API. You need to enter Telegram and ask Botfather to create a Bot. He will guide you. | |
Telegram::Bot::Client.run($api_telegram) do |bot| | |
bot.listen do |message| | |
#Messages. I use an expression to make it case insensitive. | |
case message.text | |
when /\/start/i | |
begin | |
bot.api.send_message(chat_id: message.chat.id, text: "Hello!") | |
rescue | |
end | |
when /bye/i | |
begin | |
bot.api.send_message(chat_id: message.chat.id, text: "Bye then!") | |
rescue | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment