From 8a5cef7e4978bfe099b617e65579b4a2da133e40 Mon Sep 17 00:00:00 2001 From: sementodrik Date: Sun, 15 Jun 2025 04:11:29 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D0=B9=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 7 +++++++ app/handliers.py | 29 +++++++++++++++++++++++++++++ app/keyboard.py | 0 bot.py | 24 ++++++++++++++++++++++++ config.py | 1 + create_table.py | 20 ++++++++++++++++++++ req.txt | 2 ++ users.db | Bin 0 -> 12288 bytes 8 files changed, 83 insertions(+) create mode 100644 README.md create mode 100644 app/handliers.py create mode 100644 app/keyboard.py create mode 100644 bot.py create mode 100644 config.py create mode 100644 create_table.py create mode 100644 req.txt create mode 100644 users.db diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6c6d3f --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +#python 3.10 + +1. пропишите pip install -r req.txt + +2. перед запуском вставьте токен в файле config.py + +3. для запуска бота запустите файл bot.py diff --git a/app/handliers.py b/app/handliers.py new file mode 100644 index 0000000..10c522a --- /dev/null +++ b/app/handliers.py @@ -0,0 +1,29 @@ +import asyncio +from aiogram import F, Router +from aiogram.filters import CommandStart, Command +from aiogram.types import Message, CallbackQuery +from aiogram.enums import ParseMode +import app.keyboard as kb +import sqlite3 + +router = Router() + +@router.message(CommandStart()) +async def cmd_start(message: Message): + base = sqlite3.connect('users.db') + + cur = base.cursor() + + insert_user = """INSERT OR IGNORE INTO users (first_name, last_name, username, id, is_bot, is_premium) + VALUES (?, ?, ?, ?, ?, ?)""" + + val = (message.from_user.first_name, message.from_user.last_name, message.from_user.username, + message.from_user.id, message.from_user.is_bot, message.from_user.is_premium) + + cur.execute(insert_user, val) + + base.commit() + + base.close() + + await message.answer("тестовый ответ") \ No newline at end of file diff --git a/app/keyboard.py b/app/keyboard.py new file mode 100644 index 0000000..e69de29 diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..0b3f522 --- /dev/null +++ b/bot.py @@ -0,0 +1,24 @@ +import asyncio +import logging +from aiogram import F, Router, Dispatcher, Bot +from aiogram.types import Message, CallbackQuery, User +from aiogram.filters import CommandStart, Command +from aiogram.fsm.state import State, StatesGroup +from aiogram.fsm.context import FSMContext +from aiogram.enums import ParseMode +from config import TOKEN +from app.handliers import router + +bot = Bot(token=TOKEN) +dp = Dispatcher() + +async def main(): + dp.include_router(router) + await dp.start_polling(bot) + +if __name__ == '__main__': + logging.basicConfig(level=logging.INFO) + try: + asyncio.run(main()) + except KeyboardInterrupt: + print(' бот отключен') \ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000..3aec734 --- /dev/null +++ b/config.py @@ -0,0 +1 @@ +TOKEN='' \ No newline at end of file diff --git a/create_table.py b/create_table.py new file mode 100644 index 0000000..7d6c857 --- /dev/null +++ b/create_table.py @@ -0,0 +1,20 @@ +import sqlite3 + +base = sqlite3.connect('users.db') + +cur = base.cursor() + +cur.execute("""CREATE TABLE users ( + first_name TEXT, + last_name TEXT, + username TEXT UNIQUE, + id INTEGER PRIMARY KEY, + is_bot INTEGER, + is_premium INTEGER + ) + +""") + +base.commit() + +base.close() \ No newline at end of file diff --git a/req.txt b/req.txt new file mode 100644 index 0000000..60e9e24 --- /dev/null +++ b/req.txt @@ -0,0 +1,2 @@ +aiogram +asyncio \ No newline at end of file diff --git a/users.db b/users.db new file mode 100644 index 0000000000000000000000000000000000000000..d3dd6b3f9689cf774ccf1cb3c169a0e39fc61563 GIT binary patch literal 12288 zcmeI#K}*9h6bJC6ij~3WZoR&v0};ftU>!k#BC0H%de# z1MD~cylJcxvzllUo0 z7W60emI z*mwQ8_3YbjU^@f^AOHafKmY;|fB*y_009U<00PG<(6blA`~O&fFYW~a2tWV=5P$## OAOHafKmY;|Z~|LeZB9@C literal 0 HcmV?d00001