-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessenger.go
54 lines (44 loc) · 1.01 KB
/
messenger.go
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
package muse
type Message struct {
Address string `json:"address"`
Content any `json:"content"`
}
func NewMessage(address string, content any) *Message {
return &Message{
Address: address,
Content: content,
}
}
type MessageReceiver interface {
ReceiveMessage(msg any) []*Message
}
type Messenger interface {
Control
MsgrNamed(string) Messenger
MsgrAddTo(Patch) Messenger
Messages(timestamp int64, config *Configuration) []*Message
}
type BaseMessenger struct {
*BaseControl
}
func NewBaseMessenger() *BaseMessenger {
return &BaseMessenger{
BaseControl: NewBaseControl(),
}
}
func (m *BaseMessenger) ReceiveMessage(msg any) []*Message {
// STUB
return nil
}
func (m *BaseMessenger) Messages(timestamp int64, config *Configuration) []*Message {
// STUB
return nil
}
func (m *BaseMessenger) MsgrNamed(name string) Messenger {
self := m.Self().(Messenger)
self.SetIdentifier(name)
return self
}
func (m *BaseMessenger) MsgrAddTo(p Patch) Messenger {
return p.AddMessenger(m.Self().(Messenger))
}