repositorypackage
0.0.0-20190204162326-81f90eb179b2
Repository: https://github.com/gdvfox/vkbot-go.git
Documentation: pkg.go.dev
# README
VkBot-Go
This package provides you bindings for the VK API
Install & Import
Install
go get -u github.com/GDVFox/vkbot-go
Import
import "github.com/GDVFox/vkbot-go"
Example
Simple request to VK API
Bot gets information about user id304508916
package main
import (
"log"
"net/http"
"net/url"
vkAPI "github.com/GDVFox/vkbot-go"
)
func main() {
bot, _ := vkAPI.NewVkBot("AccessToken", "5.92", &http.Client{})
resp, err := bot.Request("users.get", url.Values{
"user_ids": []string{"304508916"},
"fields": []string{"status"},
})
if err != nil {
log.Panic(err)
}
log.Println(string(resp.Response))
}
Simple use of Callback API
Bot gets events of group id1337
package main
import (
"log"
"net/http"
vkAPI "github.com/GDVFox/vkbot-go"
)
func main() {
bot, _ := vkAPI.NewVkBot("AccessToken", "5.92", &http.Client{})
bot.SetConfirmation(vkAPI.NewConfirmation("/", 1337, "ConfirmString"))
events := bot.ListenForEvents()
go http.ListenAndServe(":8080", nil)
log.Println("start listen :8080")
for event := range events {
log.Printf("[%s] %s from group: %d", event.Type, string(event.Object), event.GroupID)
}
}