When I try to use ctx.update.chats with master branch I get the following error:
In src/main.cr:6:14
6 | ctx.update.chats do |chat|
^----
Error: instantiating 'Tourmaline::Update#chats()'
In lib/tourmaline/src/tourmaline/types/custom/update.cr:72:12
72 | self.chats.each { |c| block.call(c) }
^----
Error: instantiating 'Tourmaline::Update#chats()'
In lib/tourmaline/src/tourmaline/types/custom/update.cr:54:30
54 | chats.concat(message.chats) if message
^----
Error: instantiating 'Tourmaline::Message#chats()'
In lib/tourmaline/src/tourmaline/types/custom/message.cr:61:31
61 | if reply_message = self.reply_message
^------------
Error: undefined method 'reply_message' for Tourmaline::Message
Did you mean 'reply_to_message'?
Tourmaline::Message trace:
lib/tourmaline/src/tourmaline/types/custom/message.cr:61
if reply_message = self.reply_message
How to replicate
# shard.yml
dependencies:
tourmaline:
github: protoncr/tourmaline
branch: master
# src/main.cr
require "tourmaline"
client = Tourmaline::Client.new(ENV["BOT_TOKEN"])
echo_handler = Tourmaline::CommandHandler.new("echo") do |ctx|
ctx.update.chats do |chat|
puts chat.id
end
end
client.register(echo_handler)
client.poll
Possible fix
As mentioned in the error itself: "Did you mean 'reply_to_message'?"
When the changed reply_message to reply_to_message, it seems to work as expected.
diff --git a/src/tourmaline/types/custom/message.cr b/src/tourmaline/types/custom/message.cr
index f0ccdf00..5e49e4e9 100644
--- a/src/tourmaline/types/custom/message.cr
+++ b/src/tourmaline/types/custom/message.cr
@@ -58,8 +58,8 @@ module Tourmaline
chats << self.chat
chats << self.sender_chat
chats << self.forward_from_chat
- if reply_message = self.reply_message
- chats.concat(reply_message.chats)
+ if reply_to_message = self.reply_to_message
+ chats.concat(reply_to_message.chats)
end
chats.compact.uniq
end
When I try to use
ctx.update.chatswithmasterbranch I get the following error:How to replicate
Possible fix
As mentioned in the error itself: "Did you mean 'reply_to_message'?"
When the changed
reply_messagetoreply_to_message, it seems to work as expected.