Обновление 1.8

This commit is contained in:
Profitroll 2021-04-07 23:57:02 +03:00
parent 7598e594da
commit 5206b3e2fa
6 changed files with 132 additions and 36 deletions

106
daemon.py
View File

@ -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...")
@ -100,11 +104,18 @@ def getLessons():
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:
@ -243,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:
@ -407,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:
@ -595,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:
@ -1101,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
@ -1237,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"⚠ Уроки кончились, автовыключение {profilename}через {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
@ -1290,4 +1368,4 @@ if __name__ == '__main__':
import sys import sys
clear() 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

@ -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

View File

@ -30,7 +30,7 @@ import requests
import keyboard import keyboard
from zipfile import ZipFile from zipfile import ZipFile
version = 1.7 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()

44
rpc.py
View File

@ -6,7 +6,7 @@ import sys
from colors import * from colors import *
from functions import * from functions import *
version = '1.6' version = '1.8'
import libinstaller import libinstaller
from pypresence import Presence from pypresence import Presence
@ -27,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()
@ -35,6 +37,8 @@ def disconnect():
pass pass
def connect(): def connect():
global connected
try: try:
RPC.connect() RPC.connect()
connected = True connected = True
@ -56,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:
@ -71,11 +75,11 @@ 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:
@ -86,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:
@ -101,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:
@ -116,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:
@ -131,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:
@ -146,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:
@ -161,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)
@ -176,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)
################################################################################ ################################################################################
@ -250,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()
@ -288,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': 'Ожидание',
# } # }
# ) # )

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