fix: restore regressions from discord-only refactor

This commit is contained in:
Eyejoker
2026-03-20 03:41:53 +09:00
parent 2b08851c2f
commit a293a701f4
24 changed files with 1779 additions and 396 deletions

View File

@@ -17,6 +17,7 @@ import {
DATA_DIR,
TRIGGER_PATTERN,
} from '../config.js';
import { isPairedRoomJid } from '../db.js';
import { readEnvFile } from '../env.js';
import { logger } from '../logger.js';
@@ -158,6 +159,7 @@ import {
AgentType,
Channel,
ChannelMeta,
NewMessage,
OnChatMetadata,
OnInboundMessage,
RegisteredGroup,
@@ -202,11 +204,12 @@ export class DiscordChannel implements Channel {
});
this.client.on(Events.MessageCreate, async (message: Message) => {
// Ignore own messages only
if (message.author.id === this.client?.user?.id) return;
const channelId = message.channelId;
const chatJid = `dc:${channelId}`;
const isOwnBotMessage = message.author.id === this.client?.user?.id;
if (isOwnBotMessage) return;
if (message.author.bot && !isPairedRoomJid(chatJid)) return;
let content = message.content;
const timestamp = message.createdAt.toISOString();
const senderName =
@@ -481,6 +484,10 @@ export class DiscordChannel implements Channel {
return this.client !== null && this.client.isReady();
}
isOwnMessage(msg: NewMessage): boolean {
return !!msg.is_bot_message && msg.sender === this.client?.user?.id;
}
ownsJid(jid: string): boolean {
if (!jid.startsWith('dc:')) return false;
if (!this.agentTypeFilter) return true;