summaryrefslogtreecommitdiffstats
path: root/bridge/vk/vk.go
diff options
context:
space:
mode:
authorDaniil Suvorov <severecloud@gmail.com>2022-01-10 00:50:07 +0300
committerGitHub <noreply@github.com>2022-01-09 22:50:07 +0100
commit16ab4c6fed397306030318a6a0900e208ff784e3 (patch)
tree60dd2aa67fe3d179eac43770797716533bce1e22 /bridge/vk/vk.go
parente3ee0df7ba9a66fb9082b7982bc9179ced962846 (diff)
downloadmatterbridge-msglm-16ab4c6fed397306030318a6a0900e208ff784e3.tar.gz
matterbridge-msglm-16ab4c6fed397306030318a6a0900e208ff784e3.tar.bz2
matterbridge-msglm-16ab4c6fed397306030318a6a0900e208ff784e3.zip
Remove GroupID (vk) (#1668)
Diffstat (limited to 'bridge/vk/vk.go')
-rw-r--r--bridge/vk/vk.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/bridge/vk/vk.go b/bridge/vk/vk.go
index 89a653cf..3e73b9a2 100644
--- a/bridge/vk/vk.go
+++ b/bridge/vk/vk.go
@@ -34,6 +34,7 @@ type user struct {
type Bvk struct {
c *api.VK
+ lp *longpoll.LongPoll
usernamesMap map[int]user // cache of user names and avatar URLs
*bridge.Config
}
@@ -45,21 +46,23 @@ func New(cfg *bridge.Config) bridge.Bridger {
func (b *Bvk) Connect() error {
b.Log.Info("Connecting")
b.c = api.NewVK(b.GetString("Token"))
- lp, err := longpoll.NewLongPoll(b.c, b.GetInt("GroupID"))
+
+ var err error
+ b.lp, err = longpoll.NewLongPollCommunity(b.c)
if err != nil {
b.Log.Debugf("%#v", err)
return err
}
- lp.MessageNew(func(ctx context.Context, obj events.MessageNewObject) {
+ b.lp.MessageNew(func(ctx context.Context, obj events.MessageNewObject) {
b.handleMessage(obj.Message, false)
})
b.Log.Info("Connection succeeded")
go func() {
- err := lp.Run()
+ err := b.lp.Run()
if err != nil {
b.Log.Fatal("Enable longpoll in group management")
}
@@ -69,6 +72,8 @@ func (b *Bvk) Connect() error {
}
func (b *Bvk) Disconnect() error {
+ b.lp.Shutdown()
+
return nil
}