Skip to content

'Modular' bot in aiogram #522

Answered by DLumi
DLumi asked this question in Q&A
Mar 12, 2021 · 2 comments · 4 replies
Discussion options

You must be logged in to vote

I've found what I was looking for, though, it surprises me how little info there's on the framework online.
If anyone wonders how to do it, here is the topic that helped me: #378

Though, I'll try to give my own explanation on the topic.
You should have your entry point, i.e. your main file (__main__.py in my case), and the modules that you want (e.g. message_handler.py, callback_handler.py). You might want to put the message and the callback handlers separately.
My folder structure looks like this:

Bot
-handlers
--callback
--message
__main__.py

Here's your __main__:

from handlers.message import message_handler
from handlers.callback import callback_handler

...

if __name__ == '__main__':…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@IvanShvedov
Comment options

@DLumi
Comment options

@polo7
Comment options

@tshipenchko
Comment options

Answer selected by evgfilim1
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2.x Issue or PR for legacy 2.x version
5 participants