-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (61 loc) · 2.43 KB
/
Copy pathmain.py
File metadata and controls
78 lines (61 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import asyncio
import json
import logging
import os
import time
import aiosqlite
from aiogram import Bot, Dispatcher
from aiogram.fsm.storage.memory import MemoryStorage
from aiogram.types import FSInputFile
from database.knock_db import create_knock_cards_tables
from database.mailing import create_mailing_tables
from database.premium_db import create_premium_table
from database.tea_db import create_tea_table
from handlers.admin import adm_router
from handlers.handlers import handlers_router
from handlers.inline_knock import inline_router
from handlers.knock import knock_router
from handlers.premium import premium_router
from handlers.tea import tea_router
import config
from middlewares.throttling import ThrottlingMiddleware
async def reset_cooldown_user(user_id):
async with aiosqlite.connect('database.db') as db:
await db.execute('UPDATE knock_users SET last_usage = 0 WHERE user_id = ?', (user_id,))
await db.commit()
async def create_birds_with_file_ids(bot, chat_id, directory):
files = os.listdir(directory)
birds = []
for file_name in files:
file_path = os.path.join(directory, file_name)
if os.path.isfile(file_path):
photo = FSInputFile(file_path)
message = await bot.send_photo(chat_id=chat_id, photo=photo)
file_id = message.photo[-1].file_id
bird = {
'rarity': 'some rarity',
'name': os.path.splitext(file_name)[0],
'place': 'some place',
'photo': file_id,
'points': 'some_points'
}
birds.append(bird)
print(f"File ID for {file_name}: {file_id}")
time.sleep(3)
else:
print(f"Файл {file_path} не найден или не является файлом.")
return birds
async def main():
await create_tea_table()
await create_knock_cards_tables()
await create_mailing_tables()
await create_premium_table()
bot = Bot(token=config.BOT_TOKEN)
dp = Dispatcher(storage=MemoryStorage())
dp.include_routers(handlers_router, tea_router, knock_router, adm_router, premium_router, inline_router)
dp.message.middleware(ThrottlingMiddleware())
await bot.delete_webhook(drop_pending_updates=True)
await dp.start_polling(bot, allowed_updates=dp.resolve_used_update_types())
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
asyncio.run(main())