-
Notifications
You must be signed in to change notification settings - Fork 2
feat: custom bot status rotation #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -177,6 +177,33 @@ export const CONFIG_SCHEMA = { | |
| retentionDays: { type: 'number' }, | ||
| }, | ||
| }, | ||
| botStatus: { | ||
| type: 'object', | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type should only be from an allowed list of types - if possible |
||
| properties: { | ||
| enabled: { type: 'boolean' }, | ||
| status: { type: 'string', enum: ['online', 'idle', 'dnd', 'invisible'] }, | ||
| activityType: { | ||
| type: 'string', | ||
| enum: ['Playing', 'Watching', 'Listening', 'Competing', 'Streaming', 'Custom'], | ||
| }, | ||
| activities: { type: 'array', items: { type: 'string' } }, | ||
| rotateIntervalMs: { type: 'number' }, | ||
| rotation: { | ||
| type: 'object', | ||
| properties: { | ||
| enabled: { type: 'boolean' }, | ||
| intervalMinutes: { type: 'number' }, | ||
| messages: { | ||
| type: 'array', | ||
| items: { | ||
| type: 'object', | ||
|
|
||
| required: ['text'], | ||
|
Comment on lines
+199
to
+200
|
||
| }, | ||
|
Comment on lines
+196
to
+201
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Harden Line 196–201 only enforces key presence ( Proposed schema + validator tightening rotation: {
type: 'object',
properties: {
enabled: { type: 'boolean' },
intervalMinutes: { type: 'number' },
messages: {
type: 'array',
items: {
type: 'object',
+ properties: {
+ type: {
+ type: 'string',
+ enum: ['Playing', 'Watching', 'Listening', 'Competing', 'Streaming', 'Custom'],
+ },
+ text: { type: 'string' },
+ },
required: ['text'],
},
},
},
}, } else if (schema.items.type === 'object') {
if (typeof item !== 'object' || item === null || Array.isArray(item)) {
errors.push(
`${path}[${i}]: expected object, got ${Array.isArray(item) ? 'array' : item === null ? 'null' : typeof item}`,
);
- } else if (schema.items.required) {
- for (const key of schema.items.required) {
- if (!(key in item)) {
- errors.push(`${path}[${i}]: missing required key "${key}"`);
- }
- }
+ } else {
+ if (schema.items.required) {
+ for (const key of schema.items.required) {
+ if (!(key in item)) {
+ errors.push(`${path}[${i}]: missing required key "${key}"`);
+ }
+ }
+ }
+ if (schema.items.properties) {
+ errors.push(...validateValue(item, schema.items, `${path}[${i}]`));
+ }
}
}🤖 Prompt for AI Agents |
||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| reminders: { | ||
| type: 'object', | ||
| properties: { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ import { getConfig, loadConfig } from './modules/config.js'; | |
|
|
||
| import { registerEventHandlers } from './modules/events.js'; | ||
| import { startGithubFeed, stopGithubFeed } from './modules/githubFeed.js'; | ||
| import { startBotStatus, stopBotStatus } from './modules/botStatus.js'; | ||
| import { checkMem0Health, markUnavailable } from './modules/memory.js'; | ||
| import { startTempbanScheduler, stopTempbanScheduler } from './modules/moderation.js'; | ||
| import { loadOptOuts } from './modules/optout.js'; | ||
|
|
@@ -292,6 +293,7 @@ async function gracefulShutdown(signal) { | |
| stopWarningExpiryScheduler(); | ||
| stopScheduler(); | ||
| stopGithubFeed(); | ||
| stopBotStatus(); | ||
|
|
||
| // 1.5. Stop API server (drain in-flight HTTP requests before closing DB) | ||
| try { | ||
|
|
@@ -482,6 +484,9 @@ async function startup() { | |
| // Start triage module (per-channel message classification + response) | ||
| await startTriage(client, config, healthMonitor); | ||
|
|
||
| // Start configurable bot presence rotation | ||
| startBotStatus(client); | ||
|
Comment on lines
+487
to
+488
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
rg -n "startBotStatus\\(|client\\.login\\(" src/index.js -C2
rg -n "if \\(!cfg\\?\\.enabled \\|\\| !client\\?\\.user\\) return" src/modules/botStatus.js -C2Repository: VolvoxLLC/volvox-bot Length of output: 556 🏁 Script executed: # Get the full startBotStatus function implementation
rg -n "function startBotStatus|export.*startBotStatus|const startBotStatus" src/ -A 20
# Get the applyPresence function
rg -n "function applyPresence|const applyPresence|async.*applyPresence" src/ -A 15
# Check for ClientReady event handlers
rg -n "ClientReady|client\.on.*ready" src/index.js -C 3Repository: VolvoxLLC/volvox-bot Length of output: 2562 🏁 Script executed: # Get more context on the ClientReady handler - what happens there
rg -n "ClientReady" src/index.js -A 30
# Check the rotation interval setup
rg -n "rotateInterval|setInterval" src/modules/botStatus.js -B 2 -A 8Repository: VolvoxLLC/volvox-bot Length of output: 3222 🏁 Script executed: # Check if there are any event handlers on ready that might depend on startBotStatus
rg -n "startBotStatus|on.*ready|ClientReady" src/index.js -B 2 -A 2
# Verify the rotate function and see if it has the same client.user check
rg -n "function rotate|const rotate" src/modules/botStatus.js -A 10Repository: VolvoxLLC/volvox-bot Length of output: 1032 Move Currently at line 487, Proposed fix- // Start configurable bot presence rotation
- startBotStatus(client);
-
// Start tempban scheduler for automatic unbans (DB required)
if (dbPool) {
startTempbanScheduler(client);
startWarningExpiryScheduler();
startScheduler(client);
startGithubFeed(client);
}
// Load commands and login
await loadCommands();
await client.login(token);
+
+ // Start configurable bot presence rotation after client is authenticated
+ startBotStatus(client);🤖 Prompt for AI Agents |
||
|
|
||
|
Comment on lines
+486
to
+488
|
||
| // Start tempban scheduler for automatic unbans (DB required) | ||
| if (dbPool) { | ||
| startTempbanScheduler(client); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type should only be from an allowed list of types