2021-01-21 14:00:58 +02:00
# -*- coding: utf-8 -*-
import time
import os
import sys
2021-04-06 01:32:55 +03:00
from colors import *
2021-01-21 14:00:58 +02:00
from functions import *
2021-04-24 03:08:43 +03:00
version = ' 2.0 '
2021-01-21 14:00:58 +02:00
import libinstaller
from pypresence import Presence
client_id = ' 800049969960058882 '
RPC = Presence ( client_id , pipe = 0 )
connected = False
if getConfig ( " use_rpc " ) :
try :
RPC . connect ( )
connected = True
except :
pass
else :
connected = False
def disconnect ( ) :
2021-04-07 23:57:02 +03:00
global connected
2021-01-21 14:00:58 +02:00
if getConfig ( " use_rpc " ) :
try :
RPC . close ( )
connected = False
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC disconnected ' )
2021-01-21 14:00:58 +02:00
except :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to disconnect ' )
2021-01-21 14:00:58 +02:00
def connect ( ) :
2021-04-07 23:57:02 +03:00
global connected
2021-01-21 14:00:58 +02:00
try :
RPC . connect ( )
connected = True
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC connected ' )
2021-01-21 14:00:58 +02:00
except :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to connect ' )
2021-01-21 14:00:58 +02:00
def reset ( ) :
if getConfig ( " use_rpc " ) :
RPC . clear ( )
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC status cleared ' )
2021-01-21 14:00:58 +02:00
def waitLesson ( lesson , start ) :
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
2021-04-24 03:08:43 +03:00
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_waiting ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Ожидание ' , state = f ' Ждём начала « { lesson } » ' , details = ' Конференция не началась ' , start = start )
appendLog ( f ' Discord RPC changed to waitLesson (Lesson: { lesson } , Start: { start } ) ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
except AssertionError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
def onLesson ( lesson , start ) :
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
2021-04-24 03:08:43 +03:00
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_lesson ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Конференция ' , state = f ' Слушаем « { lesson } » ' , details = ' Идёт конференция ' , start = start )
appendLog ( f ' Discord RPC changed to onLesson (Lesson: { lesson } , Start: { start } ) ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
except AssertionError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
2021-04-06 01:32:55 +03:00
def inMenu ( ) :
2021-01-21 14:00:58 +02:00
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_menu ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Главное меню ' , state = ' Открыт список опций ' , details = ' В главном меню' )
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC changed to inMenu ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
except AssertionError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
def shutdown ( end ) :
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_shutdown ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Выключение ' , state = ' Отсчёт до авто-выключения ' , details = ' Выключение ПК ' , end = end )
2021-04-24 03:08:43 +03:00
appendLog ( f ' Discord RPC changed to shutdown (End: { end } ) ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
except AssertionError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
def inSettings ( ) :
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_settings ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Настройки ' , state = ' Открыты настройки ' , details = ' В главном меню' )
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC changed to inSettings ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
except AssertionError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
def inEditor ( ) :
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_editing ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Редактор ' , state = ' Открыт редактор ' , details = ' В главном меню' )
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC changed to inEditor ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
except AssertionError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
def inUpdater ( ) :
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_updating ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Обновление ' , state = ' Открыт центр обновлений ' , details = ' В главном меню' )
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC changed to inUpdater ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
except AssertionError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
def inHelp ( ) :
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_support ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Помощь ' , state = ' Открыта помощь ' , details = ' В главном меню' )
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC changed to inHelp ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
except AssertionError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
2021-04-24 03:08:43 +03:00
def lessonEnded ( ) :
try :
if getConfig ( " use_rpc " ) :
if connected == False :
connect ( )
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_waiting ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Ожидание ' , state = f ' Ждём указаний ' , details = ' В с е конференции закончились' )
appendLog ( ' Discord RPC changed to lessonEnded ' )
except AttributeError :
appendLog ( ' Discord RPC failed to change status ' )
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
time . sleep ( 1 )
except AssertionError :
appendLog ( ' Discord RPC failed to change status ' )
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
time . sleep ( 1 )
2021-01-21 14:00:58 +02:00
if __name__ == " __main__ " :
try :
RPC . connect ( )
RPC . update ( large_image = ' 1024_cover ' , small_image = ' status_settings ' , large_text = f ' AutoZoom • v { version } \n http://bit.ly/auto_zoom ' , small_text = ' Отладка ' , state = ' Модуль Discord RPC запущен в режиме тестирования ' , details = ' Режим отладки ' )
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC changed to debug ' )
2021-01-21 14:00:58 +02:00
except AttributeError :
2021-04-24 03:08:43 +03:00
appendLog ( ' Discord RPC failed to change status ' )
2021-01-21 14:00:58 +02:00
if getConfig ( " debug " ) :
print ( f ' { RESET } Модуль { BRED } Discord RPC { RESET } не смог подключиться. \n Возможно, ваш { CYAN } Discord { RESET } не открыт. ' )
2021-04-07 23:57:02 +03:00
time . sleep ( 1 )