This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
Telegram/holochecker.py

87 lines
2.6 KiB
Python
Raw Normal View History

from os import getpid, makedirs
2022-10-17 00:30:07 +03:00
from modules.utils import *
2022-10-26 15:54:55 +03:00
from modules.inline import *
from app import app
2022-10-17 00:30:07 +03:00
2022-12-05 19:49:51 +02:00
from modules.commands_register import commands_register
from pyrogram import idle
2022-10-17 00:30:07 +03:00
2022-10-21 15:00:03 +03:00
pid = getpid()
2022-10-17 00:30:07 +03:00
makedirs(f'{configGet("cache", "locations")}{sep}avatars', exist_ok=True)
2022-10-21 15:00:03 +03:00
2022-12-05 19:49:51 +02:00
# Importing
from modules.commands.application import *
from modules.commands.applications import *
2022-12-10 18:29:06 +02:00
from modules.commands.label import *
2022-12-05 19:49:51 +02:00
from modules.commands.message import *
2022-12-15 16:12:41 +02:00
from modules.commands.nearby import *
2022-12-05 19:49:51 +02:00
from modules.commands.reapply import *
from modules.commands.reboot import *
from modules.commands.rules import *
2022-12-10 11:42:56 +02:00
from modules.commands.sponsorship import *
2022-12-05 19:49:51 +02:00
from modules.commands.start import *
from modules.commands.warn import *
from modules.commands.warnings import *
from modules.callbacks.nothing import *
from modules.callbacks.reapply import *
from modules.callbacks.rules import *
from modules.callbacks.sub import *
from modules.callbacks.sus import *
from modules.handlers.confirmation import *
from modules.handlers.contact import *
from modules.handlers.group_join import *
from modules.handlers.welcome import *
from modules.handlers.everything import *
2022-10-23 17:22:38 +03:00
2022-12-10 16:51:37 +02:00
from modules.scheduled import *
2022-10-17 00:30:07 +03:00
if __name__ == "__main__":
logWrite(f"Starting up with pid {pid}")
# Yes, it should be in some kind of async main() function but I don't give a shit.
2022-10-20 13:24:32 +03:00
# I did compare performance, almost no difference and it's much more useful this way. Change my mind.
app.start()
2022-10-17 00:30:07 +03:00
2022-12-10 16:51:37 +02:00
# if configGet("birthdays_notify"):
# every().day.at(configGet("birthdays_time")).do(check_birthdays, app)
# # Background tasks checker
# def background_task():
# try:
# while True:
# try:
# run_pending()
# #print('Checked')
# time.sleep(1)
# except:
# pass
# except KeyboardInterrupt:
# print('\nShutting down')
# killProc(pid)
# t = Thread(target=background_task)
# t.start()
try:
app.send_message(configGet("owner"), f"Starting up with pid `{pid}`")
except bad_request_400.PeerIdInvalid:
logWrite(f"Could not send startup message to bot owner. Perhaps user has not started the bot yet.")
2022-10-17 00:30:07 +03:00
2022-12-05 19:49:51 +02:00
commands_register(app)
2022-11-13 14:40:49 +02:00
2022-12-10 16:51:37 +02:00
scheduler.start()
2022-10-17 00:30:07 +03:00
idle()
2022-12-10 16:51:37 +02:00
try:
app.send_message(configGet("owner"), f"Shutting with pid `{pid}`")
except bad_request_400.PeerIdInvalid:
logWrite(f"Could not send shutdown message to bot owner. Perhaps user has not started the bot yet.")
2022-10-17 00:30:07 +03:00
app.stop()
2022-10-17 00:30:07 +03:00
killProc(pid)