in receive_file': undefined method
file_id' for nil:NilClass (NoMethodError)
#243
Unanswered
unurgunite
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi, could you dump what a message looks like when you send the command along with a document? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I'm writing a bot in Ruby for academic purposes and I'm stuck due to not knowing how to property work with the library and Telegram API itself, guess. My code is down below:
So, the problem lies in
receive_file
field, which throws the following error:in `receive_file': undefined method `file_id' for nil:NilClass (NoMethodError)
.What did I do to get this result? I started a new
Bot
instance and typed a/file
command and, expectedly, the program crashes with the above error. But if I just send a file to my bot, it will executeelse
condition branch, which is not surprising, cos the message does not fall under the pattern matching, but if I send the command in the same message along with the document, the code also executeelse
branch, what is now surprising for me. So, in my case I can only put all my logic of receiving a file under theelse
condition, what is not well and it seems to be a "code smell". All of the above aside, I'd like to wonder if there are any event handlers in the library for waiting on a document? I have the similar code, written in Python, which works well:There I send command
/file
with file and the document is downloading by the bot.So, any ideas or solution for my problem?
Beta Was this translation helpful? Give feedback.
All reactions