Files
tg-chat-bot/src/commands/random-int.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

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);
}
}