mirror of
https://github.com/42wim/matterbridge.git
synced 2024-12-21 02:22:34 +01:00
a0bca42a7a
* Update vendored libs * Fix slack api changes |
||
---|---|---|
.. | ||
api | ||
events | ||
internal | ||
longpoll-bot | ||
object | ||
.gitignore | ||
.golangci.yml | ||
.markdownlint.yml | ||
.travis.yml | ||
CONTRIBUTING.md | ||
doc.go | ||
go.mod | ||
go.sum | ||
LICENSE | ||
README.md |
VK SDK for Golang
VK SDK for Golang ready implementation of the main VK API functions for Go.
Features
Version API 5.126.
- API
- 400+ methods
- Ability to change the request handler
- Ability to modify HTTP client
- Request Limiter
- Token pool
- Callback
API
- Tracking tool for users activity in your VK communities
- Supports all events
- Auto setting callback
- Bots
Long Poll API
- Allows you to work with community events in real time
- Supports all events
- Ability to modify HTTP client
- User
Long Poll API
- Allows you to work with user events in real time
- Ability to modify HTTP client
- Streaming
API
- Receiving public data from VK by specified keywords
- Ability to modify HTTP client
- FOAF
- Machine-readable ontology describing persons
- Works with users and groups
- The only place to get page creation date
- VK Mini
Apps
- Checking launch parameters
- Intermediate http handler
- Payments
API
- Processes payment notifications
- Marusia
Skills
- For creating Marusia Skills
Install
# go mod init mymodulename
go get github.com/SevereCloud/vksdk/v2@latest
Use by
- Joe adapter: https://github.com/tdakkota/joe-vk-adapter
- Logrus hook: https://github.com/SevereCloud/vkrus
Example
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>" // use os.Getenv("TOKEN")
token := api.NewVK(token)
vk
// get information about the group
, err := vk.GroupsGetByID(nil)
groupif err != nil {
.Fatal(err)
log}
// Initializing Long Poll
, err := longpoll.NewLongPoll(vk, group[0].ID)
lpif err != nil {
.Fatal(err)
log}
// New message event
.MessageNew(func(_ context.Context, obj events.MessageNewObject) {
lp.Printf("%d: %s", obj.Message.PeerID, obj.Message.Text)
log
if obj.Message.Text == "ping" {
:= params.NewMessagesSendBuilder()
b .Message("pong")
b.RandomID(0)
b.PeerID(obj.Message.PeerID)
b
, err := vk.MessagesSend(b.Params)
_if err != nil {
.Fatal(err)
log}
}
})
// Run Bots Long Poll
.Println("Start Long Poll")
logif err := lp.Run(); err != nil {
.Fatal(err)
log}
}