You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Main Template/main.py
+3-35Lines changed: 3 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -51,11 +51,9 @@
51
51
importos# For running a command in the terminal
52
52
importplatform# For getting the operating system name
53
53
importsys# For system-specific parameters and functions
54
-
importtelegram_botastelegram_module# For setting Telegram prefix and device info
55
54
fromcoloramaimportStyle# For coloring the terminal
56
55
fromLoggerimportLogger# For logging output to both terminal and file
57
56
frompathlibimportPath# For handling file paths
58
-
fromtelegram_botimportTelegramBot, send_telegram_message# For sending progress messages to Telegram
59
57
60
58
61
59
# Macros:
@@ -72,9 +70,6 @@ class BackgroundColors: # Colors for the terminal
72
70
# Execution Constants:
73
71
VERBOSE=False# Set to True to output verbose messages
74
72
75
-
# Telegram Bot Setup:
76
-
TELEGRAM_BOT=None# Global Telegram bot instance (initialized in setup_telegram_bot)
77
-
78
73
# Logger Setup:
79
74
logger=Logger(f"./Logs/{Path(__file__).stem}.log", clean=True) # Create a Logger instance
80
75
sys.stdout=logger# Redirect stdout to the logger
@@ -136,36 +131,12 @@ def verify_dot_env_file():
136
131
env_path=Path(__file__).parent/".env"# Path to the .env file
137
132
138
133
ifnotverify_filepath_exists(env_path): # If the .env file does not exist
139
-
print(f"{BackgroundColors.CYAN}.env{BackgroundColors.YELLOW} file not found at {BackgroundColors.CYAN}{env_path}{BackgroundColors.YELLOW}. Telegram messages may not be sent.{Style.RESET_ALL}")
134
+
print(f"{BackgroundColors.CYAN}.env{BackgroundColors.YELLOW} file not found at {BackgroundColors.CYAN}{env_path}{BackgroundColors.YELLOW}.{Style.RESET_ALL}")
140
135
returnFalse# Return False
141
136
142
137
returnTrue# Return True if the .env file exists
143
138
144
139
145
-
defsetup_telegram_bot():
146
-
"""
147
-
Sets up the Telegram bot for progress messages.
148
-
149
-
:return: None
150
-
"""
151
-
152
-
verbose_output(
153
-
f"{BackgroundColors.GREEN}Setting up Telegram bot for messages...{Style.RESET_ALL}"
154
-
) # Output the verbose message
155
-
156
-
verify_dot_env_file() # Verify if the .env file exists
157
-
158
-
globalTELEGRAM_BOT# Declare the module-global telegram_bot variable
159
-
160
-
try: # Try to initialize the Telegram bot
161
-
TELEGRAM_BOT=TelegramBot() # Initialize Telegram bot for progress messages
print(f"{BackgroundColors.RED}Failed to initialize Telegram bot: {e}{Style.RESET_ALL}")
166
-
TELEGRAM_BOT=None# Set to None if initialization fails
167
-
168
-
169
140
defto_seconds(obj):
170
141
"""
171
142
Converts various time-like objects to seconds.
@@ -282,8 +253,8 @@ def main():
282
253
end="\n\n",
283
254
) # Output the welcome message
284
255
start_time=datetime.datetime.now() # Get the start time of the program
285
-
286
-
send_telegram_message(TELEGRAM_BOT, [f"Starting the Main Template Python program at {start_time.strftime('%d/%m/%Y - %H:%M:%S')}"]) # Send start message to Telegram
256
+
257
+
# Implement logic here
287
258
288
259
finish_time=datetime.datetime.now() # Get the finish time of the program
send_telegram_message(TELEGRAM_BOT, [f"Finished the Main Template Python program at {finish_time.strftime('%d/%m/%Y - %H:%M:%S')} with execution time {calculate_execution_time(start_time, finish_time)}"]) # Send finish message to Telegram
0 commit comments