2021-01-15 23:01:23 +02:00
# -*- coding: utf-8 -*-
import subprocess
2021-01-21 14:00:58 +02:00
import contextlib
import importlib
2021-01-15 23:01:23 +02:00
import time
import datetime
import os
import pathlib
import json
import getopt
import sys
from random import randint
from pathlib import Path
from datetime import datetime , date , timedelta
2021-01-21 14:00:58 +02:00
from functions import *
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if getConfig ( " use_colors " ) :
from colors import *
else :
RESET = ' '
BLACK = RED = GREEN = YELLOW = BLUE = MAGENTA = CYAN = WHITE = ' '
BBLACK = BRED = BGREEN = BYELLOW = BBLUE = BMAGENTA = BCYAN = BWHITE = ' '
ULINE = REVERSE = ' '
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if os . name == ' nt ' :
clear = lambda : os . system ( ' cls ' )
else :
clear = lambda : os . system ( ' clear ' )
2021-04-07 23:57:02 +03:00
if os . name == ' nt ' :
import winsound
else :
import playsound
2021-01-21 14:00:58 +02:00
clear ( )
os . system ( " title Загрузка daemon... " )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
import libinstaller
import easygui
import tkinter
import keyboard
import ast
import inputimeout
import telegram_send
2021-01-15 23:01:23 +02:00
menu_choose = None
try :
from inputimeout import inputimeout , TimeoutOccurred
except :
2021-01-21 14:00:58 +02:00
print ( f ' [ { YELLOW } WARN { RESET } ] Н е удалось импортировать классы " inputimeout " и " TimeoutOccurred " из модуля " inputimeout " ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
def nowtime ( seconds = True , noice = True , color = True ) :
2021-01-15 23:01:23 +02:00
now = datetime . now ( )
if seconds == True :
justnow = now . strftime ( " % H: % M: % S " )
else :
justnow = now . strftime ( " % H: % M " )
if noice == True :
2021-01-21 14:00:58 +02:00
if not color :
beautiful = f ' [ { justnow } ] '
else :
beautiful = f ' [ { CYAN } { justnow } { RESET } ] '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
if not color :
beautiful = f ' { justnow } '
else :
beautiful = f ' { CYAN } { justnow } { RESET } '
2021-01-15 23:01:23 +02:00
return beautiful
def act ( x ) :
return x + 10
def waitStart ( runTime , action ) :
from datetime import datetime , time
from time import sleep
startTime = time ( * ( map ( int , runTime . split ( ' : ' ) ) ) )
while startTime > datetime . today ( ) . time ( ) :
sleep ( 2 )
return action
def getPair ( line ) :
key , sep , value = line . strip ( ) . partition ( " " )
return int ( key ) , value
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 ( " [] " )
2021-04-06 01:32:55 +03:00
f . close ( )
2021-01-15 23:01:23 +02:00
lessons_list = [ ]
else :
with open ( files_folder + ' lessons.json ' , encoding = " utf-8 " ) as json_file :
lessons_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
return lessons_list
def getState ( ) :
2021-04-07 23:57:02 +03:00
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
2021-01-15 23:01:23 +02:00
def listLessons ( from_where = ' remove ' ) :
try :
if from_where == ' editor ' :
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Полный список запланированных конференций: \n ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } ================================================ { RESET } ' )
2021-01-15 23:01:23 +02:00
for les in enumerate ( getLessons ( ) ) :
if les [ 1 ] [ " repeat " ] :
repeat = ' Вкл. '
else :
repeat = ' Выкл. '
if les [ 1 ] [ " record " ] :
record = ' Вкл. '
else :
record = ' Выкл. '
try :
repeat_day = getDay ( les [ 1 ] [ " repeat_day " ] )
except :
repeat_day = ' Н е повторяется'
length = len ( str ( les [ 0 ] ) )
2021-01-21 14:00:58 +02:00
spacer_all = 6 * ' '
spacer_ind = ( 5 - length ) * ' '
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
print ( f ' { spacer_all } Имя: { YELLOW } { les [ 1 ] [ " name " ] } { RESET } ' )
print ( f ' { spacer_all } Дата: { YELLOW } { les [ 1 ] [ " date " ] } { RESET } ' )
print ( f ' { spacer_all } Время: { YELLOW } { les [ 1 ] [ " time " ] } { RESET } ' )
print ( f ' { GREEN } { les [ 0 ] } { RESET } { spacer_ind } Ссылка: { YELLOW } { les [ 1 ] [ " link " ] } { RESET } ' )
print ( f ' { spacer_all } Повтор: { YELLOW } { repeat } { RESET } ' )
print ( f ' { spacer_all } День: { YELLOW } { repeat_day } { RESET } ' )
print ( f ' { spacer_all } Запись: { YELLOW } { record } { RESET } ' )
print ( f ' { BBLACK } ================================================ { RESET } ' )
2021-01-15 23:01:23 +02:00
if from_where == ' editor ' :
none = input ( ' \n \n > ' )
except KeyboardInterrupt :
clear ( )
return
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 ' ) )
def getDayNum ( day ) :
output = datetime . strptime ( day , " %d . % m. % Y " ) . isoweekday ( )
return output
def getDay ( number ) :
if number == 1 :
return ' Понедельник '
if number == 2 :
return ' Вторник '
if number == 3 :
return ' Среда '
if number == 4 :
return ' Четверг '
if number == 5 :
return ' Пятница '
if number == 6 :
return ' Суббота '
if number == 7 :
return ' Воскресенье '
def addLesson ( ) :
try :
local_lessons = { }
lessons_got = getLessons ( )
2021-01-21 14:00:58 +02:00
lessname = input ( f ' { RESET } Введите (своё) имя конференции: \n \n > { CYAN } ' )
2021-01-15 23:01:23 +02:00
local_lessons . update ( { " name " : lessname } )
while True :
clear ( )
today = date . today ( )
today_1 = date . today ( ) + timedelta ( days = 1 )
today_2 = date . today ( ) + timedelta ( days = 2 )
today_3 = date . today ( ) + timedelta ( days = 3 )
today_4 = date . today ( ) + timedelta ( days = 4 )
today_5 = date . today ( ) + timedelta ( days = 5 )
today_6 = date . today ( ) + timedelta ( days = 6 )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Введите дату урока или номер дня ( { BRED } ДД.М М .ГГГГ { RESET } ): \n ' )
print ( f ' { BRED } 1. { RESET } { today . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 2. { RESET } { today_1 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_1 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 3. { RESET } { today_2 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_2 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 4. { RESET } { today_3 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_3 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 5. { RESET } { today_4 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_4 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 6. { RESET } { today_5 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_5 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 7. { RESET } { today_6 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_6 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
2021-01-15 23:01:23 +02:00
try :
2021-01-21 14:00:58 +02:00
lessdate = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if lessdate == ' ' :
finallessdate = lessons_got [ edi ] [ " date " ]
elif lessdate == ' 1 ' :
finallessdate = today . strftime ( " %d . % m. % Y " )
elif lessdate == ' 2 ' :
finallessdate = today_1 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 3 ' :
finallessdate = today_2 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 4 ' :
finallessdate = today_3 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 5 ' :
finallessdate = today_4 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 6 ' :
finallessdate = today_5 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 7 ' :
finallessdate = today_6 . strftime ( " %d . % m. % Y " )
else :
try :
test = ( datetime . strptime ( lessdate , " %d . % m. % Y " ) )
finallessdate = lessdate
except :
continue
local_lessons . update ( { " date " : finallessdate } )
break
except :
continue
while True :
clear ( )
try :
2021-01-21 14:00:58 +02:00
lesstime = input ( f ' { RESET } Введите время конференции ( { BRED } ЧЧ:М М { RESET } ): \n \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
finallesstime = ( datetime . strptime ( lesstime , " % H: % M " ) )
local_lessons . update ( { " time " : lesstime } )
break
except :
continue
clear ( )
2021-04-07 23:57:02 +03:00
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 ( " " , " " ) } '
2021-01-15 23:01:23 +02:00
local_lessons . update ( { " link " : lesslink } )
while True :
clear ( )
2021-01-21 14:00:58 +02:00
repeat = input ( f ' { RESET } Повторять эту конференцию ( { getDay ( getDayNum ( finallessdate ) ) } )? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) \n \n > ' )
2021-01-15 23:01:23 +02:00
if repeat . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
finalrepeat = True
finalrepeatday = getDayNum ( finallessdate )
local_lessons . update ( { " repeat " : finalrepeat } )
local_lessons . update ( { " repeat_day " : finalrepeatday } )
break
elif repeat . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
finalrepeat = False
finalrepeatday = None
local_lessons . update ( { " repeat " : finalrepeat } )
local_lessons . update ( { " repeat_day " : finalrepeatday } )
break
else :
continue
while True :
clear ( )
2021-01-21 14:00:58 +02:00
lessrecord = input ( f ' Записать эту конференцию? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) \n \n > ' )
2021-01-15 23:01:23 +02:00
if lessrecord . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
finallessrecord = True
local_lessons . update ( { " record " : finallessrecord } )
break
elif lessrecord . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
finallessrecord = False
local_lessons . update ( { " record " : finallessrecord } )
break
else :
continue
lessons_got . append ( dict ( local_lessons ) )
sortLessons ( lessons_got )
saveJson ( files_folder + ' lessons.json ' , lessons_got )
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' Добавлен урок { CYAN } { local_lessons [ " name " ] } { RESET } за { BRED } { local_lessons [ " date " ] } { RESET } на время { BRED } { local_lessons [ " time " ] } { RESET } . ' )
2021-01-15 23:01:23 +02:00
none = input ( ' \n > ' )
except KeyboardInterrupt :
clear ( )
return
def editLesson ( ) :
try :
local_lessons = { }
lessons_got = getLessons ( )
while True :
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Выберите номер (индекс) для изменения: \n ' )
2021-01-15 23:01:23 +02:00
listLessons ( )
lessons_got = getLessons ( )
2021-01-21 14:00:58 +02:00
print ( f ' \n Для отмены операции введите { BRED } c { RESET } или { BRED } cancel { RESET } ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
edi = input ( f ' \n > { BGREEN } ' )
2021-01-15 23:01:23 +02:00
if not isinstance ( edi , int ) :
if edi . lower ( ) == ' c ' or edi . lower ( ) == ' cancel ' :
clear ( )
return
try :
edi = int ( edi )
except :
clear ( )
continue
try :
probe = lessons_got [ edi ] [ " name " ]
break
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Выберите { ULINE } правильный { RESET } индекс (номер) для изменения. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 3 )
clear ( )
continue
break
clear ( )
2021-01-21 14:00:58 +02:00
lessname = input ( f ' { RESET } Введите (своё) имя конференции: \n \n Оригинальное имя: { CYAN } { lessons_got [ edi ] [ " name " ] } { RESET } \n \n > { CYAN } ' )
2021-01-15 23:01:23 +02:00
if lessname == ' ' :
lessname = lessons_got [ edi ] [ " name " ]
local_lessons . update ( { " name " : lessname } )
while True :
clear ( )
today = date . today ( )
today_1 = date . today ( ) + timedelta ( days = 1 )
today_2 = date . today ( ) + timedelta ( days = 2 )
today_3 = date . today ( ) + timedelta ( days = 3 )
today_4 = date . today ( ) + timedelta ( days = 4 )
today_5 = date . today ( ) + timedelta ( days = 5 )
today_6 = date . today ( ) + timedelta ( days = 6 )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Введите дату урока или номер дня ( { BRED } ДД.М М .ГГГГ { RESET } ): \n ' )
print ( f ' { BRED } 1. { RESET } { today . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 2. { RESET } { today_1 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_1 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 3. { RESET } { today_2 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_2 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 4. { RESET } { today_3 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_3 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 5. { RESET } { today_4 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_4 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 6. { RESET } { today_5 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_5 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' { BRED } 7. { RESET } { today_6 . strftime ( " %d . % m. % Y " ) } ( { BGREEN } { getDay ( datetime . strptime ( today_6 . strftime ( " %d . % m. % Y " ) , " %d . % m. % Y " ) . isoweekday ( ) ) } { RESET } ) ' )
print ( f ' \n Оригинальная дата: { BRED } { lessons_got [ edi ] [ " date " ] } { RESET } ' )
2021-01-15 23:01:23 +02:00
try :
2021-01-21 14:00:58 +02:00
lessdate = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if lessdate == ' ' :
finallessdate = lessons_got [ edi ] [ " date " ]
elif lessdate == ' 1 ' :
finallessdate = today . strftime ( " %d . % m. % Y " )
elif lessdate == ' 2 ' :
finallessdate = today_1 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 3 ' :
finallessdate = today_2 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 4 ' :
finallessdate = today_3 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 5 ' :
finallessdate = today_4 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 6 ' :
finallessdate = today_5 . strftime ( " %d . % m. % Y " )
elif lessdate == ' 7 ' :
finallessdate = today_6 . strftime ( " %d . % m. % Y " )
else :
try :
test = ( datetime . strptime ( lessdate , " %d . % m. % Y " ) )
finallessdate = lessdate
except :
continue
local_lessons . update ( { " date " : finallessdate } )
break
except :
continue
while True :
clear ( )
try :
2021-01-21 14:00:58 +02:00
lesstime = input ( f ' { RESET } Введите время конференции ( { BRED } ЧЧ:М М { RESET } ): \n \n Оригинальное время: { BRED } { lessons_got [ edi ] [ " time " ] } { RESET } \n \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if lesstime == ' ' :
finallesstime = lessons_got [ edi ] [ " time " ]
lesstime = lessons_got [ edi ] [ " time " ]
else :
try :
finallesstime = ( datetime . strptime ( lesstime , " % H: % M " ) )
2021-01-21 14:00:58 +02:00
finallesstime = lesstime
2021-01-15 23:01:23 +02:00
except :
continue
local_lessons . update ( { " time " : lesstime } )
break
except :
continue
clear ( )
2021-04-07 23:57:02 +03:00
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 ( " " , " " ) } '
2021-01-15 23:01:23 +02:00
if lesslink == ' ' :
lesslink = lessons_got [ edi ] [ " link " ]
2021-04-07 23:57:02 +03:00
2021-01-15 23:01:23 +02:00
local_lessons . update ( { " link " : lesslink } )
while True :
clear ( )
2021-01-21 14:00:58 +02:00
try :
lessrepeatday = getDay ( lessons_got [ edi ] [ " repeat_day " ] )
except :
lessrepeatday = ' Н е повторяется'
print ( f ' { RESET } Повторять эту конференцию ( { YELLOW } { getDay ( getDayNum ( finallessdate ) ) } { RESET } )? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) ' )
print ( f ' \n Оригинальное значение: { BRED } { lessrepeatday } { RESET } ' )
repeat = input ( ' \n > ' )
2021-01-15 23:01:23 +02:00
if repeat . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
finalrepeat = True
finalrepeatday = getDayNum ( finallessdate )
local_lessons . update ( { " repeat " : finalrepeat } )
local_lessons . update ( { " repeat_day " : finalrepeatday } )
break
elif repeat . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
finalrepeat = False
local_lessons . update ( { " repeat " : finalrepeat } )
break
elif repeat == ' ' :
finalrepeat = lessons_got [ edi ] [ " repeat " ]
local_lessons . update ( { " repeat " : finalrepeat } )
try :
finalrepeatday = lessons_got [ edi ] [ " repeat_day " ]
local_lessons . update ( { " repeat_day " : finalrepeatday } )
except :
pass
break
else :
continue
while True :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' Записать эту конференцию? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) ' )
print ( f ' \n Оригинальное значение: { BRED } { lessons_got [ edi ] [ " record " ] } { RESET } ' )
lessrecord = input ( ' \n > ' )
2021-01-15 23:01:23 +02:00
if lessrecord . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
finallessrecord = True
local_lessons . update ( { " record " : finallessrecord } )
break
elif lessrecord . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
finallessrecord = False
local_lessons . update ( { " record " : finallessrecord } )
break
elif lessrecord == ' ' :
finallessrecord = lessons_got [ edi ] [ " record " ]
local_lessons . update ( { " record " : finallessrecord } )
break
else :
continue
del lessons_got [ edi ]
lessons_got . append ( dict ( local_lessons ) )
sortLessons ( lessons_got )
saveJson ( files_folder + ' lessons.json ' , lessons_got )
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' Изменён урок { CYAN } { lessname } { RESET } за { BRED } { finallessdate } { RESET } на время { BRED } { finallesstime } { RESET } . ' )
2021-01-15 23:01:23 +02:00
none = input ( ' \n > ' )
except KeyboardInterrupt :
clear ( )
return
def removeLesson ( ) :
try :
while True :
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Выберите номер (индекс) для удаления: \n ' )
2021-01-15 23:01:23 +02:00
listLessons ( )
lessons_local = getLessons ( )
2021-01-21 14:00:58 +02:00
print ( f ' \n { BBLACK } Для отмены операции введите { BRED } c { BBLACK } или { BRED } cancel { RESET } ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
rem = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if rem . lower ( ) == ' c ' or rem . lower ( ) == ' cancel ' :
clear ( )
break
else :
try :
rem = int ( rem )
except :
clear ( )
continue
try :
del_name = lessons_local [ rem ] [ " name " ]
del_date = lessons_local [ rem ] [ " date " ]
del_time = lessons_local [ rem ] [ " time " ]
del lessons_local [ rem ]
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Выберите { ULINE } правильный { RESET } индекс (номер) для удаления. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 3 )
clear ( )
continue
sortLessons ( lessons_local )
saveJson ( files_folder + ' lessons.json ' , lessons_local )
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Удалён урок { CYAN } { del_name } { RESET } за { BRED } { del_date } { RESET } на время { BRED } { del_time } { RESET } . ' )
2021-01-15 23:01:23 +02:00
none = input ( ' \n > ' )
break
except KeyboardInterrupt :
clear ( )
return
def removeAllLessons ( ) :
try :
while True :
clear ( )
2021-01-21 14:00:58 +02:00
removeall = input ( f ' { RESET } Вы уверены что хотите удалить все конференции? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) \n { BRED } Внимание! { RESET } Это действие нельзя обратить! \n Ваши настройки затронуты Н Е будут. \n \n > ' )
2021-01-15 23:01:23 +02:00
if removeall . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
with open ( files_folder + ' lessons.json ' , ' w ' , encoding = " utf-8 " ) as f :
f . write ( " [] " )
2021-04-06 01:32:55 +03:00
f . close ( )
2021-01-15 23:01:23 +02:00
clear ( )
none = input ( ' В с е уроки были удалены.\n \n > ' )
clear ( )
break
elif removeall . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
clear ( )
break
else :
continue
except KeyboardInterrupt :
clear ( )
return
2021-01-21 14:00:58 +02:00
import rpc
2021-01-15 23:01:23 +02:00
def editor ( ) :
try :
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Редактор) " )
2021-01-15 23:01:23 +02:00
from main import mainMenu
while True :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } » { RESET } Меню редактора \n ' )
print ( f ' { BRED } 1. { RESET } Добавить урок ' )
print ( f ' { BRED } 2. { RESET } Изменить урок ' )
print ( f ' { BRED } 3. { RESET } Удалить урок ' )
print ( f ' { BRED } 4. { RESET } Посмотреть уроки ' )
print ( f ' { BRED } 5. { RESET } Удалить все уроки ' )
print ( f ' { BRED } 6. { RESET } В главное меню ' )
editor_choose = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if editor_choose == ' 1 ' :
clear ( )
addLesson ( )
elif editor_choose == ' 2 ' :
clear ( )
editLesson ( )
elif editor_choose == ' 3 ' :
clear ( )
removeLesson ( )
elif editor_choose == ' 4 ' :
clear ( )
listLessons ( from_where = ' editor ' )
elif editor_choose == ' 5 ' :
clear ( )
removeAllLessons ( )
elif editor_choose == ' 6 ' :
2021-01-21 14:00:58 +02:00
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Главная) " )
2021-01-15 23:01:23 +02:00
mainMenu ( )
else :
continue
except KeyboardInterrupt :
2021-01-21 14:00:58 +02:00
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
return
def tgsend ( enabled , message ) :
if enabled :
2021-01-21 14:00:58 +02:00
if os . path . exists ( files_folder + ' telegram.conf ' ) :
tg_file = open ( files_folder + ' telegram.conf ' , ' r ' , encoding = " utf-8 " )
tg_text = tg_file . read ( )
if tg_text != ' Not Configured ' :
2021-04-07 23:57:02 +03:00
try :
telegram_send . send ( messages = [ f " { message } " ] , parse_mode = " markdown " , conf = files_folder + " telegram.conf " )
except as Exception :
print ( f ' { nowtime ( ) } Н е удалось отправить Telegram сообщение " { message } " (Ошибка: { Exception } ) ' )
2021-01-21 14:00:58 +02:00
def playSound ( soundname ) :
if getConfig ( " sounds " ) :
2021-04-07 23:57:02 +03:00
if os . name == ' nt ' :
winsound . PlaySound ( sounds_folder + soundname + " .wav " , winsound . SND_FILENAME )
else :
playsound . playsound ( sounds_folder + soundname + " .wav " )
2021-01-15 23:01:23 +02:00
def settings ( ) :
try :
while True :
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Настройки) " )
2021-01-15 23:01:23 +02:00
clear ( )
if getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
debug_val = f ' { BGREEN } Вкл. { RESET } '
2021-01-15 23:01:23 +02:00
elif not getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
debug_val = f ' { BRED } Выкл. { RESET } '
else :
debug_val = f ' { BRED } ERROR { RESET } '
if getConfig ( " run_fullscreen " ) :
fullscreen_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " run_fullscreen " ) :
fullscreen_val = f ' { BRED } Выкл. { RESET } '
else :
fullscreen_val = f ' { BRED } ERROR { RESET } '
if getConfig ( " sounds " ) :
sounds_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " sounds " ) :
sounds_val = f ' { BRED } Выкл. { RESET } '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
sounds_val = f ' { BRED } ERROR { RESET } '
2021-01-22 14:53:33 +02:00
if getConfig ( " obs_exe " ) and getConfig ( " obs_core " ) not in [ None , ' Disabled ' ] :
obs_val = f ' { BGREEN } Вкл. { RESET } '
else :
obs_val = f ' { BRED } Выкл. { RESET } '
2021-01-21 14:00:58 +02:00
# Пока слишком много ошибок
# if getConfig("use_rpc"):
# rpc_val = f'{BGREEN}Вкл.{RESET}'
# elif not getConfig("use_rpc"):
# rpc_val = f'{BRED}Выкл.{RESET}'
# else:
# rpc_val = f'{BRED}ERROR{RESET}'
if getConfig ( " use_colors " ) :
color_val = f ' { BGREEN } Вкл. { RESET } '
elif not getConfig ( " use_colors " ) :
color_val = f ' { BRED } Выкл. { RESET } '
else :
color_val = f ' { BRED } ERROR { RESET } '
2021-01-15 23:01:23 +02:00
if getConfig ( " shutdown_enabled " ) :
2021-01-21 14:00:58 +02:00
shutdown_en_val = f ' { BGREEN } Вкл. { RESET } '
2021-01-15 23:01:23 +02:00
elif not getConfig ( " shutdown_enabled " ) :
2021-01-21 14:00:58 +02:00
shutdown_en_val = f ' { BRED } Выкл. { RESET } '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
shutdown_en_val = f ' { BRED } ERROR { RESET } '
2021-01-15 23:01:23 +02:00
if os . path . exists ( files_folder + ' telegram.conf ' ) :
2021-01-21 14:00:58 +02:00
tg_file = open ( files_folder + ' telegram.conf ' , ' r ' , encoding = " utf-8 " )
tg_text = tg_file . read ( )
if tg_text != ' Not Configured ' :
tg_var = f ' { BGREEN } Настроен { RESET } '
else :
tg_var = f ' { BRED } Н е настроен{ RESET } '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
tg_var = f ' { BRED } Н е настроен{ RESET } '
2021-01-15 23:01:23 +02:00
if getConfig ( " telegram_enabled " ) :
2021-01-21 14:00:58 +02:00
telegram_en_val = f ' { BGREEN } Вкл. { RESET } '
2021-01-15 23:01:23 +02:00
elif not getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
telegram_en_val = f ' { BRED } Выкл. { RESET } '
2021-01-15 23:01:23 +02:00
else :
2021-01-21 14:00:58 +02:00
telegram_en_val = f ' { BRED } ERROR { RESET } '
2021-01-15 23:01:23 +02:00
shutdown_time_val = getConfig ( " shutdown_timeout " )
start_val = getConfig ( " start " )
stop_val = getConfig ( " stop " )
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
print ( f ' { RESET } { BBLACK } » { RESET } Настройки \n ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BRED } 1. { RESET } Режим отладки ( { debug_val } ) ' )
print ( f ' { BBLACK } Н е рекомендуем включать е г о без необходимости\n ' )
print ( f ' { BRED } 2. { RESET } Цветной вывод ( { color_val } ) ' )
print ( f ' { BBLACK } Отображение цветных текстов в меню и выводе (нужен перезапуск) \n ' )
print ( f ' { BRED } 3. { RESET } Полный экран ( { fullscreen_val } ) ' )
print ( f ' { BBLACK } Эмулировать вызов полного экрана при запуске (окно должно быть в фокусе) \n ' )
print ( f ' { BRED } 4. { RESET } Звуковые сигналы ( { sounds_val } ) ' )
print ( f ' { BBLACK } Воспроизводить звуки при начале/конце уроков и записи видео \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 5. { RESET } Запись через OBS ( { obs_val } ) ' )
print ( f ' { BBLACK } Возможность записи уроков через OBS \n ' )
2021-01-21 14:00:58 +02:00
# Пока слишком много ошибок
# print(f' {BRED}3.{RESET} Discord RPC ({rpc_val})')
# print(f' {BBLACK}Показывать какой идёт урок и какое меню открыто (нужен перезапуск)\n')
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 6. { RESET } Автовыключение ( { shutdown_en_val } ) ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } Когда уроки закончатся компьютер выключится \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 7. { RESET } Таймаут выключения ( { YELLOW } { shutdown_time_val } мин. { RESET } ) ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } Время в минутах после которого ПК будет выключен \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 8. { RESET } Начать запись ( { YELLOW } { start_val } { RESET } ) ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } Комбинация клавиш для начала записи через OBS (см. документацию) \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 9. { RESET } Остановить запись ( { YELLOW } { stop_val } { RESET } ) ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } Комбинация клавиш для остановки записи через OBS (см. документацию) \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 10. { RESET } Отправлять уведомления ( { telegram_en_val } ) ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } Ваш бот отправит сообщениия о начале/конце урока и выключении ПК \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 11. { RESET } Настроить Telegram бота ( { tg_var } ) ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } Настроить на вашем ПК бота для ЛС (см. документацию) \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 12. { RESET } Сбросить все настройки ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } Восстановить настройки по умолчанию \n ' )
2021-01-22 14:53:33 +02:00
print ( f ' { BRED } 13. { RESET } В главное меню ' )
2021-01-21 14:00:58 +02:00
print ( f ' { BBLACK } Выйти без внесения изменений { RESET } \n ' )
print ( f ' { BBLACK } Для переключения параметров Вкл/Выкл просто введите номер \n Если окно приложения слишком мелкое - увеличьте е г о или листайте это меню { RESET } ' )
settings_choose = input ( f ' \n > { BRED } ' )
2021-01-15 23:01:23 +02:00
if settings_choose == ' 1 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
config_list [ " debug " ] = not getConfig ( " debug " )
saveJson ( files_folder + ' config.json ' , config_list )
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-01-15 23:01:23 +02:00
elif settings_choose == ' 2 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
config_list [ " use_colors " ] = not getConfig ( " use_colors " )
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , config_list )
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-01-15 23:01:23 +02:00
elif settings_choose == ' 3 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
config_list [ " run_fullscreen " ] = not getConfig ( " run_fullscreen " )
saveJson ( files_folder + ' config.json ' , config_list )
clear ( )
continue
elif settings_choose == ' 4 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-21 14:00:58 +02:00
config_list [ " sounds " ] = not getConfig ( " sounds " )
saveJson ( files_folder + ' config.json ' , config_list )
clear ( )
continue
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 5 ' :
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-22 14:53:33 +02:00
if getConfig ( " obs_core " ) and getConfig ( " obs_exe " ) not in [ None , ' Disabled ' ] :
config_list [ " obs_core " ] = ' Disabled '
config_list [ " obs_exe " ] = ' Disabled '
else :
clear ( )
obs_choice = input ( f ' { RESET } Хотите использовать запись через OBS? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ): ' )
if obs_choice . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
while True :
try :
filename = easygui . fileopenbox ( ' Выберите путь до obs32.exe или obs64.exe ' )
if filename . find ( " obs64.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 9 ]
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 9 ] } { RESET } ' )
time . sleep ( 3 )
break
elif filename . find ( " obs32.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 9 ]
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 9 ] } { RESET } ' )
time . sleep ( 3 )
break
elif filename . find ( " obs.exe " ) != - 1 :
f . write ( filename )
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 7 ]
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 7 ] } { RESET } ' )
time . sleep ( 3 )
break
else :
easygui . msgbox ( " Неверный путь " )
break
except :
none = input ( ' Вы не выбрали верный путь для OBS. \n \n > ' )
clear ( )
break
saveJson ( files_folder + ' config.json ' , config_list )
clear ( )
continue
2021-01-21 14:00:58 +02:00
# Пока слишком много ошибок
# elif settings_choose == '3':
# with open(f"{files_folder}config.json", encoding="utf-8") as json_file:
# config_list = json.load(json_file)
# config_list["use_rpc"] = not getConfig("use_rpc")
# saveJson(files_folder+'config.json', config_list)
# clear()
# continue
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 6 ' :
2021-01-21 14:00:58 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-21 14:00:58 +02:00
config_list [ " shutdown_enabled " ] = not getConfig ( " shutdown_enabled " )
saveJson ( files_folder + ' config.json ' , config_list )
clear ( )
continue
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 7 ' :
2021-01-21 14:00:58 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-21 14:00:58 +02:00
2021-01-15 23:01:23 +02:00
try :
clear ( )
2021-01-21 14:00:58 +02:00
config_list [ " shutdown_timeout " ] = int ( input ( f ' { RESET } Введите через сколько минут после конференции выключать ПК: \n \n > { BRED } ' ) )
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , config_list )
continue
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Нужно использовать целое число. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 2 )
continue
continue
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 8 ' :
2021-01-15 23:01:23 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
try :
clear ( )
2021-01-21 14:00:58 +02:00
config_list [ " start " ] = input ( f ' { RESET } Введите комбинацию клавиш для начала записи OBS: \n Эта комбинация должна быть идентична оной в самом OBS! \n \n > { YELLOW } ' )
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , config_list )
continue
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Нужно использовать комбинацию клавиш в виде текста. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 2 )
continue
continue
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 9 ' :
2021-01-15 23:01:23 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
try :
clear ( )
2021-01-21 14:00:58 +02:00
config_list [ " stop " ] = input ( f ' { RESET } Введите комбинацию клавиш для остановки записи OBS: \n Эта комбинация должна быть идентична оной в самом OBS! \n \n > { YELLOW } ' )
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , config_list )
continue
except :
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Нужно использовать комбинацию клавиш в виде текста. ' )
2021-01-15 23:01:23 +02:00
time . sleep ( 2 )
continue
continue
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 10 ' :
2021-01-15 23:01:23 +02:00
with open ( f " { files_folder } config.json " , encoding = " utf-8 " ) as json_file :
config_list = json . load ( json_file )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-15 23:01:23 +02:00
config_list [ " telegram_enabled " ] = not getConfig ( " telegram_enabled " )
saveJson ( files_folder + ' config.json ' , config_list )
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 11 ' :
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' { RESET } Пожалуйста, прочтите инструкцию по установке Telegram бота в { BRED } README.txt { RESET } ' )
print ( f ' или в документации/инструкции что в разделе { CYAN } Помощь { RESET } главного меню ' )
print ( f ' чтобы хорошо понимать что сейчас от вас нужно. ' )
none = input ( ' \n > ' )
2021-01-15 23:01:23 +02:00
while True :
clear ( )
try :
telegram_send . configure ( files_folder + ' telegram.conf ' , channel = False , group = False , fm_integration = False )
break
except :
clear ( )
continue
telegram_send . send ( messages = [ f " 🎊 Конфигурация правильна, всё работает! " ] , parse_mode = " markdown " , conf = f " { files_folder } telegram.conf " )
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 12 ' :
2021-01-15 23:01:23 +02:00
while True :
clear ( )
2021-01-21 14:00:58 +02:00
reset_decision = input ( f ' { RESET } Вы уверены что хотите сбросить настройки? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ) \n \n { BRED } Внимание! { RESET } Это действие нельзя обратить! \n Ваш список конференций затронут Н Е будет. \n \n > ' )
2021-01-15 23:01:23 +02:00
if reset_decision . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
temp_config_list = { }
temp_config_list [ " debug " ] = False
temp_config_list [ " shutdown_timeout " ] = 30
temp_config_list [ " shutdown_enabled " ] = True
temp_config_list [ " start " ] = " shift+f7 "
temp_config_list [ " stop " ] = " shift+f8 "
temp_config_list [ " telegram_enabled " ] = False
2021-01-21 14:00:58 +02:00
temp_config_list [ " use_colors " ] = True
2021-01-22 14:53:33 +02:00
temp_config_list [ " run_fullscreen " ] = False
temp_config_list [ " use_rpc " ] = True
temp_config_list [ " sounds " ] = True
temp_config_list [ " end_mode " ] = " shutdown "
temp_config_list [ " obs_exe " ] = None
temp_config_list [ " obs_core " ] = None
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' config.json ' , temp_config_list )
clear ( )
2021-01-21 14:00:58 +02:00
none = input ( f ' { RESET } В с е настройки были сброшены до стандартных.\n \n > ' )
2021-01-15 23:01:23 +02:00
clear ( )
break
elif reset_decision . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
clear ( )
break
else :
clear ( )
continue
continue
clear ( )
continue
2021-01-21 14:00:58 +02:00
2021-01-22 14:53:33 +02:00
elif settings_choose == ' 13 ' :
2021-01-21 14:00:58 +02:00
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Главная) " )
2021-01-15 23:01:23 +02:00
return
except KeyboardInterrupt :
2021-01-21 14:00:58 +02:00
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
return
def main ( source = ' deamon ' ) :
2021-04-06 01:32:55 +03:00
##########################################
# Возможность профилей сделана для себя
# и не планируется как фича, однако
# вы можете присобачить сюда что хотите.
try :
from profile import profilename
except :
profilename = ' '
pass
##########################################
2021-01-15 23:01:23 +02:00
try :
2021-01-21 14:00:58 +02:00
import time
2021-01-15 23:01:23 +02:00
from main import mainMenu
clear ( )
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Демон) " )
2021-01-15 23:01:23 +02:00
import webbrowser
2021-01-22 14:53:33 +02:00
if ( getConfig ( " obs_core " ) or getConfig ( " obs_exe " ) ) == None :
2021-01-21 14:00:58 +02:00
clear ( )
2021-01-22 14:53:33 +02:00
while True :
obs_choice = input ( f ' { RESET } Хотите использовать запись через OBS? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ): ' )
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 )
2021-04-06 01:32:55 +03:00
json_file . close ( )
2021-01-22 14:53:33 +02:00
while True :
try :
filename = easygui . fileopenbox ( ' Выберите путь до obs32.exe или obs64.exe ' )
if filename . find ( " obs64.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 9 ]
saveJson ( files_folder + ' config.json ' , config_list )
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 9 ] } { RESET } ' )
time . sleep ( 3 )
break
elif filename . find ( " obs32.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 9 ]
saveJson ( files_folder + ' config.json ' , config_list )
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 9 ] } { RESET } ' )
time . sleep ( 3 )
break
elif filename . find ( " obs.exe " ) != - 1 :
config_list [ " obs_exe " ] = filename
config_list [ " obs_core " ] = filename [ : - 7 ]
saveJson ( files_folder + ' config.json ' , config_list )
print ( f ' Сохранены пути для OBS: \n Приложение: { BRED } { filename } { RESET } \n Корневая папка: { BRED } { filename [ : - 7 ] } { RESET } ' )
time . sleep ( 3 )
break
else :
easygui . msgbox ( " Неверный путь " )
continue
2021-01-15 23:01:23 +02:00
break
2021-01-22 14:53:33 +02:00
except :
none = input ( ' Вы не выбрали верный путь для OBS. \n \n > ' )
config_list [ " obs_exe " ] = ' Disabled '
config_list [ " obs_core " ] = ' Disabled '
saveJson ( files_folder + ' config.json ' , config_list )
clear ( )
2021-01-15 23:01:23 +02:00
break
2021-01-22 14:53:33 +02:00
break
elif obs_choice . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
2021-04-06 01:32:55 +03:00
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 ( )
2021-01-22 14:53:33 +02:00
clear ( )
break
else :
clear ( )
continue
2021-01-15 23:01:23 +02:00
if not os . path . exists ( files_folder + ' telegram.conf ' ) :
2021-01-21 14:00:58 +02:00
clear ( )
2021-01-22 14:53:33 +02:00
tg_choice = input ( f ' { RESET } Хотите использовать Telegram бота? { RESET } ( { BGREEN } Да { RESET } / { BRED } Нет { RESET } ): ' )
if tg_choice . lower ( ) in [ ' y ' , ' yes ' , ' д ' , ' да ' ] :
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
print ( f ' Пожалуйста, прочтите инструкцию по установке Telegram бота в { BRED } README.txt { RESET } ' )
print ( f ' или в документации/инструкции что в разделе { CYAN } Помощь { RESET } главного меню ' )
print ( f ' чтобы хорошо понимать что сейчас от вас нужно. ' )
none = input ( ' \n > ' )
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
while True :
clear ( )
try :
telegram_send . configure ( files_folder + ' telegram.conf ' , channel = False , group = False , fm_integration = False )
break
except :
clear ( )
continue
telegram_send . send ( messages = [ f " 🎊 Конфигурация правильна, всё работает! " ] , parse_mode = " markdown " , conf = f " { files_folder } telegram.conf " )
clear ( )
2021-01-22 14:53:33 +02:00
elif tg_choice . lower ( ) in [ ' n ' , ' no ' , ' н ' , ' нет ' ] :
2021-01-21 14:00:58 +02:00
with open ( files_folder + ' telegram.conf ' , ' w ' , encoding = " utf-8 " ) as f :
f . write ( ' Not Configured ' )
2021-04-06 01:32:55 +03:00
f . close ( )
2021-01-15 23:01:23 +02:00
lessons_count = 0
try :
if getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Конфигурация импортирована \n ' )
2021-01-15 23:01:23 +02:00
except :
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Конфигурация { BRED } отсутсвует { RESET } , выключаем отладку \n ' )
2021-01-15 23:01:23 +02:00
for les in getLessons ( ) :
2021-01-21 14:00:58 +02:00
try :
lessons_list = getLessons ( )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
lesson_name = les [ " name " ]
lesson_date = les [ " date " ]
lesson_time = les [ " time " ]
lesson_url = les [ " link " ]
lesson_obs = les [ " record " ]
lesson_repeat = les [ " repeat " ]
try :
lesson_repeat_day = les [ " repeat_day " ]
except :
lesson_repeat_day = ' Н е повторяется'
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
today = date . today ( ) . strftime ( " %d . % m. % Y " )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if ( today == lesson_date ) or ( getDayNum ( today ) == lesson_repeat_day ) :
print ( f ' { BBLACK } ================================================ { RESET } \n ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Найден урок { CYAN } { lesson_name } { RESET } в { BRED } { lesson_time } { RESET } . Ждём начала... ' )
waiting_time_unix = int ( time . time ( ) )
rpc . waitLesson ( lesson_name , waiting_time_unix )
waitStart ( lesson_time , lambda : act ( 100 ) )
2021-04-07 23:57:02 +03:00
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 } не удалось ни напрямую, ни в браузере. ' )
2021-01-21 14:00:58 +02:00
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 )
2021-04-07 23:57:02 +03:00
retries = 0
2021-01-21 14:00:58 +02:00
while not getState ( ) :
2021-01-15 23:01:23 +02:00
if getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Урок задерживается, ждём... ' )
time . sleep ( 5 )
2021-04-07 23:57:02 +03:00
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 } " )
2021-01-21 14:00:58 +02:00
continue
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
record_now = False
lesson_duration = 0
firstshow = True
if lesson_obs :
try :
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Импортированы клавиши старта и остановки записи ( { YELLOW } { getConfig ( " start " ) } { RESET } и { YELLOW } { getConfig ( " stop " ) } { RESET } ). ' )
start = getConfig ( " start " )
stop = getConfig ( " stop " )
except :
start = ' shift+f7 '
stop = ' shift+f8 '
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Используем стандартные клавиши старта и остановки записи ( { YELLOW } { start } { RESET } и { YELLOW } { stop } { RESET } ). ' )
i = 0
while True :
while i < 3 :
if getState ( ) :
if firstshow :
start_time_unix = int ( time . time ( ) )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Захвачен текущий урок в Zoom. ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
playSound ( " started " )
2021-04-06 01:32:55 +03:00
tgsend ( getConfig ( " telegram_enabled " ) , f " ▶ Зашёл на урок * { lesson_name } * в * { nowtime ( False , False , False ) } * { profilename } " )
2021-01-21 14:00:58 +02:00
rpc . onLesson ( lesson_name , start_time_unix )
if lesson_obs :
try :
2021-01-22 14:53:33 +02:00
obs_process = subprocess . Popen ( getConfig ( " obs_exe " ) , cwd = getConfig ( " obs_core " ) )
2021-01-21 14:00:58 +02:00
time . sleep ( 5 )
except :
print ( f ' { nowtime ( ) } Н е удалось открыть OBS для записи. ' )
else :
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Н е включаем OBS для записи. ' )
firstshow = False
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if lesson_obs :
if not record_now :
keyboard . press ( start )
time . sleep ( .25 )
keyboard . release ( start )
record_now = True
print ( f ' { nowtime ( ) } Сигнал записи OBS отправлен. ' )
playSound ( " recordstart " )
lesson_duration = lesson_duration + 5
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Zoom подключён. Урок идёт уже { BGREEN } { str ( lesson_duration ) } сек { RESET } . ( { BGREEN } { str ( round ( lesson_duration / 60 , 2 ) ) } мин { RESET } .) ' )
time . sleep ( 5 )
continue
else :
i + = 1
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } { BRED } Урок не обнаружен! { RESET } Повторная проверка через { BRED } 10 { RESET } секунд... ' )
time . sleep ( 10 )
continue
2021-01-15 23:01:23 +02:00
if getConfig ( " debug " ) :
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Zoom отключился. Процесс { BRED } CptHost.exe { RESET } более не существует. ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
tgsend ( getConfig ( " telegram_enabled " ) , f " ◀ Урок * { lesson_name } * длился * { str ( round ( lesson_duration / 60 , 2 ) ) } * мин. " )
print ( f ' { nowtime ( ) } Урок длился { BGREEN } { str ( lesson_duration ) } сек { RESET } . ( { BGREEN } { str ( round ( lesson_duration / 60 , 2 ) ) } мин { RESET } .) ' )
else :
tgsend ( getConfig ( " telegram_enabled " ) , f " ◀ Урок * { lesson_name } * длился * { str ( int ( lesson_duration / 60 ) ) } * мин. " )
print ( f ' { nowtime ( ) } Урок длился { BGREEN } { str ( lesson_duration ) } сек { RESET } . ( { BGREEN } { str ( int ( lesson_duration / 60 ) ) } мин { RESET } .) ' )
playSound ( " ended " )
2021-01-15 23:01:23 +02:00
if lesson_obs :
keyboard . press ( stop )
time . sleep ( .25 )
keyboard . release ( stop )
print ( f ' { nowtime ( ) } Сигнал остановки записи через OBS отправлен. ' )
2021-01-21 14:00:58 +02:00
playSound ( " recordstop " )
2021-01-15 23:01:23 +02:00
record_now = False
time . sleep ( 3 )
try :
obs_process . terminate ( )
except :
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Н е удалось остановить процесс OBS. ' )
if not lesson_repeat :
2021-01-21 14:00:58 +02:00
del lessons_list [ lessons_list . index ( les ) ]
2021-01-15 23:01:23 +02:00
saveJson ( files_folder + ' lessons.json ' , lessons_list )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Урок { CYAN } { lesson_name } { RESET } в { BRED } { lesson_time } { RESET } удалён. ' )
2021-01-15 23:01:23 +02:00
2021-01-21 14:00:58 +02:00
print ( f ' \n { BBLACK } ================================================ { RESET } \n \n ' )
2021-01-15 23:01:23 +02:00
firstshow = True
lessons_count = lessons_count + 1
break
2021-01-21 14:00:58 +02:00
record_now = False
lessons_list = getLessons ( )
except KeyboardInterrupt :
if getConfig ( " debug " ) :
print ( f ' { nowtime ( ) } Ожидание урока сброшено. ' )
else :
print ( ' ' )
time . sleep ( 1 )
pass
2021-01-15 23:01:23 +02:00
time . sleep ( 3 )
print ( f ' { nowtime ( ) } Уроков нет или же все в списке закончились. ' )
if lessons_count > 0 :
if getConfig ( " shutdown_enabled " ) :
2021-01-21 14:00:58 +02:00
if getConfig ( " end_mode " ) == ' shutdown ' :
try :
2021-04-07 23:57:02 +03:00
tgsend ( getConfig ( " telegram_enabled " ) , f " ⚠ Уроки кончились, автовыключение { profilename } через { str ( getConfig ( ' shutdown_timeout ' ) ) } мин... " )
2021-01-21 14:00:58 +02:00
print ( f ' { nowtime ( ) } Ваш ПК автоматически выключится через { BRED } { str ( getConfig ( " shutdown_timeout " ) ) } мин { RESET } . ' )
playSound ( " shutdown " )
end_unix = int ( time . time ( ) ) + getConfig ( " shutdown_timeout " ) * 60
rpc . shutdown ( end_unix )
shutdown = inputimeout ( prompt = f ' { nowtime ( ) } Нажмите { CYAN } Enter { RESET } чтобы предотвратить выключение ПК... ' , timeout = getConfig ( " shutdown_timeout " ) * 60 )
clear ( )
except TimeoutOccurred :
clear ( )
print ( f ' { nowtime ( ) } Время вышло, выключаем ваш ПК... ' )
time . sleep ( 3 )
tgsend ( getConfig ( " telegram_enabled " ) , f " ⚠ Время таймаута исткело, выключаем ваш ПК... " )
time . sleep ( 5 )
os . system ( " shutdown /s /t 1 " )
# elif getConfig("end_mode") == 'restart':
# from datetime import datetime, time
# from time import sleep
# runTime = "00:00"
# startTime = time(*(map(int, runTime.split(':'))))
# tomorrow = date.today()+timedelta(days=1)
# timestamp = (tomorrow - date(1970, 1, 1)).total_seconds()
# while startTime.total_seconds() > timestamp: #(date.today() + timedelta(days=1)).time():
# sleep(2)
2021-01-15 23:01:23 +02:00
if source == ' deamon ' :
2021-01-21 14:00:58 +02:00
exit = input ( f ' { nowtime ( ) } Программа завершена! Нажмите { CYAN } Enter { RESET } чтобы выйти... ' )
rpc . disconnect ( )
2021-01-15 23:01:23 +02:00
clear ( )
sys . exit ( )
elif source == ' menu ' :
2021-01-21 14:00:58 +02:00
exit = input ( f ' { nowtime ( ) } Программа завершена! Нажмите { CYAN } Enter { RESET } чтобы вернуться в меню... ' )
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Главная) " )
2021-01-15 23:01:23 +02:00
return
except KeyboardInterrupt :
if source == ' deamon ' :
2021-01-21 14:00:58 +02:00
exit = input ( f ' { nowtime ( ) } Программа остановлена! Нажмите { CYAN } Enter { RESET } чтобы выйти... ' )
rpc . disconnect ( )
2021-01-15 23:01:23 +02:00
clear ( )
sys . exit ( )
elif source == ' menu ' :
2021-01-21 14:00:58 +02:00
exit = input ( f ' { nowtime ( ) } Программа остановлена! Нажмите { CYAN } Enter { RESET } чтобы вернуться в меню... ' )
rpc . inMenu ( )
2021-01-15 23:01:23 +02:00
clear ( )
return
if __name__ == ' __main__ ' :
2021-01-21 14:00:58 +02:00
os . system ( " title AutoZoom (Демон) " )
2021-01-15 23:01:23 +02:00
import sys
clear ( )
2021-04-07 23:57:02 +03:00
main ( )