-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrpc.go
More file actions
49 lines (41 loc) · 818 Bytes
/
rpc.go
File metadata and controls
49 lines (41 loc) · 818 Bytes
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
44
45
46
47
48
49
package main
import (
"log"
"time"
"github.com/andlabs/ui"
"github.com/hugolgst/rich-go/client"
)
var RPCActive = false
func RPCStop() {
client.Logout()
RPCActive = false
GUIch <- "buttonStart"
log.Println("RPC stopped.")
}
func RPCStart() {
if err := client.Login(Config.AppID); err != nil {
log.Println(err)
RPCActive = false
GUIch <- "buttonStart"
ui.MsgBoxError(Win, "ERROR!", "Can not login to Discord RPC")
return
}
go func() {
for {
if !RPCActive {
break
}
if err := client.SetActivity(Config.RPC); err != nil {
log.Println(err)
RPCActive = false
GUIch <- "buttonStart"
ui.MsgBoxError(Win, "ERROR!", "Can not update RPC")
return
}
time.Sleep(time.Second * 12)
}
}()
RPCActive = true
GUIch <- "buttonStop"
log.Println("RPC started.")
}