govkbot

package module
v0.0.0-...-d91b898 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2019 License: MIT Imports: 13 Imported by: 2

README

Go VK bot package

Build Status codecov Go Report Card godoc

This is simple VK.com bot API.

At 2019-03-01 VK was restrict messages.send for user_tokens. This bot can work with group_token, and access to chat members if has admin rights in chat. You can use v1.0.1 also, if you need only user_token access.

It can:

  • Reply to messages (private and chat)
  • Send greetings message when invited to chat
  • Add and remove mutual friends
  • Send notifies to admin

Installatioin:

go get github.com/nikepan/govkbot

For work you need get VK access token with rights: messages,friends,offline (see below).

Quickstart

package main
import "github.com/nikepan/govkbot"
import "log"

var VKAdminID = 3759927
var VKToken = "efjr98j9fj8jf4j958jj4985jfj9joijerf0fj548jf94jfiroefije495jf48"

func helpHandler(m *govkbot.Message) (reply string) {
  return "help received"
}

func startHandler(m *govkbot.Message) (reply govkbot.Reply) {
	keyboard := govkbot.Keyboard{Buttons: make([][]govkbot.Button, 0)}
	button := govkbot.NewButton("/help", nil)
	row := make([]govkbot.Button, 0)
	row = append(row, button)
	keyboard.Buttons = append(keyboard.Buttons, row)

	return govkbot.Reply{Msg: availableCommands, Keyboard: &keyboard}
}

func errorHandler(m *govkbot.Message, err error) {
  log.Fatal(err.Error())
}

func main() {
    //govkbot.HandleMessage("/", anyHandler)
    //govkbot.HandleMessage("/me", meHandler)
    govkbot.HandleMessage("/help", helpHandler)
    govkbot.HandleAdvancedMessage("/start", startHandler)

    //govkbot.HandleAction("chat_invite_user", inviteHandler)
    //govkbot.HandleAction("chat_kick_user", kickHandler)
    //govkbot.HandleAction("friend_add", addFriendHandler)
    //govkbot.HandleAction("friend_delete", deleteFriendHandler)

    govkbot.HandleError(errorHandler)

    govkbot.SetAutoFriend(true) // enable auto accept/delete friends

    govkbot.SetDebug(true) // log debug messages

    // Optional Direct VK API access
    govkbot.SetAPI(VKToken, "", "") // Need only before Listen, if you use direct API
    me, _ := govkbot.API.Me() // call API method
    log.Printf("current user: %+v\n", me.FullName())
    // Optional end

    govkbot.Listen(VKToken, "", "", VKAdminID)
}

Getting group token

Open group manage and select "Work with API"

Getting user token (most likely will not work for messages)

You need standalone vk app_id. You can use any app_id from https://vk.com/apps?act=wingames, for example 4775211 (Or you can create own app and get app_id on page https://vk.com/editapp?act=create (standalone app))

You can get token from you server ip with this node.js package: https://www.npmjs.com/package/vk-auth (you need login, pass and app_id)

To manual get token you need:

  1. Open in browser with logged in VK (you must use IP, where you want run bot)
 https://oauth.vk.com/authorize?client_id={{app_id}}&scope=offline,groups,messages,friends&display=page&response_type=token&redirect_uri=https://oauth.vk.com/blank.html
  1. Copy token query parameter from URL string. Token valid only for IP from what you get it.

If you receive validation check (for example, you use ip first time)

{"error":{"error_code":17,"error_msg":"Validation required: please open redirect_uri in browser ...", 
"redirect_uri":"https://m.vk.com/login?act=security_check&api_hash=Qwerty1234567890"}}

you can use https://github.com/Yashko/vk-validation-node.

Documentation

Overview

Package govkbot is a pure Go client library for https://vk.com messaging API.

It includes a API for receive and send messages, chats, users info and friending.

It works simply, but need to manually get user token.

This implementation don't use vk long pool API and proxies, and have limit 3 requests per second (VK API limit).

To get token you need:

1. You can use any app id from https://vk.com/apps?act=wingames, for example 4775211

(You can create own app and get app_id on page https://vk.com/editapp?act=create (standalone app))

2. Open in browser with logged in VK (you must use IP, where you want run bot)

https://oauth.vk.com/authorize?client_id={{app_id}}&scope=offline,group,messages,friends&display=page&response_type=token&redirect_uri=https://oauth.vk.com/blank.html

3. Copy token query parameter from URL string. Token valid only for IP from what you get it.

Index

Examples

Constants

View Source
const (
	LongPollModeGetAttachments    = 2
	LongPollModeGetExtendedEvents = 8
	LongPollModeGetPts            = 32
	LongPollModeGetExtraData      = 64
	LongPollModeGetRandomID       = 128
)
View Source
const ChatPrefix = 2000000000
View Source
const DefaultVersion = 2
View Source
const DefaultWait = 25

Variables

View Source
var API = newAPI()

API - bot API

View Source
var Bot = API.NewBot()

Functions

func HandleAction

func HandleAction(command string, handler func(*Message) string)

HandleAction - add action handler. Function must return string to reply or "" (if no reply)

func HandleAdvancedMessage

func HandleAdvancedMessage(command string, handler func(*Message) Reply)

HandleAdvancedMessage - add substr message handler. Function must return string to reply or "" (if no reply)

func HandleError

func HandleError(handler func(*Message, error))

HandleError - add error handler

func HandleMessage

func HandleMessage(command string, handler func(*Message) string)

HandleMessage - add substr message handler. Function must return string to reply or "" (if no reply)

func HasPrefix

func HasPrefix(s, prefix string) bool

HasPrefix tests case insensitive whether the string s begins with prefix.

func Listen

func Listen(token string, url string, ver string, adminID int) error

Listen - start server

Example
package main

import (
	"fmt"
	"github.com/nikepan/govkbot"
	"log"
)

func helpHandler(m *govkbot.Message) (reply string) {
	return "Available commands: /help, /me\nYou message" + m.Body
}

func errorHandler(msg *govkbot.Message, err error) {
	// Check gor VK Error code
	if _, ok := err.(*govkbot.VKError); !ok {
		log.Fatal(
			err.(govkbot.VKError).ErrorCode,
			err.Error(), msg.Body)
	}
	log.Fatal(err.Error(), msg.Body)
}

func addFriendHandler(m *govkbot.Message) (reply string) {
	log.Printf("friend %+v added\n", m.UserID)
	govkbot.NotifyAdmin(fmt.Sprintf("user vk.com/id%+v add me to friends", m.UserID))
	return reply
}

func main() {

	//govkbot.HandleMessage("/", anyHandler) // any commands starts with "/"
	//govkbot.HandleMessage("/me", meHandler)
	govkbot.HandleMessage("/help", helpHandler) // any commands starts with "/help"

	//govkbot.HandleAction("chat_invite_user", inviteHandler)
	//govkbot.HandleAction("chat_kick_user", kickHandler)
	govkbot.HandleAction("friend_add", addFriendHandler)
	//govkbot.HandleAction("friend_delete", deleteFriendHandler)

	govkbot.HandleError(errorHandler)

	govkbot.SetAutoFriend(true) // enable auto accept/delete friends

	govkbot.SetDebug(true) // log debug messages

	// Optional Direct VK API access
	govkbot.SetAPI("!!!!VK_TOKEN!!!!", "", "") // Need only before Listen, if you use direct API
	me, _ := govkbot.API.Me()                  // call API method
	log.Printf("current user: %+v\n", me.FullName())
	// Optional end

	govkbot.Listen("!!!!VK_TOKEN!!!!", "", "", 12345678) // start bot

}
Output:

func NotifyAdmin

func NotifyAdmin(msg string) error

NotifyAdmin - notify AdminID by VK

func SetAPI

func SetAPI(token string, url string, ver string)

SetAPI - setup API config

func SetAutoFriend

func SetAutoFriend(af bool)

SetAutoFriend - enables mutual auto friending

func SetDebug

func SetDebug(debug bool)

SetDebug - enable/disable debug messages logging

func SetLang

func SetLang(lang string)

SetLang - sets VK response language. Default auto. Available: en, ru, ua, be, es, fi, de, it

func SetToken

func SetToken(token string)

SetToken - set bot token

func TrimPrefix

func TrimPrefix(s, prefix string) string

TrimPrefix returns s without the provided leading case insensitive prefix string. If s doesn't start with prefix, s is returned unchanged.

Types

type Attachment

type Attachment struct {
	AttachType      string
	Attach          string
	Fwd             string
	From            int
	Geo             int
	GeoProvider     int
	Title           string
	AttachProductID int
	AttachPhoto     string
	AttachTitle     string
	AttachDesc      string
	AttachURL       string
	Emoji           bool
	FromAdmin       int
	SourceAct       string
	SourceMid       int
}

type Button

type Button struct {
	Action struct {
		Type    string `json:"type"`
		Payload string `json:"payload"`
		Label   string `json:"label"`
	} `json:"action"`
	Color string `json:"color"`
}

Button for keyboard, which sends to user

func NewButton

func NewButton(label string, payload interface{}) Button

type ChatInfo

type ChatInfo struct {
	ID      int    `json:"id"`
	Type    string `json:"type"`
	Title   string `json:"title"`
	Kicked  int    `json:"kicked"`
	AdminID int    `json:"admin_id"`
	Users   VKUsers
}

ChatInfo - chat info

type ChatInfoResponse

type ChatInfoResponse struct {
	Response ChatInfo
	Error    *VKError
}

ChatInfoResponse - chat info vk struct

type ConversationInfo

type ConversationInfo struct {
	Peer struct {
		ID      int
		Type    string
		LocalID int `json:"local_id"`
	}
	InRead        int `json:"in_read"`
	OutRead       int `json:"out_read"`
	LastMessageID int `json:"last_message_id"`
	CanWrite      struct {
		Allowed bool
	} `json:"can_write"`
	ChatSettings struct {
		Title        string
		MembersCount int `json:"members_count"`
		State        string
		ActiveIDs    []int `json:"active_ids"`
		ACL          struct {
			CanInvite           bool `json:"can_invite"`
			CanChangeInfo       bool `json:"can_change_info"`
			CanChangePin        bool `json:"can_change_pin"`
			CanPromoteUsers     bool `json:"can_promote_users"`
			CanSeeInviteLink    bool `json:"can_see_invite_link"`
			CanChangeInviteLink bool `json:"can_change_invite_link"`
		}
		IsGroupChannel bool `json:"is_group_channel"`
		OwnerID        int  `json:"owner_id"`
	} `json:"chat_settings"`
}

ConversationInfo - conversation info

type ConversationsResponse

type ConversationsResponse struct {
	Response struct {
		Items    []ConversationInfo
		Profiles []UserProfile
	}
	Error *VKError
}

ConversationsResponse - resonse of confersations info

type ErrorResponse

type ErrorResponse struct {
	Error *VKError
}

ErrorResponse - need to parse VK error

type FailResponse

type FailResponse struct {
	Failed     int
	Ts         int
	MinVersion int `json:"min_version"`
	MaxVersion int `json:"max_version"`
}

type FriendDeleteResponse

type FriendDeleteResponse struct {
	Response map[string]int
	Error    *VKError
}

FriendDeleteResponse - VK friend delete response

type FriendRequests

type FriendRequests struct {
	Count int
	Items []int
}

FriendRequests - VK friend requests

type FriendRequestsResponse

type FriendRequestsResponse struct {
	Response FriendRequests
	Error    *VKError
}

FriendRequestsResponse - VK friend requests response

type Geo

type Geo struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
}

Geo - City and Country info

type GroupFailResponse

type GroupFailResponse struct {
	Failed     int
	Ts         string
	MinVersion int `json:"min_version"`
	MaxVersion int `json:"max_version"`
}

type GroupLongPollEvent

type GroupLongPollEvent struct {
	Type    string
	GroupID int
}

type GroupLongPollMessage

type GroupLongPollMessage struct {
	Type   string
	Object struct {
		Date                  int                    `json:"date"`
		FromID                int                    `json:"from_id"`
		ID                    int                    `json:"id"`
		Out                   int                    `json:"out"`
		PeerID                int                    `json:"peer_id"`
		Text                  string                 `json:"text"`
		ConversationMessageID int                    `json:"conversation_message_id"`
		FwdMessages           []GroupLongPollMessage `json:"fwd_messages"`
		Important             bool                   `json:"important"`
		RandomID              int                    `json:"random_id"`
		//Attachments [] `json:"attachments"`
		IsHidden bool `json:"is_hidden"`
		Action   struct {
			Type     string
			MemberID int `json:"member_id"`
		}
	}
	GroupID int
}

type GroupLongPollResponse

type GroupLongPollResponse struct {
	Ts       string
	Messages []*Message
}

type GroupLongPollServer

type GroupLongPollServer struct {
	Key             string
	Server          string
	Ts              string
	Wait            int
	Mode            int
	Version         int
	RequestInterval int
	NeedPts         bool
	API             *VkAPI
	LpVersion       int
	ReadMessages    map[int]time.Time
}

LongPollServer - longpoll server structure

func NewGroupLongPollServer

func NewGroupLongPollServer(requestInterval int) (resp *GroupLongPollServer)

NewLongPollServer - get longpoll server

func (*GroupLongPollServer) FilterReadMesages

func (server *GroupLongPollServer) FilterReadMesages(messages []*Message) (result []*Message)

FilterReadMesages - filter read messages

func (*GroupLongPollServer) GetLongPollMessages

func (server *GroupLongPollServer) GetLongPollMessages() ([]*Message, error)

GetLongPollMessages - get messages via longpoll

func (*GroupLongPollServer) Init

func (server *GroupLongPollServer) Init() (err error)

Init - init longpoll server

func (*GroupLongPollServer) ParseLongPollMessages

func (server *GroupLongPollServer) ParseLongPollMessages(j string) (*GroupLongPollResponse, error)

ParseLongPollMessages - parse longpoll messages

func (*GroupLongPollServer) ParseMessage

func (server *GroupLongPollServer) ParseMessage(obj map[string]interface{}) Message

func (*GroupLongPollServer) Request

func (server *GroupLongPollServer) Request() ([]byte, error)

Request - make request to longpoll server

type GroupLongPollServerResponse

type GroupLongPollServerResponse struct {
	Response GroupLongPollServer
}

type GroupProfile

type GroupProfile struct {
	ID       int
	Name     string
	IsClosed int `json:"is_closed"`
	Type     string
	Photo50  string
	Photo100 string
	Photo200 string
}

GroupProfile - conversation group profile

type H

type H map[string]string

H - simple object struct

type Keyboard

type Keyboard struct {
	OneTime bool       `json:"one_time"`
	Buttons [][]Button `json:"buttons"`
}

Keyboard to send for user

type LongPollMessage

type LongPollMessage struct {
	MessageType int
	MessageID   int
	Flags       int
	PeerID      int64
	Timestamp   int64
	Text        string
	Attachments []Attachment
	RandomID    int
}

type LongPollResponse

type LongPollResponse struct {
	Ts       uint
	Messages []*Message
}

type LongPollServer

type LongPollServer interface {
	Init() (err error)
	Request() ([]byte, error)
	GetLongPollMessages() ([]*Message, error)
	FilterReadMesages(messages []*Message) (result []*Message)
}

type LongPollUpdate

type LongPollUpdate []interface{}

type LongPollUpdateNum

type LongPollUpdateNum []int64

type MemberItem

type MemberItem struct {
	MemberID  int  `json:"member_id"`
	JoinDate  int  `json:"join_date"`
	IsOwner   bool `json:"is_owner"`
	IsAdmin   bool `json:"is_admin"`
	InvitedBy int  `json:"invited_by"`
}

MemberItem - conversation item

type MembersResponse

type MembersResponse struct {
	Response VKMembers
	Error    *VKError
}

MembersResponse - VK user response

type Mention

type Mention struct {
	ID   int
	Name string
}

Mention - user mention in message

type Message

type Message struct {
	ID          int
	Date        int
	Out         int
	UserID      int   `json:"user_id"`
	ChatID      int   `json:"chat_id"`
	PeerID      int64 `json:"peer_id"`
	ReadState   int   `json:"read_state"`
	Title       string
	Body        string
	Action      string
	ActionMID   int `json:"action_mid"`
	Flags       int
	Timestamp   int64
	Payload     string
	FwdMessages []Message `json:"fwd_messages"`
}

Message - VK message struct

func GetLongPollMessage

func GetLongPollMessage(resp []interface{}) *Message

GetLongPollMessage - get message from longpoll json row

func (Message) GetMentions

func (m Message) GetMentions() []Mention

func (Message) MarkAsRead

func (m Message) MarkAsRead() (err error)

MarkAsRead - mark message as read

type Messages

type Messages struct {
	Count int
	Items []*Message
}

Messages - VK Messages

type MessagesResponse

type MessagesResponse struct {
	Response Messages
	Error    *VKError
}

MessagesResponse - VK messages response

type Reply

type Reply struct {
	Msg      string
	Keyboard *Keyboard
}

Reply for message

type ResponseError

type ResponseError struct {
	// contains filtered or unexported fields
}

VKError - error with response content

func (ResponseError) Content

func (err ResponseError) Content() string

Content - error content

func (ResponseError) Error

func (err ResponseError) Error() string

type SimpleResponse

type SimpleResponse struct {
	Response int
	Error    *VKError
}

SimpleResponse - simple int response

type User

type User struct {
	ID          int    `json:"id"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	ScreenName  string `json:"screen_name"`
	Photo       string `json:"photo"`
	InvitedBy   int    `json:"invited_by"`
	City        Geo    `json:"city"`
	Country     Geo    `json:"country"`
	Sex         int    `json:"sex"`
	BDate       string `json:"bdate"`
	Photo50     string `json:"photo_50"`
	Photo100    string `json:"photo_100"`
	Status      string `json:"status"`
	About       string `json:"about"`
	Relation    int    `json:"relation"`
	Hidden      int    `json:"hidden"`
	Deactivated string `json:"deactivated"`
	IsAdmin     bool   `json:"is_admin"`
	IsOwner     bool   `json:"is_owner"`
}

User - simple VK user struct

func FindUser

func FindUser(users []*User, ID int) *User

func (*User) FullName

func (u *User) FullName() string

FullName - returns full name of user

type UserLongPollServer

type UserLongPollServer struct {
	Key             string
	Server          string
	Ts              int
	Wait            int
	Mode            int
	Version         int
	RequestInterval int
	NeedPts         bool
	API             *VkAPI
	LpVersion       int
	ReadMessages    map[int]time.Time
}

LongPollServer - longpoll server structure

func NewUserLongPollServer

func NewUserLongPollServer(needPts bool, lpVersion int, requestInterval int) (resp *UserLongPollServer)

NewLongPollServer - get longpoll server

func (*UserLongPollServer) FilterReadMesages

func (server *UserLongPollServer) FilterReadMesages(messages []*Message) (result []*Message)

FilterReadMesages - filter read messages

func (*UserLongPollServer) GetLongPollMessages

func (server *UserLongPollServer) GetLongPollMessages() ([]*Message, error)

GetLongPollMessages - get messages via longpoll

func (*UserLongPollServer) Init

func (server *UserLongPollServer) Init() (err error)

Init - init longpoll server

func (*UserLongPollServer) ParseLongPollMessages

func (server *UserLongPollServer) ParseLongPollMessages(j string) (*LongPollResponse, error)

ParseLongPollMessages - parse longpoll messages

func (*UserLongPollServer) Request

func (server *UserLongPollServer) Request() ([]byte, error)

Request - make request to longpoll server

type UserLongPollServerResponse

type UserLongPollServerResponse struct {
	Response UserLongPollServer
}

LongPollServerResponse - response format for longpoll info

type UserProfile

type UserProfile struct {
	ID              int
	FirstName       string `json:"first_name"`
	LastName        string `json:"last_name"`
	IsClosed        bool   `json:"is_closed"`
	CanAccessClosed bool   `json:"can_access_closed"`
	Sex             int
	ScreenName      string `json:"screen_name"`
	BDate           string `json:"bdate"`
	Photo           string
	Online          int
	City            Geo
	Country         Geo
}

UserProfile - conversation user profile

type UsersResponse

type UsersResponse struct {
	Response VKUsers
	Error    *VKError
}

UsersResponse - VK user response

type VKBot

type VKBot struct {
	LastMsg int

	LongPoll LongPollServer
	API      *VkAPI
	// contains filtered or unexported fields
}

VKBot - bot config

func (*VKBot) CheckFriends

func (bot *VKBot) CheckFriends()

CheckFriends checking friend invites and matсhes and deletes mutual

func (*VKBot) GetMessages

func (bot *VKBot) GetMessages() ([]*Message, error)

GetMessages - request unread messages from VK (more than 200)

func (*VKBot) HandleAction

func (bot *VKBot) HandleAction(command string, handler func(*Message) string)

HandleAction - add action handler. Function must return string to reply or "" (if no reply)

func (*VKBot) HandleAdvancedMessage

func (bot *VKBot) HandleAdvancedMessage(command string, handler func(*Message) Reply)

HandleAdvancedMessage - add substr message handler. Function must return string to reply or "" (if no reply)

func (*VKBot) HandleError

func (bot *VKBot) HandleError(handler func(*Message, error))

HandleError - add error handler

func (*VKBot) HandleMessage

func (bot *VKBot) HandleMessage(command string, handler func(*Message) string)

HandleMessage - add substr message handler. Function must return string to reply or "" (if no reply)

func (*VKBot) ListenGroup

func (bot *VKBot) ListenGroup(api *VkAPI) error

func (*VKBot) ListenUser

func (bot *VKBot) ListenUser(api *VkAPI) error

func (*VKBot) MainRoute

func (bot *VKBot) MainRoute()

MainRoute - main router func. Working cycle Listen.

func (*VKBot) Reply

func (bot *VKBot) Reply(m *Message, reply Reply) (id int, err error)

Reply - reply message

func (*VKBot) RouteAction

func (bot *VKBot) RouteAction(m *Message) (replies []string, err error)

RouteAction routes an action

func (*VKBot) RouteMessage

func (bot *VKBot) RouteMessage(m *Message) (replies []Reply, err error)

RouteMessage routes single message

func (*VKBot) RouteMessages

func (bot *VKBot) RouteMessages(messages []*Message) (result map[*Message][]Reply)

RouteMessages routes inbound messages

func (*VKBot) SetAutoFriend

func (bot *VKBot) SetAutoFriend(af bool)

type VKError

type VKError struct {
	ErrorCode int    `json:"error_code"`
	ErrorMsg  string `json:"error_msg"`
}

VKError - error info

func (VKError) Error

func (err VKError) Error() string

type VKMembers

type VKMembers struct {
	Items    []MemberItem
	Profiles []UserProfile
	Groups   []GroupProfile
}

VKMembers - conversation members info

type VKUsers

type VKUsers []*User

VKUsers - Users list. Can be sort by full name

func (VKUsers) Len

func (a VKUsers) Len() int

func (VKUsers) Less

func (a VKUsers) Less(i, j int) bool

func (VKUsers) Swap

func (a VKUsers) Swap(i, j int)

type VkAPI

type VkAPI struct {
	Token           string
	URL             string
	Ver             string
	UID             int
	GroupID         int
	Lang            string
	HTTPS           bool
	AdminID         int
	MessagesCount   int
	RequestInterval int
	DEBUG           bool
}

VkAPI - api config

func (*VkAPI) AddFriend

func (api *VkAPI) AddFriend(uid int) bool

AddFriend - add friend

func (*VkAPI) Call

func (api *VkAPI) Call(method string, params map[string]string) ([]byte, error)

Call - main api call method

func (*VkAPI) CallMethod

func (api *VkAPI) CallMethod(method string, params map[string]string, result interface{}) error

CallMethod - call VK API method by name to interfce

func (*VkAPI) CurrentGroup

func (api *VkAPI) CurrentGroup() (*User, error)

CurrentGroup - get current group info

func (*VkAPI) DeleteFriend

func (api *VkAPI) DeleteFriend(uid int) bool

DeleteFriend - delete friend

func (*VkAPI) GetChatFullInfo

func (api *VkAPI) GetChatFullInfo(chatID int) (*ChatInfo, error)

func (*VkAPI) GetChatInfo

func (api *VkAPI) GetChatInfo(chatID int) (*ChatInfo, error)

GetChatInfo - returns Chat info by id

func (*VkAPI) GetChatUsers

func (api *VkAPI) GetChatUsers(chatID int) (users []*User, err error)

func (*VkAPI) GetConversation

func (api *VkAPI) GetConversation(chatID int) (*ChatInfo, error)

GetChatInfo - returns Chat info by id

func (*VkAPI) GetConversationMembers

func (api *VkAPI) GetConversationMembers(chatID int) (users []*User, err error)

GetChatUsers - get chat users

func (*VkAPI) GetFriendRequests

func (api *VkAPI) GetFriendRequests(out bool) (friends []int, err error)

GetFriendRequests - get friend requests

func (*VkAPI) GetMessages

func (api *VkAPI) GetMessages(count int, offset int) (*Messages, error)

GetMessages - get user messages (up to 200)

func (*VkAPI) GetRandomID

func (api *VkAPI) GetRandomID() string

func (*VkAPI) GetUserChatInfo

func (api *VkAPI) GetUserChatInfo(chatID int) (*ChatInfo, error)

GetChatInfo - returns Chat info by id

func (*VkAPI) GetUserChatUsers

func (api *VkAPI) GetUserChatUsers(chatID int) (users []*User, err error)

GetChatUsers - get chat users

func (*VkAPI) IsGroup

func (api *VkAPI) IsGroup() bool

func (*VkAPI) Me

func (api *VkAPI) Me() (*User, error)

Me - get current user info

func (*VkAPI) NewBot

func (api *VkAPI) NewBot() *VKBot

func (*VkAPI) NotifyAdmin

func (api *VkAPI) NotifyAdmin(msg string) (err error)

NotifyAdmin - send notify to admin

func (*VkAPI) SendAdvancedPeerMessage

func (api *VkAPI) SendAdvancedPeerMessage(peerID int64, message Reply) (id int, err error)

SendAdvancedPeerMessage sending a message to chat

func (*VkAPI) SendChatMessage

func (api *VkAPI) SendChatMessage(chatID int, msg string) (id int, err error)

SendChatMessage sending a message to chat

func (*VkAPI) SendMessage

func (api *VkAPI) SendMessage(userID int, msg string) (id int, err error)

SendMessage sending a message to user

func (*VkAPI) SendPeerMessage

func (api *VkAPI) SendPeerMessage(peerID int64, msg string) (id int, err error)

SendPeerMessage sending a message to chat

func (*VkAPI) User

func (api *VkAPI) User(uid int) (*User, error)

User - get simple user info

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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