diff --git a/README.md b/README.md index 7083b96..94a7fcd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ ## Добро пожаловать в AutoZoom! +Contact me [directly](https://t.me/profitroll) or via [Support Center](https://www.tidio.com/talk/ydqcvfvgkud3jjk2482uaesvjpeohlh3) if you need English translation. В этом файле описаны все шаги которые нужно выполнить для работы с программой. ### Содержание @@ -12,6 +13,7 @@ * [GitHub вики проекта](https://github.com/profitrollgame/autozoom/wiki) * [Обратная связь и предложения](https://t.me/profitroll) * [Сообщить об ошибке/баге](https://github.com/profitrollgame/autozoom/issues) +* [Центр поддержки](https://www.tidio.com/talk/ydqcvfvgkud3jjk2482uaesvjpeohlh3) ### 1. Информация и описание программы diff --git a/daemon.py b/daemon.py index 29d8a07..7e6714c 100644 --- a/daemon.py +++ b/daemon.py @@ -44,12 +44,6 @@ import ast import inputimeout import telegram_send -if getOS() == "windows": - import winsound - from playsound import playsound -else: - from playsound import playsound - menu_choose = None try: @@ -273,7 +267,26 @@ def main(source='deamon'): today = date.today().strftime("%d.%m.%Y") - if (today == lesson_date) or (getDayNum(today) == lesson_repeat_day): + diff = ((datetime.strptime(today, "%d.%m.%Y") - datetime.strptime(lesson_date, "%d.%m.%Y")).days) + + if getConfig("debug"): + print(f'{nowtime()} Конференция {CYAN}{lesson_name}{RESET}: Разница дней {BRED}{diff}{RESET}, Повторение {BRED}{lesson_repeat}{RESET}.') + + if diff > 0 and not lesson_repeat: + + if getConfig("remove_old"): + + del lessons_list[lessons_list.index(les)] + + saveJson(files_folder+'lessons.json', lessons_list) + appendLog(f'Old lesson named {lesson_name} removed') + + if getConfig("debug"): + print(f'{nowtime()} Старая конференция {CYAN}{lesson_name}{RESET} за {CYAN}{lesson_date} {RESET}в {BRED}{lesson_time}{RESET} удалена.') + + lessons_list = getLessons() + + elif (today == lesson_date) or (getDayNum(today) == lesson_repeat_day): print(f'{BBLACK}================================================{RESET}\n') print(f'{nowtime()} Найдена конференция {CYAN}{lesson_name}{RESET} в {BRED}{lesson_time}{RESET}. Ждём начала...') diff --git a/editor.py b/editor.py index 652088d..da9da3a 100644 --- a/editor.py +++ b/editor.py @@ -65,8 +65,11 @@ def listLessons(from_where='remove'): def sortLessons(dictionary): - dictionary.sort(key = lambda x: datetime.strptime(x['time'], '%H:%M')) - dictionary.sort(key = lambda x: datetime.strptime(x['date'], '%d.%m.%Y')) + if getConfig("debug"): + print(dictionary) + + dictionary.sort(key = lambda x: datetime.strptime(x["time"], '%H:%M')) + dictionary.sort(key = lambda x: datetime.strptime(x["date"], '%d.%m.%Y')) appendLog('Lessons dictionary sorted') @@ -366,54 +369,70 @@ def editLesson(): while True: clear() + try: lesstime = input(f'{RESET}Введите время конференции ({BRED}ЧЧ:ММ{RESET}):\n\nОригинальное время: {BRED}{lessons_got[edi]["time"]}{RESET}\n\n > {BRED}') - finallesstime = (datetime.strptime(lesstime, "%H:%M")) - local_lessons.update({"time": lesstime}) - abort = "skip" - conflict = False - conflictles = '' - confstr = 'конференцией' - try: - - for lesson in lessons_got: + if lesstime == '': + finallesstime = lessons_got[edi]["time"] + lesstime = lessons_got[edi]["time"] - if lesson["date"] == finallessdate and lesson["time"] == lesstime: - conflict = True + local_lessons.update({"time": lesstime}) + + else: + try: + finallesstime = (datetime.strptime(lesstime, "%H:%M")) + finallesstime = lesstime + + local_lessons.update({"time": lesstime}) + + abort = "skip" + conflict = False + conflictles = '' + confstr = 'конференцией' + + try: + + for lesson in lessons_got: - if conflictles == '': - conflictles = f'{CYAN}{lesson["name"]}{RESET}' - confstr = 'конференцией' - - else: - conflictles += f', {CYAN}{lesson["name"]}{RESET}' - confstr = 'конференциями' - - if conflict: - while True: - clear() - choice = input(f'{RESET}Время и дата конференции совпадают с {confstr} {conflictles}.\nДобавить ещё одну конференцию на то же время? ({BGREEN}Да{RESET}/{BRED}Нет{RESET})\n\n > ') - - if choice.lower() in yes_list: - abort = "bypass" - break - - elif choice.lower() in no_list: - abort = "restart" - break - - else: - continue + if lesson["date"] == finallessdate and lesson["time"] == lesstime: + conflict = True - if abort == "restart": + if conflictles == '': + conflictles = f'{CYAN}{lesson["name"]}{RESET}' + confstr = 'конференцией' + + else: + conflictles += f', {CYAN}{lesson["name"]}{RESET}' + confstr = 'конференциями' + + if conflict: + while True: + clear() + choice = input(f'{RESET}Время и дата конференции совпадают с {confstr} {conflictles}.\nДобавить ещё одну конференцию на то же время? ({BGREEN}Да{RESET}/{BRED}Нет{RESET})\n\n > ') + + if choice.lower() in yes_list: + abort = "bypass" + break + + elif choice.lower() in no_list: + abort = "restart" + break + + else: + continue + + if abort == "restart": + continue + + else: + break + + except Exception as exp: + none = input(exp) + pass + except: continue - else: - break - - except Exception as exp: - none = input(exp) - pass break except: @@ -587,6 +606,32 @@ def removeAllLessons(): return +def debugLesson(): + try: + from profile import debuglink, name + appendLog('Debug link added to the list') + + local_lessons = {} + lessons_got = getLessons() + + local_lessons.update({"name": "Debug Lesson"}) + local_lessons.update({"date": date.today().strftime("%d.%m.%Y")}) + local_lessons.update({"time": "00:00"}) + local_lessons.update({"link": debuglink}) + local_lessons.update({"repeat": False}) + local_lessons.update({"repeat_day": None}) + local_lessons.update({"record": True}) + + lessons_got.append(dict(local_lessons)) + sortLessons(lessons_got) + saveJson(files_folder+'lessons.json', lessons_got) + + return f"{RESET}Конференция для отладки профиля {CYAN}{name} {RESET}была добавлена." + + except: + return f"{RESET}Для отладки нужен профиль {BRED}profile.py {RESET}со ссылкой на конференцию {BRED}debuglink {RESET}и именем {BRED}name{RESET}." + + def editor(): try: setTitle("AutoZoom (Редактор)", getOS()) diff --git a/functions.py b/functions.py index ef16d6f..63c0b09 100644 --- a/functions.py +++ b/functions.py @@ -31,6 +31,7 @@ default_config = { "run_fullscreen": False, "use_rpc": True, "sounds": True, + "remove_old": True, "end_mode": "shutdown", "obs_exe": None, "obs_core": None, @@ -70,6 +71,14 @@ else: clear = lambda: os.system('clear') +# Импортирование игралки звуков +if getOS() == "windows": + import winsound + from playsound import playsound +elif getOS() == "unix": + from playsound import playsound + + # Установка заголовка окна cmd.exe def setTitle(title, system): if system == "windows": diff --git a/libinstaller.py b/libinstaller.py index c67344d..22e6168 100644 --- a/libinstaller.py +++ b/libinstaller.py @@ -116,7 +116,8 @@ if getOS() != "android": libs.append("playsound") else: try: - os.system('pkg install play-audio') + if not "play-audio" in os.popen('pkg list-all').read(): + os.system('pkg install play-audio') except: appendLog("Could not install play-audio") ################################### diff --git a/main.py b/main.py index 83f8b85..accf1c3 100644 --- a/main.py +++ b/main.py @@ -36,7 +36,7 @@ import keyboard import getpass from zipfile import ZipFile -version = 2.1 +version = 2.2 path = Path(__file__).resolve().parent def mainMenu(): @@ -282,10 +282,12 @@ def devMenu(): print(f' {BRED}1.{RESET} PlaySound test') print(f' {BRED}2.{RESET} WinSound test') print(f' {BRED}3.{RESET} Play-audio test') - print(f' {BRED}4.{RESET} OS check test') - print(f' {BRED}5.{RESET} Telegram test') - print(f' {BRED}6.{RESET} Color test') - print(f' {BRED}7.{RESET} Exit to menu') + print(f' {BRED}4.{RESET} playSound function test') + print(f' {BRED}5.{RESET} OS check test') + print(f' {BRED}6.{RESET} Telegram test') + print(f' {BRED}7.{RESET} Zoom meeting test') + print(f' {BRED}8.{RESET} Color test') + print(f' {BRED}9.{RESET} Exit to menu') choose = input(f'\n > {BRED}') @@ -304,17 +306,27 @@ def devMenu(): continue elif choose == '4': + playSound("debug") + continue + + elif choose == '5': clear() none = input(f'{RESET}{getOS()}\n\n > ') continue - elif choose == '5': + elif choose == '6': clear() import telegram_send telegram_send.send(messages=["Telegram message test"], parse_mode="markdown", conf=files_folder+"telegram.conf") continue - elif choose == '6': + elif choose == '7': + clear() + print(editor.debugLesson()) + none = input(f'{RESET}\n > ') + continue + + elif choose == '8': clear() print(f'{BLACK}███{RED}███{GREEN}███{YELLOW}███{BLUE}███{MAGENTA}███{CYAN}███{WHITE}███') print(f'{BBLACK}███{BRED}███{BGREEN}███{BYELLOW}███{BBLUE}███{BMAGENTA}███{BCYAN}███{BWHITE}███') @@ -324,7 +336,7 @@ def devMenu(): none = input(RESET+'\n > ') continue - elif choose == '7': + elif choose == '9': rpc.inMenu() clear() setTitle("AutoZoom (Главная)", getOS()) @@ -382,6 +394,7 @@ def updater(serv_ver, version): print(f' {BRED}1.{RESET} Установить') print(f' {BRED}2.{RESET} Отменить') updater_decide = input(f'\n > {BRED}') + print(RESET) if updater_decide == '1': appendLog('Trying to update AutoZoom') diff --git a/rpc.py b/rpc.py index 0c74ecb..d82e414 100644 --- a/rpc.py +++ b/rpc.py @@ -6,7 +6,7 @@ import sys from colors import * from functions import * -version = '2.1' +version = '2.2' import libinstaller from pypresence import Presence @@ -59,7 +59,7 @@ def waitLesson(lesson, start): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_waiting', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Ожидание', state=f'Ждём начала «{lesson}»', details='Конференция не началась', start=start) + RPC.update(large_image='1024_cover', small_image='status_waiting', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Ожидание', state=f'Ждём начала «{lesson}»', details='Конференция не началась', start=start) appendLog(f'Discord RPC changed to waitLesson (Lesson: {lesson}, Start: {start})') except AttributeError: appendLog('Discord RPC failed to change status') @@ -77,7 +77,7 @@ def onLesson(lesson, start): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_lesson', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Конференция', state=f'Слушаем «{lesson}»', details='Идёт конференция', start=start) + RPC.update(large_image='1024_cover', small_image='status_lesson', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Конференция', state=f'Слушаем «{lesson}»', details='Идёт конференция', start=start) appendLog(f'Discord RPC changed to onLesson (Lesson: {lesson}, Start: {start})') except AttributeError: appendLog('Discord RPC failed to change status') @@ -95,7 +95,7 @@ def inMenu(): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_menu', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Главное меню', state='Открыт список опций', details='В главном меню') + RPC.update(large_image='1024_cover', small_image='status_menu', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Главное меню', state='Открыт список опций', details='В главном меню') appendLog('Discord RPC changed to inMenu') except AttributeError: appendLog('Discord RPC failed to change status') @@ -113,7 +113,7 @@ def shutdown(end): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_shutdown', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Выключение', state='Отсчёт до авто-выключения', details='Выключение ПК', end=end) + RPC.update(large_image='1024_cover', small_image='status_shutdown', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Выключение', state='Отсчёт до авто-выключения', details='Выключение ПК', end=end) appendLog(f'Discord RPC changed to shutdown (End: {end})') except AttributeError: appendLog('Discord RPC failed to change status') @@ -131,7 +131,7 @@ def inSettings(): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_settings', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Настройки', state='Открыты настройки', details='В главном меню') + RPC.update(large_image='1024_cover', small_image='status_settings', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Настройки', state='Открыты настройки', details='В главном меню') appendLog('Discord RPC changed to inSettings') except AttributeError: appendLog('Discord RPC failed to change status') @@ -149,7 +149,7 @@ def inDebug(): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_debug', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Отладка', state='Открыто меню отладки', details='В меню разработчика') + RPC.update(large_image='1024_cover', small_image='status_debug', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Отладка', state='Открыто меню отладки', details='В меню разработчика') appendLog('Discord RPC changed to inDebug') except AttributeError: appendLog('Discord RPC failed to change status') @@ -167,7 +167,7 @@ def inEditor(): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_editing', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Редактор', state='Открыт редактор', details='В главном меню') + RPC.update(large_image='1024_cover', small_image='status_editing', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Редактор', state='Открыт редактор', details='В главном меню') appendLog('Discord RPC changed to inEditor') except AttributeError: appendLog('Discord RPC failed to change status') @@ -185,7 +185,7 @@ def inUpdater(): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_updating', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Обновление', state='Открыт центр обновлений', details='В главном меню') + RPC.update(large_image='1024_cover', small_image='status_updating', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Обновление', state='Открыт центр обновлений', details='В главном меню') appendLog('Discord RPC changed to inUpdater') except AttributeError: appendLog('Discord RPC failed to change status') @@ -203,7 +203,7 @@ def inHelp(): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_support', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Помощь', state='Открыта помощь', details='В главном меню') + RPC.update(large_image='1024_cover', small_image='status_support', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Помощь', state='Открыта помощь', details='В главном меню') appendLog('Discord RPC changed to inHelp') except AttributeError: appendLog('Discord RPC failed to change status') @@ -221,7 +221,7 @@ def lessonEnded(): if getConfig("use_rpc") and getOS != "android": if connected == False: connect() - RPC.update(large_image='1024_cover', small_image='status_waiting', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Ожидание', state=f'Ждём указаний', details='Все конференции закончились') + RPC.update(large_image='1024_cover', small_image='status_waiting', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Ожидание', state=f'Ждём указаний', details='Все конференции закончились') appendLog('Discord RPC changed to lessonEnded') except AttributeError: appendLog('Discord RPC failed to change status') @@ -238,7 +238,7 @@ def lessonEnded(): if __name__ == "__main__": try: RPC.connect() - RPC.update(large_image='1024_cover', small_image='status_settings', large_text=f'AutoZoom • v{version}\nhttp://bit.ly/auto_zoom', small_text='Отладка', state='Модуль Discord RPC запущен в режиме тестирования', details='Режим отладки') + RPC.update(large_image='1024_cover', small_image='status_settings', large_text=f'AutoZoom • v{str(version)}\nhttp://bit.ly/auto_zoom', small_text='Отладка', state='Модуль Discord RPC запущен в режиме тестирования', details='Режим отладки') appendLog('Discord RPC changed to debug') except AttributeError: appendLog('Discord RPC failed to change status') diff --git a/settings.py b/settings.py index 6c0be3b..b439899 100644 --- a/settings.py +++ b/settings.py @@ -412,6 +412,13 @@ def settings3(): logs_val = f'{BRED}Выкл.{RESET}' else: logs_val = f'{BRED}ERROR{RESET}' + + if getConfig("remove_old"): + remove_val = f'{BGREEN}Вкл.{RESET}' + elif not getConfig("remove_old"): + remove_val = f'{BRED}Выкл.{RESET}' + else: + remove_val = f'{BRED}ERROR{RESET}' shutdown_time_val = getConfig("shutdown_timeout") start_val = getConfig("start") @@ -427,11 +434,14 @@ def settings3(): print(f' {BRED}3.{RESET} Добавить в автозапуск') print(f' {BBLACK}{winOnly(BRED, BBLACK, sysname, end=" ")}Автоматически запускать демона при входе в систему\n') + + print(f' {BRED}4.{RESET} Удалять старые конференции ({remove_val})') + print(f' {BBLACK}Автоматически удалять одноразовые конференции которые были до дня запуска\n') - print(f' {BRED}4.{RESET} Сбросить все настройки') + print(f' {BRED}5.{RESET} Сбросить все настройки') print(f' {BBLACK}Восстановить настройки по умолчанию\n') - print(f' {BRED}5.{RESET} Назад') + print(f' {BRED}6.{RESET} Назад') print(f' {BBLACK}Вернуться на предыдущую страницу{RESET}\n') print(f' {BBLACK}Для переключения параметров Вкл/Выкл просто введите номер{RESET}') #\n Если окно приложения слишком мелкое - увеличьте его или листайте это меню{RESET}') @@ -468,18 +478,18 @@ def settings3(): shutil.copyfile('daemon.bat', 'startdaemon.bat') - with open('startdaemon.bat', 'r') as f : + with open('startdaemon.bat', 'r', encoding='utf-8') as f : filedata = f.read() filedata = filedata.replace('python daemon.py', f'python {path}\\daemon.py') - with open('startdaemon.bat', 'w') as f: + with open('startdaemon.bat', 'w', encoding="utf-8") as f: f.write(filedata) f.close() swl.create_lnk(f'{path}\\startdaemon.bat', f'{pathlib.Path.home()}\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\AutoZoomDaemon.lnk') appendLog('Autorun script added') - none = input(f'Демон AutoZoom был добавлен в автозапуск.\nПуть: {BRED}{pathlib.Path.home()}\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\AutoZoomDaemon.lnk{RESET}\n\n > ') + none = input(f'{RESET}Демон AutoZoom был добавлен в автозапуск.\nПуть: {BRED}{pathlib.Path.home()}\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\AutoZoomDaemon.lnk{RESET}\n\n > ') continue except Exception as exp: @@ -492,8 +502,12 @@ def settings3(): else: continue - + elif settings_choose == '4': + setConfig("remove_old", not getConfig("remove_old")) + appendLog(f'Changed option "remove_old" to {getConfig("remove_old")}') + + elif settings_choose == '5': appendLog('Resetting configuration') while True: @@ -527,7 +541,7 @@ def settings3(): clear() continue - elif settings_choose == '5': + elif settings_choose == '6': appendLog('Returned to settings page 2') clear() return