D
D
Dmitry Kasatkin2022-04-21 18:08:31
Bots
Dmitry Kasatkin, 2022-04-21 18:08:31

How to split telegram bot code into several files?

The telegram bot has an admin panel and many different defs.
Please tell me how to break it all into files for convenient work.
I was not banned on Google, but I can’t find normal explanations there.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alan Gibizov, 2022-04-21
@phaggi

In short, you need to divide the code into meaningful blocks by topic, create a separate module for each topic, and separate the selected blocks into modules. Then import the rest of the modules, or individual functions from those modules, into the main module.
First try on some simple model of three or four functions.

O
Oleg, 2022-04-21
@402d

Here you just need to learn programming in the language (python? puff?).
bot is just a special case.
Now OOP is used - object-oriented programming.
The code is decomposed into separate files according to the principle of one class (interface, etc.) - one file
. Previously, a modular approach was common. Functions were put into one file based on logic convenient for development.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question