feat: moderator bot presence via Discord Gateway
Use Node.js built-in WebSocket to maintain a minimal Discord Gateway connection for the moderator bot, keeping it 'online' with a 'Watching Moderating' status. Handles heartbeat, reconnect, and resume. Also fix package-plugin.mjs to include moderator-presence.ts in dist.
This commit is contained in:
@@ -3,6 +3,7 @@ import path from "node:path";
|
||||
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
||||
import { evaluateDecision, resolvePolicy, type ChannelPolicy, type Decision, type WhisperGateConfig } from "./rules.js";
|
||||
import { checkTurn, advanceTurn, resetTurn, onNewMessage, onSpeakerDone, initTurnOrder, getTurnDebugInfo } from "./turn-manager.js";
|
||||
import { startModeratorPresence, stopModeratorPresence } from "./moderator-presence.js";
|
||||
|
||||
type DiscordControlAction = "channel-private-create" | "channel-private-update" | "member-list";
|
||||
|
||||
@@ -367,6 +368,12 @@ export default {
|
||||
const liveAtRegister = getLivePluginConfig(api, baseConfig as WhisperGateConfig);
|
||||
ensurePolicyStateLoaded(api, liveAtRegister);
|
||||
|
||||
// Start moderator bot presence (keep it "online" on Discord)
|
||||
if (liveAtRegister.moderatorBotToken) {
|
||||
startModeratorPresence(liveAtRegister.moderatorBotToken, api.logger);
|
||||
api.logger.info("whispergate: moderator bot presence starting");
|
||||
}
|
||||
|
||||
api.registerTool(
|
||||
{
|
||||
name: "whispergate_tools",
|
||||
|
||||
Reference in New Issue
Block a user