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
27 lines
952 B
TypeScript
27 lines
952 B
TypeScript
import {Command} from "../base/command";
|
|
import {Message} from "typescript-telegram-bot-api";
|
|
import {logError, randomValue} from "../util/utils";
|
|
import {bot} from "../index";
|
|
|
|
type DiceEmoji = "🎲" | "🎯" | "🏀" | "⚽" | "🎳" | "🎰";
|
|
const emojis = ["🎲", "🎯", "🏀", "⚽", "🎳", "🎰"];
|
|
|
|
export class Dice extends Command {
|
|
title = "/dice";
|
|
description = "Sends random or specific dice";
|
|
|
|
async execute(msg: Message): Promise<void> {
|
|
const split = msg.text.split("/dice ");
|
|
const secondPart = split[1]?.trim();
|
|
const emojiIndex = emojis.indexOf(secondPart);
|
|
const emojiToDice: DiceEmoji = (emojiIndex >= 0 ? emojis[emojiIndex] : randomValue(emojis)) as DiceEmoji;
|
|
|
|
await bot.sendDice({
|
|
chat_id: msg.chat.id,
|
|
emoji: emojiToDice,
|
|
reply_parameters: {
|
|
message_id: msg.message_id
|
|
}
|
|
}).catch(logError);
|
|
}
|
|
} |