первый коммит
This commit is contained in:
7
README.md
Normal file
7
README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#python 3.10
|
||||||
|
|
||||||
|
1. пропишите pip install -r req.txt
|
||||||
|
|
||||||
|
2. перед запуском вставьте токен в файле config.py
|
||||||
|
|
||||||
|
3. для запуска бота запустите файл bot.py
|
29
app/handliers.py
Normal file
29
app/handliers.py
Normal file
@ -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("тестовый ответ")
|
0
app/keyboard.py
Normal file
0
app/keyboard.py
Normal file
24
bot.py
Normal file
24
bot.py
Normal file
@ -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(' бот отключен')
|
20
create_table.py
Normal file
20
create_table.py
Normal file
@ -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()
|
Reference in New Issue
Block a user