Overview
Message events are triggered when the bot receives a message. NapCat supports both private (direct) messages and group messages, following the OneBot 11 standard.Common Fields
All message events share these fields:number
required
Unix timestamp (in seconds) when the message was sent
number
required
The bot’s QQ number
string
required
Always
"message" for message eventsstring
required
Type of message:
"private" or "group"string
required
Sub-type of the message:
- For private:
"friend","group"(temp chat from group), or"normal" - For group:
"normal","anonymous", or"notice"
number
required
Unique message ID for this message
number
required
Message sequence number
number
required
QQ number of the message sender
array | string
required
Message content as an array of message segments (or string in CQ code format)
string
required
Plain text representation of the message
number
required
Font ID (usually 14)
object
required
Information about the message sender
Private Message Event
Private messages are direct messages sent to the bot.Additional Fields
string
required
Always
"private"string
required
"friend"- Message from a friend"group"- Temporary chat from group member"normal"- Normal private message
number
Source of temporary chat (present when sub_type is “group”)
Example: Friend Message
Example: Temporary Chat from Group
Group Message Event
Group messages are messages sent in group chats where the bot is a member.Additional Fields
string
required
Always
"group"number
required
Group number where the message was sent
string
Name of the group
string
required
"normal"- Normal group message"anonymous"- Anonymous message"notice"- System notice
Example: Normal Group Message
Example: Group Message with At
Message Content
Themessage field contains an array of message segments. Each segment has a type and data field.
Text Segment
Image Segment
Face Segment (Emoji)
At Segment
Reply Segment
Record Segment (Voice)
Video Segment
Forward Segment
CQ Code Format
Messages can also be represented as CQ code strings in theraw_message field:
Handling Messages
Basic Message Handler
Checking for At Mentions
Processing Images
Extracting Plain Text
Quick Reply
When using HTTP POST adapter, you can reply to messages by returning a response:Next Steps
- Learn about Notice Events
- Explore Message Actions to send messages
- Check OneBot Actions Overview for responding to messages
