-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.go
More file actions
84 lines (65 loc) · 1.73 KB
/
interface.go
File metadata and controls
84 lines (65 loc) · 1.73 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package bisonbotkit
import (
"context"
"sync"
"github.com/companyzero/bisonrelay/clientrpc/jsonrpc"
"github.com/companyzero/bisonrelay/clientrpc/types"
"github.com/decred/slog"
"github.com/vctt94/bisonbotkit/config"
"github.com/vctt94/bisonbotkit/logging"
)
// Bot represents a BisonRelay bot instance with configuration, RPC clients,
// and service interfaces for chat and payments.
type Bot struct {
// Cfg holds the bot's configuration settings
cfg *config.BotConfig
LogBackend *logging.LogBackend
wsc *jsonrpc.WSClient
ctx context.Context
cancelCtx context.CancelFunc
wl map[string]int64
wlFile string
wlMtx sync.Mutex
gcLog slog.Logger
gcChan chan<- *types.GCReceivedMsg
inviteChan chan<- *types.ReceivedGCInvite
pmLog slog.Logger
pmChan chan<- *types.ReceivedPM
postLog slog.Logger
postChan chan<- *types.ReceivedPost
postStatusLog slog.Logger
postStatusChan chan<- *types.ReceivedPostStatus
tipProgressLog slog.Logger
tipProgressChan chan<- *types.TipProgressEvent
tipReceivedLog slog.Logger
tipReceivedChan chan<- *types.ReceivedTip
kxLog slog.Logger
kxChan chan<- *types.KXCompleted
chatService types.ChatServiceClient
gcService types.GCServiceClient
paymentService types.PaymentsServiceClient
postService types.PostsServiceClient
}
type GCs []*types.ListGCsResponse_GCInfo
func (g GCs) Len() int {
return len(g)
}
func (g GCs) Less(a, b int) bool {
// Most members first
return g[a].NbMembers > g[b].NbMembers
}
func (g GCs) Swap(a, b int) {
g[a], g[b] = g[b], g[a]
}
func (b *Bot) Close() error {
if b.cancelCtx != nil {
b.cancelCtx()
}
if b.LogBackend != nil {
err := b.LogBackend.Close()
if err != nil {
return err
}
}
return b.wsc.Close()
}