first commit

This commit is contained in:
2026-01-23 17:20:44 +04:00
commit 2782f536e5
3 changed files with 76 additions and 0 deletions

56
bot.js Normal file
View File

@@ -0,0 +1,56 @@
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;
}
});