eljojo / telegram_bot

A charismatic Ruby client for Telegram's Bot API
MIT License
299 stars 82 forks source link

command = message.get_command_for(bot) is empty #12

Closed n4m3less closed 8 years ago

n4m3less commented 8 years ago

i am spliting command( command.split(" ") ) and some times i get this error and the script stops: block (2 levels) in <main>': undefined methodsplit' for nil:NilClass (NoMethodError)

I am new at ruby and telegram bot... There is a way to make the bot wait for a command and dont stop the script?

thank 4 the help :D

eljojo commented 8 years ago

@rafalars Hi Rafael! Welcome to Ruby and Telegram bot!

A simple solution to your problem would be command.to_s.split(" ")

The line that causes the problem is: https://github.com/eljojo/telegram_bot/blob/master/lib/telegram_bot/message.rb#L21

I don't really know why sometimes the command is nil. Maybe there's a bug? If you could show me more code in how you're using the gem then maybe I could help. But maybe there's just a bug in the code :)

Feel free to dive into the source code of the gem, it's somewhat simple :)

n4m3less commented 8 years ago

THANK YOU!!!!!!! Solved my problem. I am gonna record a video of my bot when its done and send to you. I implemented google web & image search options(for dork), and gonna put some more things!

Really man, thank you. Coding bot is **cking amazing!!!!!!!!!!!!!!!!

eljojo commented 8 years ago

@rafalars I'm glad it solved the problem. I hope there was no bug in the system. This solution is really just a patch :)

Have fun!

eljojo commented 8 years ago

@rafalars btw looking forward to the video!

n4m3less commented 8 years ago

hey @eljojo the video: https://www.youtube.com/watch?v=w9uPiCzTNvo

eljojo commented 8 years ago

@rafalars this is pretty neat, thanks for sharing!