-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrpc.go
More file actions
37 lines (32 loc) · 783 Bytes
/
rpc.go
File metadata and controls
37 lines (32 loc) · 783 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
package main
import (
"github.com/hugolgst/rich-go/client"
"github.com/hugolgst/rich-go/ipc"
log "github.com/sirupsen/logrus"
)
var loggedIn = false
func getRPCLogCtx() *log.Entry {
return log.WithFields(log.Fields{
"loggedIn": loggedIn,
})
}
func login() {
getRPCLogCtx().Traceln("Attempting to close IPC Socket")
err := ipc.CloseSocket()
if err != nil {
getRPCLogCtx().Debugln("IPC Socket Unable to close")
}
err = client.Login(discordAppId)
if err != nil {
getRPCLogCtx().Warnln("Could not login to Discord.")
logout()
} else {
loggedIn = true
getRPCLogCtx().Debugln("Successfully logged into Discord's RPC Server.")
}
}
func logout() {
client.Logout()
loggedIn = false
getRPCLogCtx().Debugln("Successfully logged out of Discord's RPC Server.")
}