File size: 929 Bytes
85d3b29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import sys
import base64
import pathlib
import tempfile
import gradio as gr
import threading
from assets.i18n.i18n import I18nAuto
from assets.discord_presence import RPCManager

now_dir = os.getcwd()
sys.path.append("..")

i18n = I18nAuto()


def presence_tab():
    with gr.Row():
        with gr.Column():
            presence = gr.Checkbox(
                label=i18n("Enable Applio integration with Discord presence"),
                interactive=True,
                value=True,
            )
            presence.change(
                fn=toggle,
                inputs=[presence],
                outputs=[],
            )


def toggle(checkbox):

    if bool(checkbox):
        # print("Start Presence")
        try:
            RPCManager.start_presence()
        except KeyboardInterrupt:
            RPCManager.stop_presence()
    else:
        # print("Stop presence")
        RPCManager.stop_presence()