Answer the question
In order to leave comments, you need to log in
Telegram Bot - undefined method when sending a message?
Hello!
I'm learning Ruby, trying to write a simple bot.
Essence: The user enters the package name of the application in Google Play, which is added to the array. Once every n seconds, the bot goes through the array and checks if the application has exited or is still being moderated. If the application has changed its status (for example, left the moderation), the bot should send a message.
There were difficulties writing the flow and sending the message. What am I doing wrong?
Here is the part of the code responsible for the bot: https://pastebin.com/y5mC9vY0
Attached is a screenshot:
Answer the question
In order to leave comments, you need to log in
On line 14 in the code
bot.send_message(chat_id: saved_chat_id, text: app_text)
you pass hash {chat_id:, text:}, the gem code calls the .text method on it and fails because the hash has no such method. The signature of the send_message method wants to see reply as an argument, which can be seen in the README:# reply
message.reply do |reply|
reply.text = "homer please clean the garage"
reply.send_with(bot)
end
# or
reply = message.reply
reply.text = "i'll do it after going to moe's"
bot.send_message(reply)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question