Merge pull request #84 from phj1081/codex/owner/ejclaw
This commit is contained in:
@@ -68,11 +68,6 @@
|
|||||||
"maxFunctionLines": 816,
|
"maxFunctionLines": 816,
|
||||||
"owner": "discord test hotspot"
|
"owner": "discord test hotspot"
|
||||||
},
|
},
|
||||||
"src/channels/discord.ts": {
|
|
||||||
"maxLines": 903,
|
|
||||||
"maxFunctionLines": 191,
|
|
||||||
"owner": "discord channel hotspot"
|
|
||||||
},
|
|
||||||
"src/codex-warmup.test.ts": {
|
"src/codex-warmup.test.ts": {
|
||||||
"maxFunctionLines": 277,
|
"maxFunctionLines": 277,
|
||||||
"owner": "codex warmup test hotspot"
|
"owner": "codex warmup test hotspot"
|
||||||
|
|||||||
@@ -225,6 +225,32 @@ export class DiscordChannel implements Channel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.client.on(Events.MessageCreate, async (message: Message) => {
|
this.client.on(Events.MessageCreate, async (message: Message) => {
|
||||||
|
await this.handleMessageCreate(message);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle errors gracefully
|
||||||
|
this.client.on(Events.Error, (err) => {
|
||||||
|
logger.error({ err: err.message }, 'Discord client error');
|
||||||
|
});
|
||||||
|
|
||||||
|
return new Promise<void>((resolve) => {
|
||||||
|
this.client!.once(Events.ClientReady, (readyClient) => {
|
||||||
|
logger.info(
|
||||||
|
{ username: readyClient.user.tag, id: readyClient.user.id },
|
||||||
|
'Discord bot connected',
|
||||||
|
);
|
||||||
|
console.log(`\n Discord bot: ${readyClient.user.tag}`);
|
||||||
|
console.log(
|
||||||
|
` Use /chatid command or check channel IDs in Discord settings\n`,
|
||||||
|
);
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.client!.login(this.botToken);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private async handleMessageCreate(message: Message): Promise<void> {
|
||||||
const channelId = message.channelId;
|
const channelId = message.channelId;
|
||||||
const chatJid = `dc:${channelId}`;
|
const chatJid = `dc:${channelId}`;
|
||||||
if (!this.receivesInbound) return;
|
if (!this.receivesInbound) return;
|
||||||
@@ -341,13 +367,7 @@ export class DiscordChannel implements Channel {
|
|||||||
|
|
||||||
// Store chat metadata for discovery
|
// Store chat metadata for discovery
|
||||||
const isGroup = message.guild !== null;
|
const isGroup = message.guild !== null;
|
||||||
this.opts.onChatMetadata(
|
this.opts.onChatMetadata(chatJid, timestamp, chatName, 'discord', isGroup);
|
||||||
chatJid,
|
|
||||||
timestamp,
|
|
||||||
chatName,
|
|
||||||
'discord',
|
|
||||||
isGroup,
|
|
||||||
);
|
|
||||||
|
|
||||||
// Only deliver full message for registered groups. Secondary role bots
|
// Only deliver full message for registered groups. Secondary role bots
|
||||||
// are configured as outbound-only, while the owner bot receives inbound.
|
// are configured as outbound-only, while the owner bot receives inbound.
|
||||||
@@ -382,28 +402,6 @@ export class DiscordChannel implements Channel {
|
|||||||
{ chatJid, chatName, sender: senderName },
|
{ chatJid, chatName, sender: senderName },
|
||||||
'Discord message stored',
|
'Discord message stored',
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
|
||||||
// Handle errors gracefully
|
|
||||||
this.client.on(Events.Error, (err) => {
|
|
||||||
logger.error({ err: err.message }, 'Discord client error');
|
|
||||||
});
|
|
||||||
|
|
||||||
return new Promise<void>((resolve) => {
|
|
||||||
this.client!.once(Events.ClientReady, (readyClient) => {
|
|
||||||
logger.info(
|
|
||||||
{ username: readyClient.user.tag, id: readyClient.user.id },
|
|
||||||
'Discord bot connected',
|
|
||||||
);
|
|
||||||
console.log(`\n Discord bot: ${readyClient.user.tag}`);
|
|
||||||
console.log(
|
|
||||||
` Use /chatid command or check channel IDs in Discord settings\n`,
|
|
||||||
);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.client!.login(this.botToken);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendMessage(
|
async sendMessage(
|
||||||
|
|||||||
Reference in New Issue
Block a user