Skip to content

lanzay/go-vk-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-vk-api

GoDoc Go Report Card

Golang wrapper for VK API

Install

Install the package with:

go get github.com/urShadow/go-vk-api

Import it with:

import "github.com/urShadow/go-vk-api"

and use vk as the package name inside the code.

Example

package main

import (
	"github.com/urShadow/go-vk-api"
	"log"
	"strconv"
)

func main() {
	api := vk.New("ru")
	// set http proxy
	//api.Proxy = "localhost:8080"

	err := api.Init("TOKEN")

	if err != nil {
		log.Fatalln(err)
	}

	api.OnNewMessage(func(msg *vk.LPMessage) {
		if msg.Flags&vk.FlagMessageOutBox == 0 {
			if msg.Text == "/hello" {
				api.Messages.Send(vk.RequestParams{
					"peer_id":          strconv.FormatInt(msg.FromID, 10),
					"message":          "Hello!",
					"forward_messages": strconv.FormatInt(msg.ID, 10),
				})
			}
		}
	})

	api.RunLongPoll()
}

About

Golang wrapper for VK API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%