Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
5206b3e2fa | |||
7598e594da | |||
747e666cf1 | |||
c8e3f64762 |
148
daemon.py
148
daemon.py
@@ -10,7 +10,6 @@ import pathlib
|
|||||||
import json
|
import json
|
||||||
import getopt
|
import getopt
|
||||||
import sys
|
import sys
|
||||||
import winsound
|
|
||||||
from random import randint
|
from random import randint
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from datetime import datetime, date, timedelta
|
from datetime import datetime, date, timedelta
|
||||||
@@ -30,6 +29,11 @@ if os.name == 'nt':
|
|||||||
else:
|
else:
|
||||||
clear = lambda: os.system('clear')
|
clear = lambda: os.system('clear')
|
||||||
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
import winsound
|
||||||
|
else:
|
||||||
|
import playsound
|
||||||
|
|
||||||
clear()
|
clear()
|
||||||
os.system("title Загрузка daemon...")
|
os.system("title Загрузка daemon...")
|
||||||
|
|
||||||
@@ -90,19 +94,28 @@ def getLessons():
|
|||||||
if not os.path.exists(files_folder+'lessons.json'):
|
if not os.path.exists(files_folder+'lessons.json'):
|
||||||
with open(files_folder+'lessons.json', 'w', encoding="utf-8") as f:
|
with open(files_folder+'lessons.json', 'w', encoding="utf-8") as f:
|
||||||
f.write("[]")
|
f.write("[]")
|
||||||
|
f.close()
|
||||||
lessons_list = []
|
lessons_list = []
|
||||||
else:
|
else:
|
||||||
with open(files_folder+'lessons.json', encoding="utf-8") as json_file:
|
with open(files_folder+'lessons.json', encoding="utf-8") as json_file:
|
||||||
lessons_list = json.load(json_file)
|
lessons_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
return lessons_list
|
return lessons_list
|
||||||
|
|
||||||
def getState():
|
def getState():
|
||||||
output = os.popen('wmic process get description, processid').read()
|
if os.system == 'nt':
|
||||||
if "CptHost.exe" in output:
|
output = os.popen('wmic process get description, processid').read()
|
||||||
return True
|
if "CptHost.exe" in output:
|
||||||
else:
|
return True
|
||||||
return False
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
### KODIL TUT
|
||||||
|
|
||||||
|
#else:
|
||||||
|
#check_result = subprocess.check_output('ps -efww', shell=True)
|
||||||
|
#if
|
||||||
|
|
||||||
def listLessons(from_where='remove'):
|
def listLessons(from_where='remove'):
|
||||||
try:
|
try:
|
||||||
@@ -241,7 +254,15 @@ def addLesson():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
clear()
|
clear()
|
||||||
lesslink = input(f'{RESET}Введите ссылку на конференцию:\n\n > {BRED}')
|
lesslink = input(f'{RESET}Введите ссылку на конференцию:\n{BBLACK}Формат: {BRED}https://us01web.zoom.us/j/ИДЕНТИФИКАТОР?pwd=ПАРОЛЬ{RESET}\n{BBLACK}Либо введите {YELLOW}1 {BBLACK}для добавления по номеру и паролю{RESET}\n\n > {BRED}')
|
||||||
|
|
||||||
|
if lesslink.replace(' ', '') == '1':
|
||||||
|
clear()
|
||||||
|
lessid = input(f'{RESET}Введите идентификатор конференции:\n{BBLACK}Формат: {BRED}012 3456 7890 {BBLACK} либо {BRED}01234567890{RESET}\n\n > {BRED}')
|
||||||
|
clear()
|
||||||
|
lesspasswd = input(f'{RESET}Введите код доступа (пароль) конференции:\n\n > {BRED}')
|
||||||
|
lesslink = f'https://us01web.zoom.us/j/{lessid.replace(" ", "")}?pwd={lesspasswd.replace(" ", "")}'
|
||||||
|
|
||||||
local_lessons.update({"link": lesslink})
|
local_lessons.update({"link": lesslink})
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -405,10 +426,18 @@ def editLesson():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
clear()
|
clear()
|
||||||
lesslink = input(f'{RESET}Введите ссылку на конференцию\n\nОригинальная ссылка: {BRED}{lessons_got[edi]["link"]}{RESET}\n\n > {BRED}')
|
lesslink = input(f'{RESET}Введите ссылку на конференцию:\n{BBLACK}Формат: {BRED}https://us01web.zoom.us/j/ИДЕНТИФИКАТОР?pwd=ПАРОЛЬ{RESET}\n{BBLACK}Либо введите {YELLOW}1 {BBLACK}для добавления по номеру и паролю{RESET}\n\n > {BRED}')
|
||||||
|
|
||||||
|
if lesslink.replace(' ', '') == '1':
|
||||||
|
clear()
|
||||||
|
lessid = input(f'{RESET}Введите идентификатор конференции:\n{BBLACK}Формат: {BRED}012 3456 7890 {BBLACK} либо {BRED}01234567890{RESET}\n\n > {BRED}')
|
||||||
|
clear()
|
||||||
|
lesspasswd = input(f'{RESET}Введите код доступа (пароль) конференции:\n\n > {BRED}')
|
||||||
|
lesslink = f'https://us01web.zoom.us/j/{lessid.replace(" ", "")}?pwd={lesspasswd.replace(" ", "")}'
|
||||||
|
|
||||||
if lesslink == '':
|
if lesslink == '':
|
||||||
lesslink = lessons_got[edi]["link"]
|
lesslink = lessons_got[edi]["link"]
|
||||||
|
|
||||||
local_lessons.update({"link": lesslink})
|
local_lessons.update({"link": lesslink})
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@@ -528,6 +557,7 @@ def removeAllLessons():
|
|||||||
if removeall.lower() in ['y', 'yes', 'д', 'да']:
|
if removeall.lower() in ['y', 'yes', 'д', 'да']:
|
||||||
with open(files_folder+'lessons.json', 'w', encoding="utf-8") as f:
|
with open(files_folder+'lessons.json', 'w', encoding="utf-8") as f:
|
||||||
f.write("[]")
|
f.write("[]")
|
||||||
|
f.close()
|
||||||
clear()
|
clear()
|
||||||
none = input('Все уроки были удалены.\n\n > ')
|
none = input('Все уроки были удалены.\n\n > ')
|
||||||
clear()
|
clear()
|
||||||
@@ -592,11 +622,18 @@ def tgsend(enabled, message):
|
|||||||
tg_file = open(files_folder+'telegram.conf', 'r', encoding="utf-8")
|
tg_file = open(files_folder+'telegram.conf', 'r', encoding="utf-8")
|
||||||
tg_text = tg_file.read()
|
tg_text = tg_file.read()
|
||||||
if tg_text != 'Not Configured':
|
if tg_text != 'Not Configured':
|
||||||
telegram_send.send(messages=[f"{message}"], parse_mode="markdown", conf=files_folder+"telegram.conf")
|
try:
|
||||||
|
telegram_send.send(messages=[f"{message}"], parse_mode="markdown", conf=files_folder+"telegram.conf")
|
||||||
|
except as Exception:
|
||||||
|
print(f'{nowtime()} Не удалось отправить Telegram сообщение "{message}" (Ошибка: {Exception})')
|
||||||
|
|
||||||
def playSound(soundname):
|
def playSound(soundname):
|
||||||
if getConfig("sounds"):
|
if getConfig("sounds"):
|
||||||
winsound.PlaySound(sounds_folder+soundname+".wav", winsound.SND_FILENAME)
|
|
||||||
|
if os.name == 'nt':
|
||||||
|
winsound.PlaySound(sounds_folder+soundname+".wav", winsound.SND_FILENAME)
|
||||||
|
else:
|
||||||
|
playsound.playsound(sounds_folder+soundname+".wav")
|
||||||
|
|
||||||
def settings():
|
def settings():
|
||||||
try:
|
try:
|
||||||
@@ -726,6 +763,7 @@ def settings():
|
|||||||
if settings_choose == '1':
|
if settings_choose == '1':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
config_list["debug"] = not getConfig("debug")
|
config_list["debug"] = not getConfig("debug")
|
||||||
saveJson(files_folder+'config.json', config_list)
|
saveJson(files_folder+'config.json', config_list)
|
||||||
@@ -735,6 +773,7 @@ def settings():
|
|||||||
elif settings_choose == '2':
|
elif settings_choose == '2':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
config_list["use_colors"] = not getConfig("use_colors")
|
config_list["use_colors"] = not getConfig("use_colors")
|
||||||
saveJson(files_folder+'config.json', config_list)
|
saveJson(files_folder+'config.json', config_list)
|
||||||
@@ -744,6 +783,7 @@ def settings():
|
|||||||
elif settings_choose == '3':
|
elif settings_choose == '3':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
config_list["run_fullscreen"] = not getConfig("run_fullscreen")
|
config_list["run_fullscreen"] = not getConfig("run_fullscreen")
|
||||||
saveJson(files_folder+'config.json', config_list)
|
saveJson(files_folder+'config.json', config_list)
|
||||||
@@ -754,6 +794,7 @@ def settings():
|
|||||||
elif settings_choose == '4':
|
elif settings_choose == '4':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
config_list["sounds"] = not getConfig("sounds")
|
config_list["sounds"] = not getConfig("sounds")
|
||||||
saveJson(files_folder+'config.json', config_list)
|
saveJson(files_folder+'config.json', config_list)
|
||||||
@@ -764,6 +805,7 @@ def settings():
|
|||||||
elif settings_choose == '5':
|
elif settings_choose == '5':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
if getConfig("obs_core") and getConfig("obs_exe") not in [None, 'Disabled']:
|
if getConfig("obs_core") and getConfig("obs_exe") not in [None, 'Disabled']:
|
||||||
config_list["obs_core"] = 'Disabled'
|
config_list["obs_core"] = 'Disabled'
|
||||||
@@ -819,6 +861,7 @@ def settings():
|
|||||||
elif settings_choose == '6':
|
elif settings_choose == '6':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
config_list["shutdown_enabled"] = not getConfig("shutdown_enabled")
|
config_list["shutdown_enabled"] = not getConfig("shutdown_enabled")
|
||||||
saveJson(files_folder+'config.json', config_list)
|
saveJson(files_folder+'config.json', config_list)
|
||||||
@@ -828,6 +871,7 @@ def settings():
|
|||||||
elif settings_choose == '7':
|
elif settings_choose == '7':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
clear()
|
clear()
|
||||||
@@ -844,6 +888,7 @@ def settings():
|
|||||||
elif settings_choose == '8':
|
elif settings_choose == '8':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
clear()
|
clear()
|
||||||
@@ -860,6 +905,7 @@ def settings():
|
|||||||
elif settings_choose == '9':
|
elif settings_choose == '9':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
clear()
|
clear()
|
||||||
@@ -876,6 +922,7 @@ def settings():
|
|||||||
elif settings_choose == '10':
|
elif settings_choose == '10':
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
config_list["telegram_enabled"] = not getConfig("telegram_enabled")
|
config_list["telegram_enabled"] = not getConfig("telegram_enabled")
|
||||||
saveJson(files_folder+'config.json', config_list)
|
saveJson(files_folder+'config.json', config_list)
|
||||||
@@ -946,6 +993,21 @@ def settings():
|
|||||||
return
|
return
|
||||||
|
|
||||||
def main(source='deamon'):
|
def main(source='deamon'):
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
# Возможность профилей сделана для себя
|
||||||
|
# и не планируется как фича, однако
|
||||||
|
# вы можете присобачить сюда что хотите.
|
||||||
|
|
||||||
|
try:
|
||||||
|
from profile import profilename
|
||||||
|
except:
|
||||||
|
profilename = ''
|
||||||
|
pass
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import time
|
import time
|
||||||
from main import mainMenu
|
from main import mainMenu
|
||||||
@@ -962,6 +1024,7 @@ def main(source='deamon'):
|
|||||||
if obs_choice.lower() in ['y', 'yes', 'д', 'да']:
|
if obs_choice.lower() in ['y', 'yes', 'д', 'да']:
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
filename = easygui.fileopenbox('Выберите путь до obs32.exe или obs64.exe')
|
filename = easygui.fileopenbox('Выберите путь до obs32.exe или obs64.exe')
|
||||||
@@ -999,9 +1062,13 @@ def main(source='deamon'):
|
|||||||
break
|
break
|
||||||
break
|
break
|
||||||
elif obs_choice.lower() in ['n', 'no', 'н', 'нет']:
|
elif obs_choice.lower() in ['n', 'no', 'н', 'нет']:
|
||||||
config_list["obs_exe"] = 'Disabled'
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list["obs_core"] = 'Disabled'
|
config_list = json.load(json_file)
|
||||||
saveJson(files_folder+'config.json', config_list)
|
config_list["obs_exe"] = 'Disabled'
|
||||||
|
config_list["obs_core"] = 'Disabled'
|
||||||
|
saveJson(files_folder+'config.json', config_list)
|
||||||
|
json_file.close()
|
||||||
|
|
||||||
clear()
|
clear()
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
@@ -1032,6 +1099,7 @@ def main(source='deamon'):
|
|||||||
elif tg_choice.lower() in ['n', 'no', 'н', 'нет']:
|
elif tg_choice.lower() in ['n', 'no', 'н', 'нет']:
|
||||||
with open(files_folder+'telegram.conf', 'w', encoding="utf-8") as f:
|
with open(files_folder+'telegram.conf', 'w', encoding="utf-8") as f:
|
||||||
f.write('Not Configured')
|
f.write('Not Configured')
|
||||||
|
f.close()
|
||||||
lessons_count = 0
|
lessons_count = 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -1067,17 +1135,61 @@ def main(source='deamon'):
|
|||||||
rpc.waitLesson(lesson_name, waiting_time_unix)
|
rpc.waitLesson(lesson_name, waiting_time_unix)
|
||||||
|
|
||||||
waitStart(lesson_time, lambda: act(100))
|
waitStart(lesson_time, lambda: act(100))
|
||||||
webbrowser.open(lesson_url)
|
|
||||||
|
try:
|
||||||
|
if os.name == 'nt':
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
while i < 10:
|
||||||
|
lesson_url = lesson_url.replace(f"https://us0{i}web.zoom.us/j/", "zoommtg://zoom.us/join?action=join&confno=")
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
lesson_url = lesson_url.replace("&", "^&")
|
||||||
|
lesson_url = lesson_url.replace("?pwd", "^&pwd")
|
||||||
|
|
||||||
|
if getConfig("debug"):
|
||||||
|
print(lesson_url)
|
||||||
|
|
||||||
|
os.system(f'start {lesson_url}')
|
||||||
|
else:
|
||||||
|
i = 0
|
||||||
|
|
||||||
|
while i < 10:
|
||||||
|
lesson_url = lesson_url.replace(f"https://us0{i}web.zoom.us/j/", "zoommtg://zoom.us/join?action=join&confno=")
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
lesson_url = lesson_url.replace("?pwd=", "&pwd=")
|
||||||
|
|
||||||
|
if getConfig("debug"):
|
||||||
|
print(lesson_url)
|
||||||
|
|
||||||
|
os.system(f'xdg-open "{lesson_url}"')
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
webbrowser.open(lesson_url)
|
||||||
|
except:
|
||||||
|
print(f'{nowtime()} Открыть урок {CYAN}{lesson_name}{RESET} не удалось ни напрямую, ни в браузере.')
|
||||||
|
|
||||||
easteregg_number = randint(1, 100000)
|
easteregg_number = randint(1, 100000)
|
||||||
if easteregg_number == 69420:
|
if easteregg_number == 69420:
|
||||||
webbrowser.open('https://www.pornhub.com/view_video.php?viewkey=ph5f3eb1e206aa8')
|
webbrowser.open('https://www.pornhub.com/view_video.php?viewkey=ph5f3eb1e206aa8')
|
||||||
print(f'{nowtime()} Ждём {BRED}10 секунд{RESET} до отслеживания Zoom...')
|
print(f'{nowtime()} Ждём {BRED}10 секунд{RESET} до отслеживания Zoom...')
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
|
retries = 0
|
||||||
|
|
||||||
while not getState():
|
while not getState():
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{nowtime()} Урок задерживается, ждём...')
|
print(f'{nowtime()} Урок задерживается, ждём...')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
retries += 1
|
||||||
|
|
||||||
|
if retries == 36:
|
||||||
|
tgsend(getConfig("telegram_enabled"), f"⚠ Задержка урока *{lesson_name}* превысила 3 минуты {profilename}")
|
||||||
|
|
||||||
|
if retries == 120:
|
||||||
|
tgsend(getConfig("telegram_enabled"), f"⚠ Задержка урока *{lesson_name}* превысила 10 минут {profilename}")
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
record_now = False
|
record_now = False
|
||||||
@@ -1108,7 +1220,7 @@ def main(source='deamon'):
|
|||||||
print(f'{nowtime()} Захвачен текущий урок в Zoom.')
|
print(f'{nowtime()} Захвачен текущий урок в Zoom.')
|
||||||
|
|
||||||
playSound("started")
|
playSound("started")
|
||||||
tgsend(getConfig("telegram_enabled"), f"▶ Зашёл на урок *{lesson_name}* в *{nowtime(False, False, False)}*")
|
tgsend(getConfig("telegram_enabled"), f"▶ Зашёл на урок *{lesson_name}* в *{nowtime(False, False, False)}* {profilename}")
|
||||||
|
|
||||||
rpc.onLesson(lesson_name, start_time_unix)
|
rpc.onLesson(lesson_name, start_time_unix)
|
||||||
|
|
||||||
@@ -1203,7 +1315,7 @@ def main(source='deamon'):
|
|||||||
if getConfig("shutdown_enabled"):
|
if getConfig("shutdown_enabled"):
|
||||||
if getConfig("end_mode") == 'shutdown':
|
if getConfig("end_mode") == 'shutdown':
|
||||||
try:
|
try:
|
||||||
tgsend(getConfig("telegram_enabled"), f"⚠ Уроки кончились, автовыключение через {nowtime(False, False, False)} мин...")
|
tgsend(getConfig("telegram_enabled"), f"⚠ Уроки кончились, автовыключение {profilename}через {str(getConfig('shutdown_timeout'))} мин...")
|
||||||
print(f'{nowtime()} Ваш ПК автоматически выключится через {BRED}{str(getConfig("shutdown_timeout"))} мин{RESET}.')
|
print(f'{nowtime()} Ваш ПК автоматически выключится через {BRED}{str(getConfig("shutdown_timeout"))} мин{RESET}.')
|
||||||
playSound("shutdown")
|
playSound("shutdown")
|
||||||
end_unix = int(time.time())+getConfig("shutdown_timeout")*60
|
end_unix = int(time.time())+getConfig("shutdown_timeout")*60
|
||||||
@@ -1256,4 +1368,4 @@ if __name__ == '__main__':
|
|||||||
import sys
|
import sys
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
4
daemon.sh
Normal file
4
daemon.sh
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo "Running AutoZoom daemon with Python 3. Please read README.md!"
|
||||||
|
python3 daemon.py
|
@@ -34,6 +34,7 @@ def getConfig(some_var):
|
|||||||
try:
|
try:
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
return config_list[some_var]
|
return config_list[some_var]
|
||||||
except:
|
except:
|
||||||
return "Error"
|
return "Error"
|
||||||
@@ -60,6 +61,7 @@ def getConfig(some_var):
|
|||||||
try:
|
try:
|
||||||
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
|
||||||
config_list = json.load(json_file)
|
config_list = json.load(json_file)
|
||||||
|
json_file.close()
|
||||||
return config_list[some_var]
|
return config_list[some_var]
|
||||||
except:
|
except:
|
||||||
return "Error"
|
return "Error"
|
||||||
@@ -68,4 +70,5 @@ def getConfig(some_var):
|
|||||||
|
|
||||||
def saveJson(filename, value):
|
def saveJson(filename, value):
|
||||||
with open(filename, 'w', encoding="utf-8") as f:
|
with open(filename, 'w', encoding="utf-8") as f:
|
||||||
json.dump(value, f, indent=4, ensure_ascii=False)
|
json.dump(value, f, indent=4, ensure_ascii=False)
|
||||||
|
f.close()
|
@@ -61,6 +61,11 @@ try:
|
|||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
libs.append("requests")
|
libs.append("requests")
|
||||||
###################################
|
###################################
|
||||||
|
try:
|
||||||
|
import playsound
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
libs.append("playsound")
|
||||||
|
###################################
|
||||||
try:
|
try:
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
@@ -102,6 +107,7 @@ if len(libs) > 0:
|
|||||||
import telegram_send
|
import telegram_send
|
||||||
import wget
|
import wget
|
||||||
import requests
|
import requests
|
||||||
|
import playsound
|
||||||
import asyncio
|
import asyncio
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
from pypresence import Presence
|
from pypresence import Presence
|
||||||
|
4
main.py
4
main.py
@@ -30,7 +30,7 @@ import requests
|
|||||||
import keyboard
|
import keyboard
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
version = 1.5
|
version = 1.8
|
||||||
path = Path(__file__).resolve().parent
|
path = Path(__file__).resolve().parent
|
||||||
|
|
||||||
def mainMenu():
|
def mainMenu():
|
||||||
@@ -273,4 +273,4 @@ if __name__ == '__main__':
|
|||||||
keyboard.release('alt, enter')
|
keyboard.release('alt, enter')
|
||||||
os.system("title AutoZoom (Главная)")
|
os.system("title AutoZoom (Главная)")
|
||||||
mainMenu()
|
mainMenu()
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
47
rpc.py
47
rpc.py
@@ -3,9 +3,10 @@
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from colors import *
|
||||||
from functions import *
|
from functions import *
|
||||||
|
|
||||||
version = '1.5'
|
version = '1.8'
|
||||||
|
|
||||||
import libinstaller
|
import libinstaller
|
||||||
from pypresence import Presence
|
from pypresence import Presence
|
||||||
@@ -26,6 +27,8 @@ else:
|
|||||||
connected = False
|
connected = False
|
||||||
|
|
||||||
def disconnect():
|
def disconnect():
|
||||||
|
global connected
|
||||||
|
|
||||||
if getConfig("use_rpc"):
|
if getConfig("use_rpc"):
|
||||||
try:
|
try:
|
||||||
RPC.close()
|
RPC.close()
|
||||||
@@ -34,6 +37,8 @@ def disconnect():
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def connect():
|
def connect():
|
||||||
|
global connected
|
||||||
|
|
||||||
try:
|
try:
|
||||||
RPC.connect()
|
RPC.connect()
|
||||||
connected = True
|
connected = True
|
||||||
@@ -55,11 +60,11 @@ def waitLesson(lesson, start):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
def onLesson(lesson, start):
|
def onLesson(lesson, start):
|
||||||
try:
|
try:
|
||||||
@@ -70,13 +75,13 @@ def onLesson(lesson, start):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
def inMenu():
|
def inMenu():
|
||||||
try:
|
try:
|
||||||
if getConfig("use_rpc"):
|
if getConfig("use_rpc"):
|
||||||
if connected == False:
|
if connected == False:
|
||||||
@@ -85,11 +90,11 @@ def inMenu():
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
def shutdown(end):
|
def shutdown(end):
|
||||||
try:
|
try:
|
||||||
@@ -100,11 +105,11 @@ def shutdown(end):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
def inSettings():
|
def inSettings():
|
||||||
try:
|
try:
|
||||||
@@ -115,11 +120,11 @@ def inSettings():
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
def inEditor():
|
def inEditor():
|
||||||
try:
|
try:
|
||||||
@@ -130,11 +135,11 @@ def inEditor():
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
def inUpdater():
|
def inUpdater():
|
||||||
try:
|
try:
|
||||||
@@ -145,11 +150,11 @@ def inUpdater():
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
def inHelp():
|
def inHelp():
|
||||||
try:
|
try:
|
||||||
@@ -160,11 +165,11 @@ def inHelp():
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -175,7 +180,7 @@ if __name__ == "__main__":
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
if getConfig("debug"):
|
if getConfig("debug"):
|
||||||
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
|
||||||
time.sleep(2)
|
time.sleep(1)
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -249,7 +254,7 @@ if __name__ == "__main__":
|
|||||||
# )
|
# )
|
||||||
|
|
||||||
# discord_rpc.update_connection()
|
# discord_rpc.update_connection()
|
||||||
# time.sleep(2)
|
# time.sleep(1)
|
||||||
# discord_rpc.run_callbacks()
|
# discord_rpc.run_callbacks()
|
||||||
|
|
||||||
# discord_rpc.shutdown()
|
# discord_rpc.shutdown()
|
||||||
@@ -287,4 +292,4 @@ if __name__ == "__main__":
|
|||||||
# 'large_image_text': f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom',
|
# 'large_image_text': f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom',
|
||||||
# 'small_image_text': 'Ожидание',
|
# 'small_image_text': 'Ожидание',
|
||||||
# }
|
# }
|
||||||
# )
|
# )
|
||||||
|
Reference in New Issue
Block a user