From 2782f536e5c441bb9328a495d25d7dbc9cffd0fc Mon Sep 17 00:00:00 2001 From: devmhand Date: Fri, 23 Jan 2026 17:20:44 +0400 Subject: [PATCH] first commit --- bot.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ example.env | 3 +++ package.json | 17 ++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 bot.js create mode 100644 example.env create mode 100644 package.json diff --git a/bot.js b/bot.js new file mode 100644 index 0000000..0b927f7 --- /dev/null +++ b/bot.js @@ -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; + } +}); diff --git a/example.env b/example.env new file mode 100644 index 0000000..f111874 --- /dev/null +++ b/example.env @@ -0,0 +1,3 @@ +TOKEN_TG = +TOKEN_AI = +SECRET_ID = \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..8b4b92d --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "bot-ai", + "version": "1.0.0", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "description": "", + "dependencies": { + "axios": "^1.13.2", + "dotenv": "^17.2.3", + "node-telegram-bot-api": "^0.67.0" + } +}