motioneye-project / motioneye

A web frontend for the motion daemon.
GNU General Public License v3.0
3.99k stars 655 forks source link

Update sendtelegram.py #2872

Closed L1QU3D closed 1 year ago

L1QU3D commented 1 year ago

Imports and Constants: Imported necessary modules and grouped them based on standard libraries, third-party libraries, and local modules. Defined the constant user_agent and the messages dictionary at the beginning. Function and Variable Naming:

Renamed functions and variables to adhere to PEP 8 naming conventions and to make them more descriptive. Added docstrings to functions to explain their purpose. Combining Telegram Message Creation and Sending: Combined the functions for creating and sending Telegram messages into a single process to improve readability and maintainability.]

Main Function: Moved the main logic into a function named main and provided a generic parser for command line arguments (assuming it's an instance of argparse.ArgumentParser).

Script Execution Check: Added a check for if name == "main": to ensure that the script is only executed when run directly, not when imported as a module. Argument Parsing Function:

Created a function parse_command_line_args for parsing command line arguments using argparse.ArgumentParser.