Skip to content

Instantly share code, notes, and snippets.

@setiawanjemy88
Forked from vsdsantos/bot.log
Created August 11, 2021 01:09
Show Gist options
  • Save setiawanjemy88/8d4ec176b6901cb648bead3fb015d613 to your computer and use it in GitHub Desktop.
Save setiawanjemy88/8d4ec176b6901cb648bead3fb015d613 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