Contributions are very welcome! Here are some guidelines on how the project is designed.
-
All code is formatted using black formatter with the settings described in
pyproject.toml
. -
Each function must have a docstring at the beginning of the function body in the reStructuredText format. This is the default format of the docstrings generated by pycharm, and explains each argument passed to the function and what the function returns.
-
All arguments in a function must have type hints specified, along with type hints for the returned object if anything is returned.
There are a few self-imposed rules on the project structure to keep the project as tidy as possible.
-
All modules should be a single
.py
file in thetelebot/modules
directory. -
All database related code should be in
.py
files in thetelebot/modules/db
directory. -
Try to create one db handling file for a single module with the same name as the module, with the Document classes being defined first and then all helper functions defined at the bottom. These helper functions should cover all the different CRUD operations required and should be the only way to interact with the DB. Do not directly use the Document classes anywhere out of the db handling file. This is done to completely abstract database interaction to shift from MongoDB to anything else (SQL, Firestore, etc.) without changing any code in the modules themselves.
-
Make sure all modules function independently of each other. Deleting a
module.py
file or not loading that module during runtime should not affect the other modules. -
If there is a function that is not handling a bot functionality but only helping it achieve the functionality (e.g., a wrapper to check if the user has certain permissions or a function to get all the sticker packs belonging to a certain user), then
-
It should be in
telebot/functions.py
if it is going to be used in multiple modules. -
It should be in the
module.py
file if it is going to be used only in that module.
-
-
Keep in mind that some things might clash; e.g., a regex handler could clash with a command handler - in this case, you should put them in different dispatcher groups.
It might seem complicated, but it'll make sense when you get into it. Feel free to ask me for a hand/advice!