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
25 lines
854 B
TypeScript
25 lines
854 B
TypeScript
import {Command} from "../base/command";
|
|
import {getRandomInt, getRangedRandomInt, logError, oldSendMessage} from "../util/utils";
|
|
import {Message} from "typescript-telegram-bot-api";
|
|
|
|
export class RandomInt extends Command {
|
|
argsMode = "optional" as const;
|
|
|
|
title = "/randomInt";
|
|
description = "Ranged random integer from parameters";
|
|
|
|
async execute(msg: Message) {
|
|
const split = msg.text.split(" ");
|
|
const min = parseInt(split[1]);
|
|
const max = parseInt(split[2]);
|
|
|
|
const good = max > min;
|
|
const sufficient = !!(min && max) && good;
|
|
|
|
const random = !sufficient ? getRandomInt(Math.pow(2, 60)) : getRangedRandomInt(min, max);
|
|
|
|
const randomText = !sufficient ? random.toString() : `[${min}; ${max}]: ${random}`;
|
|
|
|
await oldSendMessage(msg, randomText).catch(logError);
|
|
}
|
|
} |