GitXplorerGitXplorer
S

vksdk

public
196 stars
36 forks
26 issues

Commits

List of commits on branch master.
Verified
b01a28d34668975a34a08e4f4d6063ad260ad764

feat: update golang to 1.22 (#305)

SSevereCloud committed 6 days ago
Unverified
5dabb672b26d25f5e3fe5b1162879a05f084b508

docs: 3.0.1 version

SSevereCloud committed 7 days ago
Unverified
0314622fe28ccef70ed6f591c21b475b1ef302c8

fix(callback): check Fprint error

SSevereCloud committed 7 days ago
Unverified
59cb208ce9209e7b9aa832873e7094e3d02dce6e

fix: rename max & min size var

SSevereCloud committed 7 days ago
Unverified
7b2be6b4a5f0fb85a9fbff7a4625d4fb52236f65

chore(deps): go mod update

SSevereCloud committed 7 days ago
Unverified
1728fe854b5d07f25a498a7acb29b2930ab5bef2

test(api): StreamingError ErrMethod

SSevereCloud committed 7 days ago

README

The README file for this repository.

VK SDK for Golang

PkgGoDev VK Developers codecov VK chat release license

VK SDK for Golang ready implementation of the main VK API functions for Go.

Russian documentation

Features

Version API 5.199.

  • API
    • 500+ methods
    • Ability to modify HTTP client
    • Request Limiter
    • Support zstd and MessagePack
    • Token pool
    • OAuth
  • 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
  • Games
    • Checking launch parameters
    • Intermediate http handler
  • VK Mini Apps
    • Checking launch parameters
    • Intermediate http handler
  • Payments API
    • Processes payment notifications
  • Marusia Skills
    • For creating Marusia Skills
    • Support SSML

Install

# go mod init mymodulename
go get github.com/SevereCloud/vksdk/v3@latest

Use by

Example

package main

import (
	"context"
	"log"

	"github.com/SevereCloud/vksdk/v3/api"
	"github.com/SevereCloud/vksdk/v3/api/params"
	"github.com/SevereCloud/vksdk/v3/events"
	"github.com/SevereCloud/vksdk/v3/longpoll-bot"
)

func main() {
	token := "<TOKEN>" // use os.Getenv("TOKEN")
	vk := api.NewVK(token)

	// get information about the group
	group, err := vk.GroupsGetByID(nil)
	if err != nil {
		log.Fatal(err)
	}

	// Initializing Long Poll
	lp, err := longpoll.NewLongPoll(vk, group[0].ID)
	if err != nil {
		log.Fatal(err)
	}

	// New message event
	lp.MessageNew(func(_ context.Context, obj events.MessageNewObject) {
		log.Printf("%d: %s", obj.Message.PeerID, obj.Message.Text)

		if obj.Message.Text == "ping" {
			b := params.NewMessagesSendBuilder()
			b.Message("pong")
			b.RandomID(0)
			b.PeerID(obj.Message.PeerID)

			_, err := vk.MessagesSend(b.Params)
			if err != nil {
				log.Fatal(err)
			}
		}
	})

	// Run Bots Long Poll
	log.Println("Start Long Poll")
	if err := lp.Run(); err != nil {
		log.Fatal(err)
	}
}

LICENSE

FOSSA Status