Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First reaction to channel post triggers edited_channel_post update #1969

Open
awerc opened this issue Mar 9, 2024 · 3 comments
Open

First reaction to channel post triggers edited_channel_post update #1969

awerc opened this issue Mar 9, 2024 · 3 comments

Comments

@awerc
Copy link

awerc commented Mar 9, 2024

Context

If channel post gets first reaction some time after creation (about 30 minutes by my observations) - telegraf will trigger edited_channel_post with no reactions in ctx.reactions

Therefore, I cannot use edited_channel_post due to false positives if someone decided to react to old posts.

  • Telegraf.js Version: 4.16.3
  • Node.js Version: v18.17.1
  • Operating System: mac os

Minimal Example Code Reproducing the Issue

Register 3 handlers

  bot.on('message_reaction_count', ctx => { ... });
  bot.on('channel_post', ctx => { ... });
  bot.on('edited_channel_post', ctx => { ... });

Send any message to channel, wait about 30 minutes, set any reaction to post

Expected Behavior

Triggered message_reaction_count with reactions list, not triggered edited_channel_post

Current Behavior

Triggered edited_channel_post without reactions list, not triggered message_reaction_count

After a few minutes message_reaction_count triggered with empty reactions list (but if i log body in webhoook - it contains all reactions)

@MKRhere
Copy link
Member

MKRhere commented Mar 9, 2024

Note that ctx.reactions is a convenience shorthand for the message_reaction update. It will be empty for all other types of updates, including message_reaction_count.

Before the reaction updates, Bot API did treat reactions to messages as edits without observable changes. This behaviour may persist yet. It's likely related to how reactions is architected by Telegram. Nothing we can do about it; Telegraf has no way to tell if an edit update was triggered by an actual change, or a reaction caused it.

@awerc
Copy link
Author

awerc commented Mar 10, 2024

Thank you for your reply. It's quite strange to see this behaviour from Telegram, considering the reactions update.

About ctx.reactions

Note that ctx.reactions is a convenience shorthand for the message_reaction update. It will be empty for all other types of updates, including message_reaction_count.

Maybe it should also include reactions from message_reaction_count ? Because in the body of the request to the webhook, we can see all the reactions.

request body
{
  "update_id": 548087610,
  "message_reaction_count": {
    "chat": {
      "id": -1,
      "title": "channel",
      "username": "channel",
      "type": "channel"
    },
    "message_id": 993,
    "date": 1710061582,
    "reactions": [
      {
        "type": {
          "type": "emoji",
          "emoji": "👍"
        },
        "total_count": 1
      }
    ]
  }
}

However in ctx.reactions we have an empty list ReactionList { }

@MKRhere
Copy link
Member

MKRhere commented Mar 11, 2024

The shape of message_reaction_count and message_reaction are different. The first contains reaction counts for anonymous reactions (in channels), and the second is for user-named reactions. ctx.reactions only wraps message_reaction updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants