a736f786c2
- 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
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import {Command} from "../base/command";
|
|
import {getRandomInt, logError, replyToMessage} from "../util/utils";
|
|
import {Message} from "typescript-telegram-bot-api";
|
|
|
|
export class RandomString extends Command {
|
|
argsMode = "optional" as const;
|
|
|
|
title = "/randomString";
|
|
description = "literally random string (up to 4096 symbols)";
|
|
|
|
async execute(msg: Message) {
|
|
const split = msg.text.split(" ");
|
|
const l = parseInt(split.length > 1 ? split[1] : "1");
|
|
|
|
const length = (l <= 0 || l > 4096) ? 1 : l;
|
|
|
|
let result = "";
|
|
|
|
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюя0123456789";
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
result += characters.charAt(getRandomInt(characters.length));
|
|
}
|
|
|
|
await replyToMessage({
|
|
message: msg,
|
|
text: "<blockquote expandable>" + result + "</blockquote>",
|
|
parse_mode: "HTML"
|
|
}).catch(logError);
|
|
}
|
|
} |