Answer the question
In order to leave comments, you need to log in
Vk longpoll api where is the error?
I am writing a simple bot on SDK from "/SevereCloud/vksdk" , an error appears when responding to a message in a VK conversation, it says "api: You don't have access to this chat
exit status 1"
There are administrator rights in the conversation, event types are in the settings community "Messages" included.
Here is the code:
package main
import (
"context"
"log"
"github.com/SevereCloud/vksdk/v2/api"
"github.com/SevereCloud/vksdk/v2/api/params"
"github.com/SevereCloud/vksdk/v2/events"
"github.com/SevereCloud/vksdk/v2/longpoll-bot"
)
func main() {
token := "****"
vk := api.NewVK(token)
group, err := vk.GroupsGetByID(nil)
if err != nil {
log.Fatal(err)
}
lp, err := longpoll.NewLongPoll(vk, group[0].ID)
if err != nil {
log.Fatal(err)
}
lp.MessageNew(func(_ context.Context, obj events.MessageNewObject) {
log.Printf("%d: %s", obj.Message.PeerID, obj.Message.Text)
if obj.Message.Text == "test" {
b := params.NewMessagesSendBuilder()
b.Message("test 2")
b.RandomID(0)
b.PeerID(2000000266)
_, err := vk.MessagesSend(b.Params)
if err != nil {
log.Fatal(err)
}
}
})
log.Println("Start Long Poll")
if err := lp.Run(); err != nil {
log.Fatal(err)
}
}
You don't have access to this chat
exit status 1
Answer the question
In order to leave comments, you need to log in
Maybe it's the peer_id. Bots and pages are different. Try printing it to the console when you receive a new message and compare.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question