-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
52 lines (41 loc) · 1.49 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from telethon import events
from config.processingCommands import *
from multiprocessing import Process, freeze_support
from gui.main import launch
from auth import client, User, CheckAuth
import ping3
import time
@client.on(events.NewMessage(outgoing=True, pattern='/'))
async def command_handler(message):
try:
response = str(ExecuteCommand(message.text))
except Exception:
return
await message.delete()
await message.respond(response)
@client.on(events.NewMessage(outgoing=True, pattern='/QuickMessage'))
async def output_interface(message):
await message.delete()
GuiProcess = Process(target=launch, name = 'GuiProcess', daemon=True, args=(User.is_authorized,))
GuiProcess.start()
def launch_telegram():
while True:
try:
ping3.ping('8.8.8.8')
CheckAuth()
if not User.is_authorized:
GuiProcess = Process(target=launch, name = 'GuiProcessAuth', daemon=True, args=(User.is_authorized,))
GuiProcess.start()
GuiProcess.join()
CheckAuth()
if not User.is_authorized: return
client.start()
client.run_until_disconnected()
break
except (ConnectionError, OSError):
time.sleep(5)
if __name__ == '__main__':
freeze_support()
MainProcess = Process(target=launch_telegram, name = 'TelegramPluginProcess')
MainProcess.start()
MainProcess.join()