skip to Main Content

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


  1. Chosen as BEST ANSWER

    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!


  2. I think that this gem is not installed. You can try these commands:

    gem install telegram_bot

    bundle install

    Login or Signup to reply.
  3. First of all

    cd path/to/my_app
    bundle install
    

    Then try to run your code from console to see if error occurs

    cd path/to/my_app
    bundle exec ruby my_script_with_telegram.rb
    

    if it is ok, then we need more information for your Atom Runner cause error lies in it

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search