Contexts are event objects that pass through the middleware chain. Each context provides type-safe access to event data and convenient helper methods.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/negezor/vk-io/llms.txt
Use this file to discover all available pages before exploring further.
Base Context
All contexts extend the baseContext class with these common properties:
Core Properties
Main event type (e.g.,
'message', 'wall_post', 'group_join')Event subtypes (e.g.,
['message_new'], ['chat_invite_user'])Event source:
UpdateSource.POLLING or UpdateSource.WEBHOOKMutable state object for storing custom data across middleware
Type Checking
Useis() to check event types and subtypes:
State Management
Store custom data in context state:Message Context
Type:'message'
Subtypes: 'message_new', 'message_edit', 'message_reply', chat action events
Handles incoming messages with full support for text, attachments, and chat actions.
Properties
Message ID
Message ID within conversation
Conversation ID (user ID, chat ID, or group ID)
ID of user who sent the message
Message text
Whether message was sent by current user/bot
Message creation timestamp (seconds)
Message update timestamp if edited
Array of message attachments
Forwarded messages collection
Replied-to message
Button payload (from keyboard buttons)
Chat Properties
Chat ID (for group chats)
Whether message is from a chat
Peer type:
'user', 'chat', or 'group'Methods
Chat Actions
Detect chat service actions:chat_photo_update/chat_photo_removechat_createchat_title_updatechat_invite_user/chat_kick_userchat_pin_message/chat_unpin_messagechat_invite_user_by_link
Example Usage
Wall Post Context
Type:'wall_post'
Subtypes: 'wall_post_new', 'wall_repost'
Wall post attachment with full post data
Comment Context
Type:'comment'
Subtypes: 'photo_comment_new', 'video_comment_new', 'wall_reply_new', etc.
Message Event Context
Type:'message_event'
Handles callback button presses from inline keyboards:
Payload from callback button
ID of message with the button
Group Member Context
Type:'group_member'
Subtypes: 'group_join', 'group_leave'
Typing Context
Type:'typing'
Subtypes: 'typing_user', 'typing_chat'
Available Context Types
All available context classes:MessageContext- Messages and chat eventsMessageEventContext- Callback button eventsMessageSubscriptionContext- Message allow/denyMessageFlagsContext- Message flags (polling only)MessagesReadContext- Messages read statusWallPostContext- Wall postsCommentContext- Comments on mediaLikeContext- Like add/removeVoteContext- Poll votesGroupMemberContext- Group join/leaveGroupUserContext- User block/unblockGroupUpdateContext- Group settings changesNewAttachmentsContext- New photos/videos/audioTypingContext- Typing indicatorsDialogFlagsContext- Dialog flags (polling only)DialogMessagesContext- Dialog messages counterDialogNotificationSettingsContext- Notification settingsFriendActivityContext- Friend online/offline (polling only)VKAppPayloadContext- VK App eventsVKPayTransactionContext- VK Pay transactionsMarketOrderContext- Market ordersDonutSubscriptionContext- Donut subscriptionsDonutSubscriptionPriceContext- Subscription price changesDonutWithdrawContext- Donut money withdrawalUnsupportedEventContext- Unknown events
Contexts from User Long Poll may contain incomplete data compared to Bots Long Poll or webhooks.