-
Notifications
You must be signed in to change notification settings - Fork 174
/
provider.go
50 lines (43 loc) · 1.12 KB
/
provider.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
package message
import (
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/message/appChat"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/message/externalContact"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/message/linkedCorp"
"reflect"
)
func RegisterProvider(app kernel.ApplicationInterface) (*Client, *Messager,
*appChat.Client,
*externalContact.Client,
*linkedCorp.Client,
error,
) {
config := app.GetConfig()
client, err := NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, err
}
AppChat, err := appChat.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, err
}
ExternalContact, err := externalContact.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, err
}
LinkedCorp, err := linkedCorp.NewClient(app)
if err != nil {
return nil, nil, nil, nil, nil, err
}
messager := NewMessager(client)
agentID := config.Get("agent_id", nil)
switch reflect.TypeOf(agentID).Kind() {
case reflect.Int:
messager.OfAgent(agentID.(int))
}
return client, messager,
AppChat,
ExternalContact,
LinkedCorp,
nil
}