Skip to content

Instantly share code, notes, and snippets.

@vsdsantos
Created May 10, 2016 15:38
Show Gist options
  • Save vsdsantos/2e4f414cdd30d3090ad4b63f73415de0 to your computer and use it in GitHub Desktop.
Save vsdsantos/2e4f414cdd30d3090ad4b63f73415de0 to your computer and use it in GitHub Desktop.
bundle exec ruby bot.rb
bot created
(JSON::ParserError)bies/ruby-2.3.0/lib/ruby/2.3.0/json/common.rb:156:in `parse': 784: unexpected token at '<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx/1.9.1</center>
</body>
</html>
'
from /.../.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/json/common.rb:156:in `parse'
from /.../.rvm/gems/ruby-2.3.0/gems/telegram_bot-0.0.5/lib/telegram_bot/api_response.rb:12:in `initialize'
from /.../.rvm/gems/ruby-2.3.0/gems/telegram_bot-0.0.5/lib/telegram_bot/bot.rb:53:in `new'
from /.../.rvm/gems/ruby-2.3.0/gems/telegram_bot-0.0.5/lib/telegram_bot/bot.rb:53:in `request'
from /.../.rvm/gems/ruby-2.3.0/gems/telegram_bot-0.0.5/lib/telegram_bot/bot.rb:57:in `get_last_updates'
from /.../.rvm/gems/ruby-2.3.0/gems/telegram_bot-0.0.5/lib/telegram_bot/bot.rb:68:in `get_last_messages'
from /.../.rvm/gems/ruby-2.3.0/gems/telegram_bot-0.0.5/lib/telegram_bot/bot.rb:32:in `block in get_updates'
from /.../.rvm/gems/ruby-2.3.0/gems/telegram_bot-0.0.5/lib/telegram_bot/bot.rb:31:in `loop'
from /.../.rvm/gems/ruby-2.3.0/gems/telegram_bot-0.0.5/lib/telegram_bot/bot.rb:31:in `get_updates'
from bot.rb:16:in `<main>'
require 'telegram_bot'
## Telegram Bot
bot = TelegramBot.new(token: ENV['BOT_TOKEN'])
puts 'bot created'
bot.get_updates(fail_silently: true) do |message|
puts "@#{message.from.username}: #{message.text}"
command = message.get_command_for(bot)
message.reply do |reply|
# things
puts "sending #{reply.text.inspect} to @#{message.from.username}"
reply.send_with(bot)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment