mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 21:01:08 +02:00
🐛 fix(matrix-bot-common): ignore edit events to prevent bot duplicate responses
When a bot edits its message (like timer updates), other bots were responding to each edit as if it were a new message. This fix adds isEditEvent() check to ignore m.replace events.
This commit is contained in:
parent
e357f9f292
commit
69f2eaf2e4
1 changed files with 10 additions and 0 deletions
|
|
@ -170,6 +170,13 @@ export abstract class BaseMatrixService implements OnModuleInit, OnModuleDestroy
|
|||
return localpart.includes('-bot') || localpart.endsWith('bot');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if event is an edit (message replacement)
|
||||
*/
|
||||
protected isEditEvent(event: MatrixRoomEvent): boolean {
|
||||
return event.content?.['m.relates_to']?.rel_type === 'm.replace';
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle incoming room message
|
||||
*/
|
||||
|
|
@ -180,6 +187,9 @@ export abstract class BaseMatrixService implements OnModuleInit, OnModuleDestroy
|
|||
// Ignore messages from other bots to prevent infinite loops
|
||||
if (this.isBot(event.sender)) return;
|
||||
|
||||
// Ignore edit events (message replacements) to prevent duplicate responses
|
||||
if (this.isEditEvent(event)) return;
|
||||
|
||||
// Check room permissions
|
||||
if (this.allowedRooms.length > 0 && !this.allowedRooms.includes(roomId)) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue