I was doing a code in the app "Atom" and when I tried to run this code
require 'telegram_bot'
token = 'MY_TOKEN'
bot = TelegramBot.new(token: token)
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 / start /i
reply.text = 'Ciao, questo è un bot creato da @JustDavide per gli strike. Usami con /strike (Username) (motivo) (numero strike)'
end
puts "sending #{reply.text.inspect} to @#{message.from.username}"
reply.send_with(bot)
end
end
Obviously I made another file "Gemfile" putting
source 'https://rubygems.org'
gem 'telegram_bot'
And when I use "Atom Runner" this error comes:
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- telegram_bot (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Users/davidelao/telegram-bot/bot.rb:1:in `<main>'
I started Ruby like 3 weeks ago, so I am not an expert
3
Answers
It's ok now.. I'm using Repl now not Atom, it was giving me some problems and now I'm ok with that site. Thanks to everyone anyway!
I think that this gem is not installed. You can try these commands:
gem install telegram_bot
bundle install
First of all
Then try to run your code from console to see if error occurs
if it is ok, then we need more information for your
Atom Runner
cause error lies in it