4 Commits
v1.6 ... v1.8

Author SHA1 Message Date
5206b3e2fa Обновление 1.8 2021-04-07 23:57:02 +03:00
7598e594da Фикс номера версии 2021-04-06 01:53:48 +03:00
747e666cf1 Обновление 1.7
Фиксы багов связанных с RPC и файлами.
2021-04-06 01:32:55 +03:00
c8e3f64762 Фикс версии 2021-01-22 15:03:17 +02:00
7 changed files with 176 additions and 42 deletions

148
daemon.py
View File

@@ -10,7 +10,6 @@ import pathlib
import json
import getopt
import sys
import winsound
from random import randint
from pathlib import Path
from datetime import datetime, date, timedelta
@@ -30,6 +29,11 @@ if os.name == 'nt':
else:
clear = lambda: os.system('clear')
if os.name == 'nt':
import winsound
else:
import playsound
clear()
os.system("title Загрузка daemon...")
@@ -90,19 +94,28 @@ def getLessons():
if not os.path.exists(files_folder+'lessons.json'):
with open(files_folder+'lessons.json', 'w', encoding="utf-8") as f:
f.write("[]")
f.close()
lessons_list = []
else:
with open(files_folder+'lessons.json', encoding="utf-8") as json_file:
lessons_list = json.load(json_file)
json_file.close()
return lessons_list
def getState():
output = os.popen('wmic process get description, processid').read()
if "CptHost.exe" in output:
return True
else:
return False
if os.system == 'nt':
output = os.popen('wmic process get description, processid').read()
if "CptHost.exe" in output:
return True
else:
return False
### KODIL TUT
#else:
#check_result = subprocess.check_output('ps -efww', shell=True)
#if
def listLessons(from_where='remove'):
try:
@@ -241,7 +254,15 @@ def addLesson():
continue
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})
while True:
@@ -405,10 +426,18 @@ def editLesson():
continue
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 == '':
lesslink = lessons_got[edi]["link"]
local_lessons.update({"link": lesslink})
while True:
@@ -528,6 +557,7 @@ def removeAllLessons():
if removeall.lower() in ['y', 'yes', 'д', 'да']:
with open(files_folder+'lessons.json', 'w', encoding="utf-8") as f:
f.write("[]")
f.close()
clear()
none = input('Все уроки были удалены.\n\n > ')
clear()
@@ -592,11 +622,18 @@ def tgsend(enabled, message):
tg_file = open(files_folder+'telegram.conf', 'r', encoding="utf-8")
tg_text = tg_file.read()
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):
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():
try:
@@ -726,6 +763,7 @@ def settings():
if settings_choose == '1':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
config_list["debug"] = not getConfig("debug")
saveJson(files_folder+'config.json', config_list)
@@ -735,6 +773,7 @@ def settings():
elif settings_choose == '2':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
config_list["use_colors"] = not getConfig("use_colors")
saveJson(files_folder+'config.json', config_list)
@@ -744,6 +783,7 @@ def settings():
elif settings_choose == '3':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
config_list["run_fullscreen"] = not getConfig("run_fullscreen")
saveJson(files_folder+'config.json', config_list)
@@ -754,6 +794,7 @@ def settings():
elif settings_choose == '4':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
config_list["sounds"] = not getConfig("sounds")
saveJson(files_folder+'config.json', config_list)
@@ -764,6 +805,7 @@ def settings():
elif settings_choose == '5':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
if getConfig("obs_core") and getConfig("obs_exe") not in [None, 'Disabled']:
config_list["obs_core"] = 'Disabled'
@@ -819,6 +861,7 @@ def settings():
elif settings_choose == '6':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
config_list["shutdown_enabled"] = not getConfig("shutdown_enabled")
saveJson(files_folder+'config.json', config_list)
@@ -828,6 +871,7 @@ def settings():
elif settings_choose == '7':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
try:
clear()
@@ -844,6 +888,7 @@ def settings():
elif settings_choose == '8':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
try:
clear()
@@ -860,6 +905,7 @@ def settings():
elif settings_choose == '9':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
try:
clear()
@@ -876,6 +922,7 @@ def settings():
elif settings_choose == '10':
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
config_list["telegram_enabled"] = not getConfig("telegram_enabled")
saveJson(files_folder+'config.json', config_list)
@@ -946,6 +993,21 @@ def settings():
return
def main(source='deamon'):
##########################################
# Возможность профилей сделана для себя
# и не планируется как фича, однако
# вы можете присобачить сюда что хотите.
try:
from profile import profilename
except:
profilename = ''
pass
##########################################
try:
import time
from main import mainMenu
@@ -962,6 +1024,7 @@ def main(source='deamon'):
if obs_choice.lower() in ['y', 'yes', 'д', 'да']:
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
while True:
try:
filename = easygui.fileopenbox('Выберите путь до obs32.exe или obs64.exe')
@@ -999,9 +1062,13 @@ def main(source='deamon'):
break
break
elif obs_choice.lower() in ['n', 'no', 'н', 'нет']:
config_list["obs_exe"] = 'Disabled'
config_list["obs_core"] = 'Disabled'
saveJson(files_folder+'config.json', config_list)
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
config_list["obs_exe"] = 'Disabled'
config_list["obs_core"] = 'Disabled'
saveJson(files_folder+'config.json', config_list)
json_file.close()
clear()
break
else:
@@ -1032,6 +1099,7 @@ def main(source='deamon'):
elif tg_choice.lower() in ['n', 'no', 'н', 'нет']:
with open(files_folder+'telegram.conf', 'w', encoding="utf-8") as f:
f.write('Not Configured')
f.close()
lessons_count = 0
try:
@@ -1067,17 +1135,61 @@ def main(source='deamon'):
rpc.waitLesson(lesson_name, waiting_time_unix)
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)
if easteregg_number == 69420:
webbrowser.open('https://www.pornhub.com/view_video.php?viewkey=ph5f3eb1e206aa8')
print(f'{nowtime()} Ждём {BRED}10 секунд{RESET} до отслеживания Zoom...')
time.sleep(10)
retries = 0
while not getState():
if getConfig("debug"):
print(f'{nowtime()} Урок задерживается, ждём...')
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
record_now = False
@@ -1108,7 +1220,7 @@ def main(source='deamon'):
print(f'{nowtime()} Захвачен текущий урок в Zoom.')
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)
@@ -1203,7 +1315,7 @@ def main(source='deamon'):
if getConfig("shutdown_enabled"):
if getConfig("end_mode") == 'shutdown':
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}.')
playSound("shutdown")
end_unix = int(time.time())+getConfig("shutdown_timeout")*60
@@ -1256,4 +1368,4 @@ if __name__ == '__main__':
import sys
clear()
main()
main()

4
daemon.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
echo "Running AutoZoom daemon with Python 3. Please read README.md!"
python3 daemon.py

View File

@@ -34,6 +34,7 @@ def getConfig(some_var):
try:
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
return config_list[some_var]
except:
return "Error"
@@ -60,6 +61,7 @@ def getConfig(some_var):
try:
with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
config_list = json.load(json_file)
json_file.close()
return config_list[some_var]
except:
return "Error"
@@ -68,4 +70,5 @@ def getConfig(some_var):
def saveJson(filename, value):
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()

View File

@@ -61,6 +61,11 @@ try:
except ModuleNotFoundError:
libs.append("requests")
###################################
try:
import playsound
except ModuleNotFoundError:
libs.append("playsound")
###################################
try:
from zipfile import ZipFile
except ModuleNotFoundError:
@@ -102,6 +107,7 @@ if len(libs) > 0:
import telegram_send
import wget
import requests
import playsound
import asyncio
from zipfile import ZipFile
from pypresence import Presence

View File

@@ -30,7 +30,7 @@ import requests
import keyboard
from zipfile import ZipFile
version = 1.5
version = 1.8
path = Path(__file__).resolve().parent
def mainMenu():
@@ -273,4 +273,4 @@ if __name__ == '__main__':
keyboard.release('alt, enter')
os.system("title AutoZoom (Главная)")
mainMenu()
sys.exit()
sys.exit()

47
rpc.py
View File

@@ -3,9 +3,10 @@
import time
import os
import sys
from colors import *
from functions import *
version = '1.5'
version = '1.8'
import libinstaller
from pypresence import Presence
@@ -26,6 +27,8 @@ else:
connected = False
def disconnect():
global connected
if getConfig("use_rpc"):
try:
RPC.close()
@@ -34,6 +37,8 @@ def disconnect():
pass
def connect():
global connected
try:
RPC.connect()
connected = True
@@ -55,11 +60,11 @@ def waitLesson(lesson, start):
except AttributeError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
except AssertionError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
def onLesson(lesson, start):
try:
@@ -70,13 +75,13 @@ def onLesson(lesson, start):
except AttributeError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
except AssertionError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
def inMenu():
def inMenu():
try:
if getConfig("use_rpc"):
if connected == False:
@@ -85,11 +90,11 @@ def inMenu():
except AttributeError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
except AssertionError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
def shutdown(end):
try:
@@ -100,11 +105,11 @@ def shutdown(end):
except AttributeError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
except AssertionError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
def inSettings():
try:
@@ -115,11 +120,11 @@ def inSettings():
except AttributeError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
except AssertionError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
def inEditor():
try:
@@ -130,11 +135,11 @@ def inEditor():
except AttributeError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
except AssertionError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
def inUpdater():
try:
@@ -145,11 +150,11 @@ def inUpdater():
except AttributeError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
except AssertionError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
def inHelp():
try:
@@ -160,11 +165,11 @@ def inHelp():
except AttributeError:
if getConfig("debug"):
print(f'{RESET}Модуль {BRED}Discord RPC {RESET}не смог подключиться.\nВозможно, ваш {CYAN}Discord {RESET}не открыт.')
time.sleep(2)
time.sleep(1)
except AssertionError:
if getConfig("debug"):
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:
if getConfig("debug"):
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()
# time.sleep(2)
# time.sleep(1)
# discord_rpc.run_callbacks()
# discord_rpc.shutdown()
@@ -287,4 +292,4 @@ if __name__ == "__main__":
# 'large_image_text': f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom',
# 'small_image_text': 'Ожидание',
# }
# )
# )

4
start.sh Normal file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
echo "AutoZoom needs Python 3 to work. Please read README.md!"
python3 main.py