feat: complete DM pairing codes with channel adapters, gateway handlers, and TUI command (Tier 4 feature 4)
This commit is contained in:
@@ -18,6 +18,7 @@ import type {
|
||||
ChannelStatus,
|
||||
} from '../types.js';
|
||||
import { splitMessage } from '../utils.js';
|
||||
import type { PairingManager } from '../pairing.js';
|
||||
|
||||
/** Configuration for the Discord channel adapter. */
|
||||
export interface DiscordAdapterConfig {
|
||||
@@ -28,6 +29,8 @@ export interface DiscordAdapterConfig {
|
||||
allowedChannelIds?: string[];
|
||||
/** Whether to require mention to respond in guild channels (default: true). DMs always respond. */
|
||||
requireMention?: boolean;
|
||||
/** Optional pairing manager for DM pairing codes. */
|
||||
pairingManager?: PairingManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,6 +197,20 @@ export class DiscordAdapter implements ChannelAdapter {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// DM pairing check — if pairing is enabled, require approval
|
||||
const pm = this.config.pairingManager;
|
||||
if (pm?.enabled && !pm.isApproved('discord', message.channelId)) {
|
||||
const text = message.content.trim();
|
||||
if (text && pm.validateCode('discord', message.channelId, text)) {
|
||||
try {
|
||||
if ('send' in message.channel) {
|
||||
(message.channel as any).send('Pairing successful! You can now chat with Flynn.');
|
||||
}
|
||||
} catch { /* ignore send errors */ }
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Send typing indicator (lasts 10 seconds, no need for interval)
|
||||
|
||||
Reference in New Issue
Block a user