vksdk

package module
v2.5.0-dev Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2020 License: MIT Imports: 0 Imported by: 8

README

VK SDK for Golang

Build Status 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

  • 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

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

Documentation

Overview

Package vksdk implements the basic VK API functions.

Source https://github.com/SevereCloud/vksdk

Index

Constants

View Source
const (
	Version = "2.5.0"
	API     = "5.124"
)

Module constants.

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
api
Package api implements VK API.
Package api implements VK API.
params
Package params for generating query parameters.
Package params for generating query parameters.
Package callback implements Callback API.
Package callback implements Callback API.
Package events for community events handling.
Package events for community events handling.
Package foaf wrapper for FOAF.
Package foaf wrapper for FOAF.
Package internal unimportable Package internal unimportable
Package internal unimportable Package internal unimportable
Package longpoll implements Bots Long Poll API.
Package longpoll implements Bots Long Poll API.
Package longpoll implements User Long Poll API.
Package longpoll implements User Long Poll API.
v3
Package wrapper implement User Long Poll API wrapper v3.
Package wrapper implement User Long Poll API wrapper v3.
Package marusia для создания скилла Маруси.
Package marusia для создания скилла Маруси.
Package object contains objects for VK.
Package object contains objects for VK.
Package payments implements Payments API.
Package payments implements Payments API.
Package streaming implements Streaming API.
Package streaming implements Streaming API.
Package vkapps for VK Mini Apps.
Package vkapps for VK Mini Apps.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL