[FEATURE] Add AI-based /ask command (complementing #54) (#56)

* docs: add ai documentation

* docker: update docker files for ai/regular versions, lint

* feat: add initial /ask command

* Delete docker-compose.yml

* docker: ignore ollama folder in builds

* fix: add emojis to help commands, capitalize, add ai commands to help menu

* feat: add better logging, thought handling improvements

* bug fixes, better logging and seperation of ai, update docs for ai

* clean, remove prompt and user info from logs, more docs edits

* system prompt change (plaintext only), parse out /think

* clean up, axios tweaks

* cleanup, logging of ratelimit

---------

Co-authored-by: Aidan <aidan@p0ntus.com>
This commit is contained in:
Lucas Gabriel 2025-06-28 16:22:15 -03:00 committed by GitHub
parent 0c364a1814
commit 81294f5721
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 733 additions and 35 deletions

View file

@ -4,6 +4,7 @@ import fs from 'fs';
import { isOnSpamWatch } from './spamwatch/spamwatch';
import '@dotenvx/dotenvx';
import './plugins/ytDlpWrapper';
import { preChecks } from './commands/ai';
// Ensures bot token is set, and not default value
if (!process.env.botToken || process.env.botToken === 'InsertYourBotTokenHere') {
@ -11,7 +12,17 @@ if (!process.env.botToken || process.env.botToken === 'InsertYourBotTokenHere')
process.exit(1)
}
const bot = new Telegraf(process.env.botToken);
// Detect AI and run pre-checks
if (process.env.ollamaEnabled === "true") {
if (!(await preChecks())) {
process.exit(1)
}
}
const bot = new Telegraf(
process.env.botToken,
{ handlerTimeout: Number(process.env.handlerTimeout) || 600_000 }
);
const maxRetries = process.env.maxRetries || 5;
let restartCount = 0;
@ -21,7 +32,7 @@ const loadCommands = () => {
try {
const files = fs.readdirSync(commandsPath)
.filter(file => file.endsWith('.ts') || file.endsWith('.js'));
files.forEach((file) => {
try {
const commandPath = path.join(commandsPath, file);