-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
42 lines (34 loc) · 1.35 KB
/
bot.py
File metadata and controls
42 lines (34 loc) · 1.35 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
import asyncio
import logging
from aiogram import Bot, Dispatcher, types
from aiogram.enums import ParseMode
from config import BOT_TOKEN
from handlers import admin, group, user
from database import engine
import models
logging.basicConfig(level=logging.INFO)
models.Base.metadata.create_all(bind=engine)
async def main():
bot = Bot(token=BOT_TOKEN, parse_mode=ParseMode.HTML)
dp = Dispatcher()
admin.register_handlers(dp)
group.register_handlers(dp)
user.register_handlers(dp)
await bot.set_my_commands([
types.BotCommand(command="/start", description="Start the bot"),
types.BotCommand(command="/help", description="Show help message"),
types.BotCommand(command="/ban", description="Ban a user"),
types.BotCommand(command="/unban", description="Unban a user"),
types.BotCommand(command="/mute", description="Mute a user for 2 hours"),
types.BotCommand(command="/unmute", description="Unmute a user"),
types.BotCommand(command="/info", description="Bot info"),
types.BotCommand(command="/stats", description="Show bot statistics"),
])
try:
await dp.start_polling(bot)
except Exception as e:
logging.error(f"Error: {e}")
finally:
await bot.session.close()
if __name__ == "__main__":
asyncio.run(main())