Files
bot-ai/bot.js
2026-01-23 17:20:44 +04:00

57 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const TelegramBot = require('node-telegram-bot-api');
require('dotenv').config()
const axios = require('axios')
const tokenTg = process.env.TOKEN_TG;
const tokenAi = process.env.TOKEN_AI;
const accessId = process.env.SECRET_ID;
const bot = new TelegramBot(tokenTg, { polling: true });
console.log('Бот запущен...');
bot.onText(/\/info/, (msg)=>{
const message = `Информация о боте: \n
'/start' - перезапускает чат, забывает контекст прошлого диалого \n
'/toggleModel' - Выбор модели (еще не доступен)`
const chatId = msg.chat.id
bot.sendMessage(chatId, message)
})
bot.onText(/\/start/, (msg) => {
const chatId = msg.chat.id;
const chatType = msg.chat.type
bot.sendMessage(chatId, `Чат перезапущен, тип чата ${chatType}`);
});
bot.on('message', (msg) => {
const chatId = msg.chat.id;
const user = msg.from
if (msg.text && msg.text.startsWith('/')) {
return;
}
if (msg.photo) {
bot.sendMessage(chatId, 'Красиво, но такое мне не надо');
return;
}
if (msg.document) {
bot.sendMessage(chatId, 'Такое мне не надо');
return;
}
if (msg.text) {
bot.sendMessage(chatId, `Ты написал: ${msg.text}`);
return;
}
});