vkapi

package
v0.0.0-...-3c8687b Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttachmentTypePhoto        = "photo"
	AttachmentTypeAudioMessage = "audio_message"
)

vk types

View Source
const (
	EventDataTypeShowSnackbar = "show_snackbar"
	EventDataTypeOpenLink     = "open_link"
	EventDataTypeOpenApp      = "open_app"
)
View Source
const (
	UserNameCaseNom = "nom"
	UserNameCaseGen = "gen"
	UserNameCaseDat = "dat"
	UserNameCaseAcc = "acc"
	UserNameCaseIns = "ins"
	UserNameCaseAbl = "abl"
)

name cases

View Source
const (
	UserOptFieldPhoto50      = "photo_50"
	UserOptFieldPhoto100     = "photo_100"
	UserOptFieldPhoto200     = "photo_200"
	UserOptFieldPhotoMax     = "photo_max"
	UserOptFieldPhoto200Orig = "photo_200_orig"
	UserOptFieldPhoto400Orig = "photo_400_orig"
	UserOptFieldPhotoMaxOrig = "photo_max_orig"
	UserOptFieldOnline       = "online"
	UserOptFieldScreenName   = "screen_name"
)

users opt fields

View Source
const Version = "5.120"

Version is a vk api version.

Variables

This section is empty.

Functions

func Auth

func Auth(accessToken string) (*Client, *Error)

Auth returns vk authorized client.

Types

type Args

type Args interface{}

Args for vk.

type ArgsMap

type ArgsMap map[string]interface{}

ArgsMap is allias for string map.

type AudioMessage

type AudioMessage struct {
	Duration int    `json:"duration"`
	LinkOGG  string `json:"link_ogg"`
	LinkMP3  string `json:"link_mp3"`
	// contains filtered or unexported fields
}

AudioMessage struct.

func (*AudioMessage) String

func (a *AudioMessage) String() string

type ChatID

type ChatID uint

ChatID points to chat.

func (ChatID) ToID

func (c ChatID) ToID() ID

ToID ...

type Client

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

Client struct.

func (*Client) Do

func (c *Client) Do(req *http.Request, obj interface{}) (status int, canceled bool)

Do sends http request and parses body as JSON.

func (*Client) EditMessage

func (c *Client) EditMessage(peerID ID, convMessageID int, content OutMessageContent) (bool, *Error)

EditMessage edits a message.

func (*Client) GetConversationMembers

func (c *Client) GetConversationMembers(peerID ID) (*Members, *Error)

GetConversationMembers returns a list of IDs of users participating in a conversation.

func (*Client) GetLongPollServer

func (c *Client) GetLongPollServer(groupID GroupID) (*LongPollServer, *Error)

GetLongPollServer returns the data needed to query a Long Poll server for events.

func (*Client) GroupsGetByID

func (c *Client) GroupsGetByID(groupIds ...GroupID) ([]*Group, *Error)

GroupsGetByID returns information about communities by their IDs.

func (*Client) HTTP

func (c *Client) HTTP(req *http.Request) (*http.Response, error)

HTTP sends http request.

func (*Client) PhotosGetMessagesUploadServer

func (c *Client) PhotosGetMessagesUploadServer(peerID ID) (*MessagesUploadServer, *Error)

PhotosGetMessagesUploadServer returns the server address for photo upload in a private message for a user. When uploaded successfully, the photo can be saved using the photos.saveMessagesPhoto method.

func (*Client) PhotosSaveMessagesPhoto

func (c *Client) PhotosSaveMessagesPhoto(server int, photo, hash string) ([]*Photo, *Error)

PhotosSaveMessagesPhoto saves a photo after being successfully uploaded. URL obtained with photos.getMessagesUploadServer method.

func (*Client) RemoveChatUser

func (c *Client) RemoveChatUser(chatID ChatID, memberID ID) *Error

RemoveChatUser allows the current user to leave a chat or, if the current user started the chat, allows the user to remove another user from the chat.

func (*Client) Self

func (c *Client) Self() Group

Self returns self group info.

func (*Client) SendMessage

func (c *Client) SendMessage(msg OutMessage) *Error

SendMessage sends a message.

func (*Client) SendMessageEventAnswer

func (c *Client) SendMessageEventAnswer(eventID string, userID UserID, peerID ID, eventData *EventData) *Error

SendMessageEventAnswer sends event answer.

func (*Client) UsersGet

func (c *Client) UsersGet(userIds []UserID, nameCase string, fields ...string) ([]*User, *Error)

UsersGet returns detailed information on users.

type Error

type Error struct {
	Method  string
	Args    url.Values
	Code    int
	Message string
}

Error struct.

func (*Error) String

func (e *Error) String() string

type EventData

type EventData struct {
	Type string `json:"type"`

	// show_snackbar
	Text string `json:"text,omitempty"`

	// open_link
	Link string `json:"link,omitempty"`

	// open_app
	Hash    string `json:"hash,omitempty"`
	AppID   int    `json:"app_id,omitempty"`
	OwnerID int    `json:"owner_id,omitempty"`
}

EventData struct.

type Group

type Group struct {
	Name        string  `json:"name"`
	ScreenName  string  `json:"screen_name"`
	Type        string  `json:"type"`
	ID          GroupID `json:"id"`
	IsClosed    boolean `json:"is_closed"`
	Deactivated string  `json:"deactivated"`
	Photo50     string  `json:"photo_50"`
	Photo100    string  `json:"photo_100"`
	Photo200    string  `json:"photo_200"`
}

Group describes VK community.

type GroupID

type GroupID uint

GroupID points to group.

func (GroupID) ToID

func (g GroupID) ToID() ID

ToID ...

type ID

type ID int

ID is a general id that can point to anything.

func (ID) ToChat

func (id ID) ToChat() ChatID

ToChat converts ID to ChatID.

func (ID) ToGroup

func (id ID) ToGroup() GroupID

ToGroup converts ID to GroupID.

func (ID) ToUser

func (id ID) ToUser() UserID

ToUser converts ID to UserID.

type JSONData

type JSONData string

JSONData represents json as string.

func NewJSONData

func NewJSONData(v interface{}) (JSONData, bool)

NewJSONData creates new JSONData from object.

func (*JSONData) Unmarshal

func (j *JSONData) Unmarshal(dst interface{}) error

Unmarshal data.

func (*JSONData) UnmarshalJSON

func (j *JSONData) UnmarshalJSON(data []byte) error

UnmarshalJSON implementation.

type LongPollServer

type LongPollServer struct {
	Server string `json:"server"`
	Key    string `json:"key"`
	Ts     string `json:"ts"`
}

LongPollServer struct.

type Member

type Member struct {
	MemberID  ID    `json:"member_id"`
	InvitedBy ID    `json:"invited_by"`
	JoinDate  int64 `json:"join_date"`
	IsAdmin   bool  `json:"is_admin"`
	IsOwner   bool  `json:"is_owner"`
	CanKick   bool  `json:"can_kick"`
}

Member struct.

type Members

type Members struct {
	Items    []*Member `json:"items"`
	Profiles []*User   `json:"profiles"`
	Groups   []*Group  `json:"groups"`
	Count    int       `json:"count"`
}

Members struct.

type Message

type Message struct {
	Date          int64        `json:"date"`
	FromID        ID           `json:"from_id"`
	PeerID        ID           `json:"peer_id"`
	Text          string       `json:"text"`
	Attachments   []attachment `json:"attachments"`
	Forward       []shortMsg   `json:"fwd_messages"`
	Reply         *shortMsg    `json:"reply_message"`
	Payload       JSONData     `json:"payload"`
	ConvMessageID int          `json:"conversation_message_id"`
	Action        *struct {
		Type     string `json:"type"`
		MemberID int    `json:"member_id"`
	} `json:"action"`
}

Message struct.

type MessagesUploadServer

type MessagesUploadServer struct {
	UploadURL string `json:"upload_url"`
	AlbumID   int    `json:"album_id"`
	UserID    UserID `json:"user_id"`
}

MessagesUploadServer struct.

type OutMessage

type OutMessage struct {
	UserID  UserID   `vkargs:"user_id"`
	UserIDs []UserID `vkargs:"user_ids"`
	PeerID  ID       `vkargs:"peer_id"`
	PeerIDs []ID     `vkargs:"peer_ids"`
	Domain  string   `vkargs:"domain"`
	ChatID  ChatID   `vkargs:"chat_id"`

	OutMessageContent
	// contains filtered or unexported fields
}

OutMessage struct.

type OutMessageContent

type OutMessageContent struct {
	Message    string   `vkargs:"message"`
	Lat        float64  `vkargs:"lat"`
	Long       float64  `vkargs:"long"`
	Attachment []string `vkargs:"attachment"`
	StickerID  int      `vkargs:"sticker_id"`
	Keyboard   JSONData `vkargs:"keyboard"`

	ReplyTo         int   `vkargs:"reply_to"`
	ForwardMessages []int `vkargs:"forward_messages"`

	DontParseLinks  bool `vkargs:"dont_parse_links"`
	DisableMentions bool `vkargs:"disable_mentions"`
}

OutMessageContent struct.

type Photo

type Photo struct {
	AlbumID int    `json:"album_id"`
	UserID  UserID `json:"user_id"`
	Date    int64  `json:"date"`
	HasTag  bool   `json:"has_tag"`
	Text    string `json:"text"`

	Sizes []struct {
		URL    string `json:"url"`
		Type   string `json:"type"`
		Height int    `json:"height"`
		Width  int    `json:"width"`
	} `json:"sizes"`
	// contains filtered or unexported fields
}

Photo struct.

func (*Photo) String

func (p *Photo) String() string

type User

type User struct {
	FirstName       string  `json:"first_name"`
	LastName        string  `json:"last_name"`
	ID              UserID  `json:"id"`
	Deactivated     string  `json:"deactivated"`
	IsClosed        boolean `json:"is_closed"`
	CanAccessClosed bool    `json:"can_access_closed"`

	// opt fields
	Photo50      *string  `json:"photo_50"`
	Photo100     *string  `json:"photo_100"`
	Photo200     *string  `json:"photo_200"`
	PhotoMax     *string  `json:"photo_max"`
	Photo200Orig *string  `json:"photo_200_orig"`
	Photo400Orig *string  `json:"photo_400_orig"`
	PhotoMaxOrig *string  `json:"photo_max_orig"`
	Online       *boolean `json:"online"`
	ScreenName   *string  `json:"screen_name"`
}

User struct.

type UserID

type UserID uint

UserID is equal to id but points only to users.

func (UserID) ToID

func (u UserID) ToID() ID

ToID ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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