Skip to content

Instantly share code, notes, and snippets.

@ikaruce
Created March 22, 2016 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikaruce/2ee4088438bb45d25fbd to your computer and use it in GitHub Desktop.
Save ikaruce/2ee4088438bb45d25fbd to your computer and use it in GitHub Desktop.
require 'telegram_bot'
bot = TelegramBot.new(token: '193199186:AAFtN0tv35_AUxiWHvQvOQOLw-u-tsGtn6A')
bot.get_updates(fail_silently: true) do |message|
puts "@#{message.from.username}: #{message.text}"
command = message.get_command_for(bot)
message.reply do |reply|
case command
when /greet/i
reply.text = "Hello, #{message.from.first_name}!"
else
reply.text = "#{message.from.first_name}, have no idea what #{command.inspect} means."
end
puts "sending #{reply.text.inspect} to @#{message.from.username}"
reply.send_with(bot)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment