Coder Social home page Coder Social logo

vksdk's Introduction

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.131.

  • 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/v2@latest

Use by

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 := "<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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.