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/main.py

79 lines
2.2 KiB
Python
Raw Normal View History

2022-10-25 15:18:51 +03:00
from threading import Thread
2022-10-20 16:08:46 +03:00
from time import time
2022-10-23 12:48:34 +03:00
from os import getpid, path
2022-10-25 15:18:51 +03:00
from modules.birthdays import check_birthdays
2022-10-17 00:30:07 +03:00
from modules.utils import *
2022-10-26 15:54:55 +03:00
from modules.inline import *
2022-10-25 15:18:51 +03:00
from schedule import run_pending, every
2022-10-26 15:54:55 +03:00
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
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 *
from modules.commands.message import *
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-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-10-25 15:18:51 +03: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()
app.send_message(configGet("owner"), f"Starting up with pid `{pid}`")
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-10-17 00:30:07 +03:00
idle()
app.send_message(configGet("owner"), f"Shutting with pid `{pid}`")
2022-10-17 00:30:07 +03:00
app.stop()
2022-10-17 00:30:07 +03:00
killProc(pid)