Rework pacing, pause poll, add user search, voice overview, and DM list
This commit is contained in:
+13
-7
@@ -19,7 +19,6 @@ import {
|
||||
parsePoll,
|
||||
parseTier,
|
||||
POLL_EMOJIS,
|
||||
randomActionDelay,
|
||||
stripMentions,
|
||||
toCachedMessage,
|
||||
type AssembledContext,
|
||||
@@ -29,11 +28,13 @@ import {
|
||||
type TrustTier
|
||||
} from "./communication.js";
|
||||
import { MessageCache } from "./message-cache.js";
|
||||
import { paced } from "./pacing.js";
|
||||
import { paced, pacedSend } from "./pacing.js";
|
||||
|
||||
const DM_CHANNEL = 1;
|
||||
const GROUP_DM_CHANNEL = 3;
|
||||
|
||||
const POLL_ENABLED = false;
|
||||
|
||||
const DEFAULT_OWNER_ID = "177117296140091393";
|
||||
const STATE_FILE =
|
||||
process.env.VESKSLOP_STATE_FILE ?? new URL("../.veskslop-state.json", import.meta.url).pathname;
|
||||
@@ -237,6 +238,11 @@ export class Puppet {
|
||||
return this.actionLog.read(limit);
|
||||
}
|
||||
|
||||
/** Write a web UI action to the persistent log. */
|
||||
appendAction(entry: Record<string, unknown> & { type: string }) {
|
||||
this.actionLog.append(entry);
|
||||
}
|
||||
|
||||
addToWhitelist(userIds: string[], tier: TrustTier = "user"): Record<string, TrustTier> {
|
||||
for (const id of userIds) {
|
||||
if (id && id !== this.ownerId) this.tiers.set(id, tier);
|
||||
@@ -440,7 +446,7 @@ export class Puppet {
|
||||
|
||||
if (command?.name === "whitelist") {
|
||||
await this.handleWhitelistCommand(command, author.id, tier, channelId);
|
||||
} else if (command?.name === "poll") {
|
||||
} else if (POLL_ENABLED && command?.name === "poll") {
|
||||
await this.handlePollCommand(author.id, channelId, text);
|
||||
}
|
||||
}
|
||||
@@ -664,11 +670,11 @@ export class Puppet {
|
||||
const sensitive = !!commandName && policy.sensitiveCommands.includes(commandName);
|
||||
const mode = override ?? (sensitive ? "dm" : policy.defaultMode);
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, randomActionDelay()));
|
||||
|
||||
try {
|
||||
if (mode === "dm") await this.core.sendDm(requesterId, content);
|
||||
else await this.core.sendMessage(originChannelId, content);
|
||||
await pacedSend(async () => {
|
||||
if (mode === "dm") await this.core.sendDm(requesterId, content);
|
||||
else await this.core.sendMessage(originChannelId, content);
|
||||
});
|
||||
|
||||
this.actionLog.append({
|
||||
type: "reply",
|
||||
|
||||
Reference in New Issue
Block a user