feat: handle tapbacks and threaded replies for TEXT messages#17
Merged
Conversation
Contributor
Author
|
I can't see what is actually coming in via mqtt so it may be worthwhile to check if the reply to and emoji fields are actually there lol |
Skordy
reviewed
May 15, 2026
|
|
||
| if reply_id > 0 and emoji_flag != 0 and discord_msg_id: | ||
| # Emoji Reaction (Tapback) | ||
| await self.append_reaction_to_discord(mp, se, message_text, discord_msg_id) |
Member
There was a problem hiding this comment.
se isn't used in the method, let's remove it from the parameters.
Skordy
reviewed
May 15, 2026
| import traceback | ||
| print(traceback.format_exc()) | ||
|
|
||
| async def append_reaction_to_discord(self, mp, se, message_text, discord_msg_id): |
Member
There was a problem hiding this comment.
se isn't used in the method, let's remove it from the parameters. Same a line #404
Skordy
reviewed
May 15, 2026
Comment on lines
+817
to
+820
| if reactions_idx >= 0: | ||
| # Append to existing | ||
| current_value = embed.fields[reactions_idx].value | ||
| embed.set_field_at(reactions_idx, name="Reactions", value=f"{current_value}\n{reaction_str}", inline=False) |
Member
There was a problem hiding this comment.
What do you think about doing something like this instead? Restrict the limit since Discord's API enforces a hard 1,024-character limit on embed field values.
if reactions_idx >= 0:
current_value = embed.fields[reactions_idx].value
new_value = f"{current_value}\n{reaction_str}"
if len(new_value) > REACTIONS_FIELD_LIMIT:
new_value = new_value[:REACTIONS_FIELD_LIMIT - 3] + "..."
embed.set_field_at(reactions_idx, name="Reactions", value=new_value, inline=False)```
Skordy
reviewed
May 15, 2026
| if reply_to_discord_id: | ||
| try: | ||
| reference = await self.messages_channel.fetch_message(reply_to_discord_id) | ||
| except discord.NotFound: |
Member
There was a problem hiding this comment.
except (discord.NotFound, discord.HTTPException):
Skordy
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reactions and Threaded Replies Implementation
The
mqttbridgecog has been updated to better handle Meshtastic's threaded replies and emoji tapback reactions in Discord.Changes Made
1. Packet Processing Updates
In
mqtt.py, theprocess_mqtt_messagefunction was updated to evaluate two fields in theTEXT_MESSAGE_APPpayload:reply_id: The ID of the message being replied to or reacted to.emoji: A flag that indicates the packet is an emoji tapback rather than a standard text message.2. Threaded Replies
If a text packet contains a
reply_idbut noemojiflag, it is treated as a threaded reply.message_historytable to find the correspondingdiscord_message_id.send_to_discordmethod now accepts areply_to_discord_idargument.referenceparameter when sending the message (await channel.send(..., reference=msg)), visually linking the reply to the original message in the Discord client.3. Emoji Tapback Reactions
If a text packet contains both a
reply_idand theemojiflag, it is treated as a tapback reaction.append_reaction_to_discord, was added to handle these.Reactions:field in the embed, detailing the emoji and the specific node that reacted (e.g.,👍 - Bob (!abcd1234)).message_historytable to ensure that deduplication works, but we skip sending a separate Discord message to reduce channel noise.Validation
To test these changes: