My template for aiogram bots
πHello everyone! This is the template for developing Telegram bots on Python with aiogram.π
When I was developing Telegramia, I've used these templates: aiogram-bot-template and tgbot_template for creating bots. And I have many probles with them. So I decided to create my own template.
Here you can understand how template works and what is imported from where.
classDiagram
bot <|-- loader: dp
bot <|-- aiogram: executor
bot <|-- `tgbot.handlers`
bot <|-- `tgbot.filters`: custom_filter
bot <|-- `tgbot.middlewares` : custom_middleware
bot <|-- `tgbot.services` : set_commands(), on_startup_notify()
bot <|-- `tgbot.config` : load_config()
`tgbot.handlers` <|-- some_handler
`tgbot.handlers` <|-- `tgbot.keyboards`: reply_keyboard, inline_keyboard
`tgbot.handlers` <|-- `tgbot.middlewares` : rate_limit()
`tgbot.handlers` <|-- `tgbot.states` : custom_state
some_handler <|-- loader: dp
loader <|-- `tgbot.config` : load_config()
`tgbot.keyboards` <|-- reply
`tgbot.keyboards` <|-- inline
`tgbot.middlewares` <|-- custom_middleware
`tgbot.services` <|-- set_default_commands
`tgbot.services` <|-- admins_notify
class bot{
Logger logger
executor
register_all_middlewares(dispatcher: Dispatcher)
register_all_filters(dispatcher: Dispatcher)
register_all_handlers(dispatcher: Dispatcher)
register_all_commands(dispatcher: Dispatcher)
on_startup(dispatcher: Dispatcher)
on_shutdown(dispatcher: Dispatcher)
executor.start_polling()
}
class aiogram{
executor
}
class loader{
Config config
Bot bot
Dispatcher dp
MemoryStorage storage
}
class `tgbot.config`{
load_config()
}
class `tgbot.handlers`{
}
class some_handler{
}
class `tgbot.filters`{
custom_filter
}
class `tgbot.keyboards`{
}
class reply {
reply_keyboard
}
class inline {
inline_keyboard
}
class `tgbot.middlewares` {
}
class custom_middleware {
rate_limit()
}
class `tgbot.misc` {
}
class `tgbot.models` {
}
class `tgbot.services` {
}
class set_default_commands {
set_commands()
}
class admins_notify {
on_startup_notify()
}
class `tgbot.states` {
custom_state
}
- Clone the repository
git clone https://github.com/mezgoodle/bot_template.git
- Install dependencies
pip install -r requirements.txt
-
Set the bot token in the tgbot.config.py file
-
Run the bot
python bot.py
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
MIT Β© mezgoodle