Documentation ¶
Overview ¶
Package wrapper implement User Long Poll API wrapper v3.
w := wrapper.NewWrapper(&lp) w.OnNewMessage(func(m wrapper.NewMessage) { fmt.Printf("4 wrapper.NewMessage: %v\n", m) })
VK documentation https://vk.com/dev/using_longpoll
Index ¶
- Constants
- type Action
- type AdditionalData
- type ChatInfoChange
- type ChatInfoChangeHandler
- type ChatParamsChange
- type ChatParamsChangeHandler
- type CounterChange
- type CounterChangeHandler
- type DeleteMessages
- type DeleteMessagesHandler
- type DialogFlag
- type DialogFlagsReplace
- type DialogFlagsReplaceHandler
- type DialogFlagsReset
- type DialogFlagsResetHandler
- type DialogsFlagsSet
- type DialogsFlagsSetHandler
- type EditMessage
- type EditMessageHandler
- type ExtraFields
- type FriendBecameOffline
- type FriendBecameOfflineHandler
- type FriendBecameOnline
- type FriendBecameOnlineHandler
- type LongPollAttachments
- type MessageFlag
- type MessageFlagsChange
- type MessageFlagsChangeHandler
- type MessageFlagsReset
- type MessageFlagsResetHandler
- type MessageFlagsSet
- type MessageFlagsSetHandler
- type NewMessage
- type NewMessageHandler
- type NotificationSettingsChange
- type NotificationSettingsChangeHandler
- type ReadInMessages
- type ReadInMessagesHandler
- type ReadOutMessages
- type ReadOutMessagesHandler
- type RestoreDeletedMessages
- type RestoreDeletedMessagesHandler
- type TypeID
- type UserCall
- type UserCallHandler
- type UserTyping
- type UserTypingChat
- type UserTypingChatHandler
- type UserTypingHandler
- type UsersRecordingAudioMessage
- type UsersRecordingAudioMessageHandler
- type UsersTyping
- type UsersTypingHandler
- type Wrapper
- func (w Wrapper) OnChatInfoChange(f ChatInfoChangeHandler)
- func (w Wrapper) OnChatParamsChange(f ChatParamsChangeHandler)
- func (w Wrapper) OnCounterChange(f CounterChangeHandler)
- func (w Wrapper) OnDeleteMessages(f DeleteMessagesHandler)
- func (w Wrapper) OnDialogFlagsReplace(f DialogFlagsReplaceHandler)
- func (w Wrapper) OnDialogFlagsReset(f DialogFlagsResetHandler)
- func (w Wrapper) OnDialogsFlagsSet(f DialogsFlagsSetHandler)
- func (w Wrapper) OnEditMessage(f EditMessageHandler)
- func (w Wrapper) OnFriendBecameOffline(f FriendBecameOfflineHandler)
- func (w Wrapper) OnFriendBecameOnline(f FriendBecameOnlineHandler)
- func (w Wrapper) OnMessageFlagsChange(f MessageFlagsChangeHandler)
- func (w Wrapper) OnMessageFlagsReset(f MessageFlagsResetHandler)
- func (w Wrapper) OnMessageFlagsSet(f MessageFlagsSetHandler)
- func (w Wrapper) OnNewMessage(f NewMessageHandler)
- func (w Wrapper) OnNotificationSettingsChange(f NotificationSettingsChangeHandler)
- func (w Wrapper) OnReadInMessages(f ReadInMessagesHandler)
- func (w Wrapper) OnReadOutMessages(f ReadOutMessagesHandler)
- func (w Wrapper) OnRestoreDeletedMessages(f RestoreDeletedMessagesHandler)
- func (w Wrapper) OnUserCall(f UserCallHandler)
- func (w Wrapper) OnUserTyping(f UserTypingHandler)
- func (w Wrapper) OnUserTypingChat(f UserTypingChatHandler)
- func (w Wrapper) OnUsersRecordingAudioMessage(f UsersRecordingAudioMessageHandler)
- func (w Wrapper) OnUsersTyping(f UsersTypingHandler)
Constants ¶
const ( ChatCreate = "chat_create" // create chat ChatTitleUpdate = "chat_title_update" // change chat name ChatPhotoUpdate = "chat_photo_update" // change chat photo ChatInviteUser = "chat_invite_user" // invite user to chat ChatKickUser = "chat_kick_user" // kick out user from chat )
Possible values for Action.SourceAct.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { SourceAct string // Service action name with multiple dialogs SourceMid string // User ID to whom the service action concerns SourceText string SourceOldText string SourceMessage string SourceChatLocalID string }
Action struct for AdditionalData.
type AdditionalData ¶
type AdditionalData struct { Title string // Message's subject. RefSource string From string // User ID of who sent the message if the message is from a chat // FromAdmin ID of the administrator who sent the message. It is returned for // messages sent from a community (only for community administrators). FromAdmin string Emoji string // Message contains emoji. Action }
AdditionalData struct. If mode contains the flag 2 along with text and the message topic, a JSON-object may be passed. This object contains media attachments or other additional information. Descriptions of the object fields are listed below.
type ChatInfoChangeHandler ¶
type ChatInfoChangeHandler func(m ChatInfoChange)
ChatInfoChangeHandler handler func for ChatInfoChange.
type ChatParamsChange ¶
ChatParamsChange struct for event with code 51.
One of the parameters (content, topic) of the conversation ChatID was changed. Self — 1 or 0 (whether the change was caused by the user).
type ChatParamsChangeHandler ¶
type ChatParamsChangeHandler func(m ChatParamsChange)
ChatParamsChangeHandler handler func for ChatParamsChange.
type CounterChange ¶
type CounterChange struct {
Count int
}
CounterChange struct for event with code 80.
type CounterChangeHandler ¶
type CounterChangeHandler func(m CounterChange)
CounterChangeHandler handler func for CounterChange.
type DeleteMessages ¶
DeleteMessages struct for event with code 13.
Deleting all messages in PeerID dialogs with IDs up to LocalID.
type DeleteMessagesHandler ¶
type DeleteMessagesHandler func(m DeleteMessages)
DeleteMessagesHandler handler func for DeleteMessages.
type DialogFlag ¶
type DialogFlag int
DialogFlag type.
const ( ImportantDialog DialogFlag = 1 << iota // Important dialog UnansweredDialog // Dialog without a community reply )
Each dialog has flags, which are values received by summing up any of the following parameters.
type DialogFlagsReplace ¶
type DialogFlagsReplace struct { PeerID int Flags DialogFlag }
DialogFlagsReplace struct for event with code 11.
Replace dialog flags.
type DialogFlagsReplaceHandler ¶
type DialogFlagsReplaceHandler func(m DialogFlagsReplace)
DialogFlagsReplaceHandler handler func for DialogFlagsReplace.
type DialogFlagsReset ¶
type DialogFlagsReset struct { PeerID int Mask DialogFlag }
DialogFlagsReset struct for event with code 10.
Reset dialog flags.
type DialogFlagsResetHandler ¶
type DialogFlagsResetHandler func(m DialogFlagsReset)
DialogFlagsResetHandler handler func for DialogFlagsReset.
type DialogsFlagsSet ¶
type DialogsFlagsSet struct { PeerID int Mask DialogFlag }
DialogsFlagsSet struct for event with code 12.
Install dialog flags.
type DialogsFlagsSetHandler ¶
type DialogsFlagsSetHandler func(m DialogsFlagsSet)
DialogsFlagsSetHandler handler func for DialogsFlagsSet.
type EditMessage ¶
type EditMessage struct { MessageID int Flags MessageFlag PeerID int Timestamp time.Time NewText string AdditionalData AdditionalData Attachments LongPollAttachments }
EditMessage struct for event with code 5.
Edit message.
type EditMessageHandler ¶
type EditMessageHandler func(m EditMessage)
EditMessageHandler handler func for EditMessage.
type ExtraFields ¶
type ExtraFields struct { PeerID int // destination ID Timestamp time.Time // message sent time Text string // message text AdditionalData AdditionalData Attachments LongPollAttachments // attachments, if mode = 2 was chosen }
ExtraFields for a message object.
https://vk.com/dev/using_longpoll_3, point 3.1
type FriendBecameOffline ¶
FriendBecameOffline struct for event with code 9.
A friend UserID is offline.
type FriendBecameOfflineHandler ¶
type FriendBecameOfflineHandler func(m FriendBecameOffline)
FriendBecameOfflineHandler handler func for FriendBecameOffline.
type FriendBecameOnline ¶
FriendBecameOnline struct for event with code 8.
A friend UserID is online.
type FriendBecameOnlineHandler ¶
type FriendBecameOnlineHandler func(m FriendBecameOnline)
FriendBecameOnlineHandler handler func for FriendBecameOnline.
type LongPollAttachments ¶
type LongPollAttachments map[string]interface{}
LongPollAttachments type.
type MessageFlag ¶
type MessageFlag int
MessageFlag type.
const ( Unread MessageFlag = 1 << iota // Message is unread Outbox // Message is outgoing Replied // Message was answered Important // Message is marked as important Chat // Message sent via chat Friends // Message sent by a friend Spam // Message marked as "Spam" Deleted // Message was deleted Fixed // Message was user-checked for spam Media // Message has media content Hidden MessageFlag = 1 << 16 // Greeting message from a community DeleteForAll = 1 << 17 // Message was deleted for all NotDelivered = 1 << 18 // Incoming message not delivered )
Each message has a flag, which is a value received by summing up any of the following parameters.
type MessageFlagsChange ¶
type MessageFlagsChange struct { MessageID int Flags MessageFlag ExtraFields }
MessageFlagsChange struct for event with code 1.
Replace message flags.
type MessageFlagsChangeHandler ¶
type MessageFlagsChangeHandler func(m MessageFlagsChange)
MessageFlagsChangeHandler handler func for MessageFlagsChange.
type MessageFlagsReset ¶
type MessageFlagsReset struct { MessageID int Mask MessageFlag ExtraFields }
MessageFlagsReset struct for event with code 3.
Reset message flags.
type MessageFlagsResetHandler ¶
type MessageFlagsResetHandler func(m MessageFlagsReset)
MessageFlagsResetHandler handler func for MessageFlagsReset.
type MessageFlagsSet ¶
type MessageFlagsSet struct { MessageID int Mask MessageFlag ExtraFields }
MessageFlagsSet struct for event with code 2.
Install message flags.
type MessageFlagsSetHandler ¶
type MessageFlagsSetHandler func(m MessageFlagsSet)
MessageFlagsSetHandler handler func for MessageFlagsSet.
type NewMessage ¶
type NewMessage struct { MessageID int Flags MessageFlag ExtraFields }
NewMessage struct for event with code 4.
Add a new message.
type NewMessageHandler ¶
type NewMessageHandler func(m NewMessage)
NewMessageHandler handler func for NewMessage.
type NotificationSettingsChange ¶
NotificationSettingsChange struct for event with code 114.
type NotificationSettingsChangeHandler ¶
type NotificationSettingsChangeHandler func(m NotificationSettingsChange)
NotificationSettingsChangeHandler handler func for NotificationSettingsChange.
type ReadInMessages ¶
ReadInMessages struct for event with code 6.
Read all incoming messages received before message with LocalID.
type ReadInMessagesHandler ¶
type ReadInMessagesHandler func(m ReadInMessages)
ReadInMessagesHandler handler func for ReadInMessages.
type ReadOutMessages ¶
ReadOutMessages struct for event with code 7.
Read all outgoing messages sent before message with LocalID.
type ReadOutMessagesHandler ¶
type ReadOutMessagesHandler func(m ReadOutMessages)
ReadOutMessagesHandler handler func for ReadOutMessages.
type RestoreDeletedMessages ¶
RestoreDeletedMessages struct for event with code 14.
Restore message.
type RestoreDeletedMessagesHandler ¶
type RestoreDeletedMessagesHandler func(m RestoreDeletedMessages)
RestoreDeletedMessagesHandler handler func for RestoreDeletedMessages.
type TypeID ¶
type TypeID int
TypeID chat change type identifier.
const ( ChatNameChange TypeID = iota + 1 // The name of the conversation has changed ChatCoverChange // The cover of the conversation has changed ChatAdminAssigned // New administrator has been appointed. ChatPinMessage // Message pin ChatUserCome // User has joined the conversation ChatUserLeave // User left the conversation. ChatUserKicked // User was excluded from the conversation. ChatAdminDismissed // Administrator rights have been removed from the user )
TypeID const.
type UserCallHandler ¶
type UserCallHandler func(m UserCall)
UserCallHandler handler func for UserCall.
type UserTyping ¶
UserTyping struct for event with code 61.
User UserID began typing in the conversation ChatID.
type UserTypingChat ¶
UserTypingChat struct for event with code 62.
User UserID began typing in the conversation ChatID.
type UserTypingChatHandler ¶
type UserTypingChatHandler func(m UserTypingChat)
UserTypingChatHandler handler func for UserTypingChat.
type UserTypingHandler ¶
type UserTypingHandler func(m UserTyping)
UserTypingHandler handler func for UserTyping.
type UsersRecordingAudioMessage ¶
UsersRecordingAudioMessage struct for event with code 64.
type UsersRecordingAudioMessageHandler ¶
type UsersRecordingAudioMessageHandler func(m UsersRecordingAudioMessage)
UsersRecordingAudioMessageHandler handler func for UsersRecordingAudioMessage.
type UsersTyping ¶
UsersTyping struct for event with code 63.
type UsersTypingHandler ¶
type UsersTypingHandler func(m UsersTyping)
UsersTypingHandler handler func for UsersTyping.
type Wrapper ¶
type Wrapper struct {
// contains filtered or unexported fields
}
Wrapper struct.
func NewWrapper ¶
func NewWrapper(lp *longpoll.Longpoll) *Wrapper
NewWrapper return *Wrapper for longpoll v3.
func (Wrapper) OnChatInfoChange ¶
func (w Wrapper) OnChatInfoChange(f ChatInfoChangeHandler)
OnChatInfoChange handler for ChatInfoChange.
event with code 52.
Chat info change.
func (Wrapper) OnChatParamsChange ¶
func (w Wrapper) OnChatParamsChange(f ChatParamsChangeHandler)
OnChatParamsChange handler for ChatParamsChange.
event with code 51.
One of the parameters (content, topic) of the conversation ChatID was changed. Self — 1 or 0 (whether the change was caused by the user).
func (Wrapper) OnCounterChange ¶
func (w Wrapper) OnCounterChange(f CounterChangeHandler)
OnCounterChange handler for CounterChange.
event with code 80.
func (Wrapper) OnDeleteMessages ¶
func (w Wrapper) OnDeleteMessages(f DeleteMessagesHandler)
OnDeleteMessages handler for DeleteMessages.
event with code 13.
Deleting all messages in PeerID dialogs with IDs up to LocalID.
func (Wrapper) OnDialogFlagsReplace ¶
func (w Wrapper) OnDialogFlagsReplace(f DialogFlagsReplaceHandler)
OnDialogFlagsReplace handler for DialogFlagsReplace.
event with code 11.
Replace dialog flags.
func (Wrapper) OnDialogFlagsReset ¶
func (w Wrapper) OnDialogFlagsReset(f DialogFlagsResetHandler)
OnDialogFlagsReset handler for DialogFlagsReset.
event with code 10.
Reset dialog flags.
func (Wrapper) OnDialogsFlagsSet ¶
func (w Wrapper) OnDialogsFlagsSet(f DialogsFlagsSetHandler)
OnDialogsFlagsSet handler for DialogsFlagsSet.
event with code 12.
Install dialog flags.
func (Wrapper) OnEditMessage ¶
func (w Wrapper) OnEditMessage(f EditMessageHandler)
OnEditMessage handler for EditMessage.
event with code 5.
Edit message.
func (Wrapper) OnFriendBecameOffline ¶
func (w Wrapper) OnFriendBecameOffline(f FriendBecameOfflineHandler)
OnFriendBecameOffline handler for FriendBecameOffline.
event with code 9.
A friend UserID is offline.
func (Wrapper) OnFriendBecameOnline ¶
func (w Wrapper) OnFriendBecameOnline(f FriendBecameOnlineHandler)
OnFriendBecameOnline handler for FriendBecameOnline.
event with code 8.
A friend UserID is online.
func (Wrapper) OnMessageFlagsChange ¶
func (w Wrapper) OnMessageFlagsChange(f MessageFlagsChangeHandler)
OnMessageFlagsChange handler for MessageFlagsChange.
event with code 1.
Replace message flags.
func (Wrapper) OnMessageFlagsReset ¶
func (w Wrapper) OnMessageFlagsReset(f MessageFlagsResetHandler)
OnMessageFlagsReset handler for MessageFlagsReset.
event with code 3.
Reset message flags.
func (Wrapper) OnMessageFlagsSet ¶
func (w Wrapper) OnMessageFlagsSet(f MessageFlagsSetHandler)
OnMessageFlagsSet handler for MessageFlagsSet.
event with code 2.
Install message flags.
func (Wrapper) OnNewMessage ¶
func (w Wrapper) OnNewMessage(f NewMessageHandler)
OnNewMessage handler for NewMessage.
event with code 4.
Add a new message.
func (Wrapper) OnNotificationSettingsChange ¶
func (w Wrapper) OnNotificationSettingsChange(f NotificationSettingsChangeHandler)
OnNotificationSettingsChange handler for NotificationSettingsChange.
event with code 114.
func (Wrapper) OnReadInMessages ¶
func (w Wrapper) OnReadInMessages(f ReadInMessagesHandler)
OnReadInMessages handler for ReadInMessages.
event with code 6.
Read all incoming messages received before message with LocalID.
func (Wrapper) OnReadOutMessages ¶
func (w Wrapper) OnReadOutMessages(f ReadOutMessagesHandler)
OnReadOutMessages handler for ReadOutMessages.
event with code 7.
Read all outgoing messages sent before message with LocalID.
func (Wrapper) OnRestoreDeletedMessages ¶
func (w Wrapper) OnRestoreDeletedMessages(f RestoreDeletedMessagesHandler)
OnRestoreDeletedMessages handler for RestoreDeletedMessages.
event with code 14.
Restore message.
func (Wrapper) OnUserCall ¶
func (w Wrapper) OnUserCall(f UserCallHandler)
OnUserCall handler for UserCall.
event with code 70.
func (Wrapper) OnUserTyping ¶
func (w Wrapper) OnUserTyping(f UserTypingHandler)
OnUserTyping handler for UserTyping.
event with code 61.
User UserID began typing in the dialog. The event should happen once in ~5 seconds during continuous typing.
func (Wrapper) OnUserTypingChat ¶
func (w Wrapper) OnUserTypingChat(f UserTypingChatHandler)
OnUserTypingChat handler for UserTypingChat.
event with code 62.
User UserID began typing in the conversation ChatID.
func (Wrapper) OnUsersRecordingAudioMessage ¶
func (w Wrapper) OnUsersRecordingAudioMessage(f UsersRecordingAudioMessageHandler)
OnUsersRecordingAudioMessage handler for UsersRecordingAudioMessage.
event with code 64.
func (Wrapper) OnUsersTyping ¶
func (w Wrapper) OnUsersTyping(f UsersTypingHandler)
OnUsersTyping handler for UsersTyping.
event with code 63.