-
-
Save setiawanjemy88/8d4ec176b6901cb648bead3fb015d613 to your computer and use it in GitHub Desktop.
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
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>' |
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
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