commit 8a5cef7e4978bfe099b617e65579b4a2da133e40 Author: sementodrik Date: Sun Jun 15 04:11:29 2025 +0300 первый коммит 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 0000000..d3dd6b3 Binary files /dev/null and b/users.db differ