Files
tg-chat-bot/src/commands/what-better.ts
T
melod1n a736f786c2 feat(openai): add chat streaming and model commands
- add /openai (/chatgpt) chat command using OpenAI Responses API (streaming + incremental edits)
- add /openAIListModels, /openAIGetModel, /openAISetModel
- introduce base Command class and migrate non-chat commands to it
- wire OpenAI client + env vars (OPENAI_API_KEY, OPENAI_MODEL)
- bump deps (@google/genai, systeminformation, @types/node) and add openai
2026-02-03 13:39:01 +03:00

26 lines
903 B
TypeScript

import {Command} from "../base/command";
import {logError, oldSendMessage, randomValue} from "../util/utils";
import {Message} from "typescript-telegram-bot-api";
import {Environment} from "../common/environment";
export class WhatBetter extends Command {
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);
}
}