You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While using the library, I encountered the following error: elebot: json: cannot unmarshal array into Go struct field MessageReactionCount.Result.message_reaction_count.reactions of type telebot.ReactionCount
After investigating, I found that the output of b.Raw("getUpdates", params) in getUpdates() is as follows:
As you can see, the reactions field is returned as a list. However, in the library, MessageReactionCount is defined with Reactions as a single ReactionCount, not a slice:
type MessageReactionCount struct {
// The chat containing the message.
Chat *Chat `json:"chat"`
// Unique message identifier inside the chat.
MessageID int `json:"message_id"`
// Date of the change in Unix time.
DateUnixtime int64 `json:"date"`
// List of reactions that are present on the message.
Reactions *ReactionCount `json:"reactions"`
}
This mismatch caused the error mentioned above, and the lastUpdateId in Poll() was not incremented, leading to repeated errors and failed updates.
I resolved the issue by modifying the MessageReactionCount struct as follows:
type MessageReactionCount struct {
// The chat containing the message.
Chat *Chat `json:"chat"`
// Unique message identifier inside the chat.
MessageID int `json:"message_id"`
// Date of the change in Unix time.
DateUnixtime int64 `json:"date"`
// List of reactions that are present on the message.
Reactions *[]ReactionCount `json:"reactions"` //<- changed to slice
}
With this change, the error is resolved. I suggest updating the MessageReactionCount struct so that Reactions is a slice. If this approach sounds good, I’d be happy to open a PR with the fix.
Thank you!
The text was updated successfully, but these errors were encountered:
Hello,
While using the library, I encountered the following error:
elebot: json: cannot unmarshal array into Go struct field MessageReactionCount.Result.message_reaction_count.reactions of type telebot.ReactionCount
After investigating, I found that the output of
b.Raw("getUpdates", params)
ingetUpdates()
is as follows:As you can see, the
reactions
field is returned as a list. However, in the library,MessageReactionCount
is defined withReactions
as a singleReactionCount
, not a slice:This mismatch caused the error mentioned above, and the lastUpdateId in Poll() was not incremented, leading to repeated errors and failed updates.
I resolved the issue by modifying the MessageReactionCount struct as follows:
With this change, the error is resolved. I suggest updating the
MessageReactionCount
struct so that Reactions is a slice. If this approach sounds good, I’d be happy to open a PR with the fix.Thank you!
The text was updated successfully, but these errors were encountered: