b74e0a0f3e
- make MessageStore.put() return StoredMessage and allow collectReplyChainText() to work with StoredMessage - move muted users + answers loading into Environment (add Answers model + GEMINI_IMAGE_MODEL) - extract message handling into processNewMessage() and add media-group (album) caching/downloading by unique_file_id - for Ollama: check model capabilities before sending images; use replyToMessage helper consistently - add /geminiGenImage command stub for Gemini image generation
26 lines
916 B
TypeScript
26 lines
916 B
TypeScript
import {ChatCommand} from "../base/chat-command";
|
|
import {logError, oldSendMessage, randomValue} from "../util/utils";
|
|
import {Message} from "typescript-telegram-bot-api";
|
|
import {Environment} from "../common/environment";
|
|
|
|
export class WhatBetter extends ChatCommand {
|
|
command = ["what", "что"];
|
|
argsMode = "required" as const;
|
|
|
|
title = "/what better [a] or [b]";
|
|
description = "either a or b randomly (50% chance)";
|
|
|
|
private argsRe = /^(better|лучше)\s+([\s\S]+?)\s+(or|или)\s+([\s\S]+)$/i;
|
|
|
|
async execute(msg: Message, match?: RegExpExecArray) {
|
|
const args = (match?.[3] ?? "").trim();
|
|
const m = this.argsRe.exec(args);
|
|
if (!m) return;
|
|
const a = m[2].trim();
|
|
const b = m[4].trim();
|
|
|
|
const text = `${randomValue(Environment.ANSWERS.better)} ${randomValue([a, b])}`;
|
|
|
|
await oldSendMessage(msg, text).catch(logError);
|
|
}
|
|
} |