Documentation ¶
Overview ¶
Package mparser parses the text from a Slack message, identifying user, group, and channel mentions. This package also supports stripping those mentions from the message, to allow for easier command processing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Mention ¶
Mention represents a Slack message mention. This could be mentioning a user, a group, or special things like @here, @channel, and @everyone.
If Type is TypeUser or TypeGroup, the ID field will be the ID of the user or group that was mentioned. If the Type is TypeHere, TypeChannel, or TypeEveryone, the ID is the channel the message was sent in.
If the Type is TypeChannelRef, it's someone mentioning a channel in the message, and may include a Label. There is no guarantee this will be set.
func Parse ¶
Parse takes the message text, and the channel ID where the message was sent, and parses the mentions in the message. This returns the list of mentions, and the start/end index of each mention to allow you to locate them.
For @here, @channel, and @everyone the Mention.ID is set to the channelID.
func ParseAndSplice ¶
ParseAndSplice calls Parse(), and uses the start/end index of each mention to remove it from the message and return the resulting string. Please see the Parse() documentation for more information on parsing.
func (Mention) MarshalText ¶
MarshalText satisfies the encoding.TextMarshaler interface.
type Type ¶
type Type uint8
Type is a faux-enum for describing whether it was a user or group mention.
const ( // TypeUser represents a user mention. TypeUser Type = 1 << iota // TypeGroup represents a workspace group mention. TypeGroup // TypeHere is for @here mentions. If this Type is used, the // Mention.ID will be the channel's ID. TypeHere // TypeChannel is for @channel mentions. If this Type is used, the // Mention.ID will be the channel's ID. TypeChannel // TypeEveryone is for @everyone metnions. If this Type is used, the // Mention.ID will be the channel's ID. TypeEveryone // TypeChannelRef is a reference to another channel in a message, like if a // user were to type "join #general". TypeChannelRef )