msg

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	MessageRef
	Text string          `json:"text,omitempty"`
	Done *sync.WaitGroup `json:"-"` // WaitGroup gets unlocked when the message was processed
}

Message represents a slack.Message in a slim format. The MessageRef contains the context of the message

func FromSlackEvent

func FromSlackEvent(event *slack.MessageEvent) Message

FromSlackEvent generates a slack.MessageEvent into a msg.Message

func (*Message) AddDoneHandler

func (msg *Message) AddDoneHandler() *sync.WaitGroup

AddDoneHandler will register a sync.WaitGroup

func (*Message) GetMessageRef

func (msg *Message) GetMessageRef() slack.ItemRef

GetMessageRef create a msg.ItemRef, an unique identifier to a message

func (*Message) GetText

func (msg *Message) GetText() string

GetText returns the attached text of the message

type MessageRef

type MessageRef struct {
	Channel         string `json:"channel,omitempty"`
	User            string `json:"user,omitempty"`
	Timestamp       string `json:"ts,omitempty"`
	Thread          string `json:"thread_ts,omitempty"`
	InternalMessage bool   `json:"InternalMessage,omitempty"`
	UpdatedMessage  bool   `json:"updated,omitempty"`
}

MessageRef is holds meta information for an message, like author, creation date or channel

func (MessageRef) GetChannel

func (msg MessageRef) GetChannel() string

GetChannel returns the channel id (usually starting with "C") of the current message

func (MessageRef) GetThread

func (msg MessageRef) GetThread() string

GetThread returns the thread "timestamp" of the message

func (MessageRef) GetTime

func (msg MessageRef) GetTime() time.Time

GetTime extracts the time.Time of the Message

func (MessageRef) GetTimestamp

func (msg MessageRef) GetTimestamp() string

GetTimestamp returns the slack-timestamp of the message (e.g. 1613728332.201900)

func (MessageRef) GetUniqueKey

func (msg MessageRef) GetUniqueKey() string

GetUniqueKey generated a unique identifier for a message (based on the user/channel/thread)

func (MessageRef) GetUser

func (msg MessageRef) GetUser() string

GetUser returns the user id (usually starting with "U") of the current message

func (MessageRef) IsInternalMessage

func (msg MessageRef) IsInternalMessage() bool

IsInternalMessage is set when the bot is generating internal messages which are handles (like from "cron" command)

func (MessageRef) IsUpdatedMessage

func (msg MessageRef) IsUpdatedMessage() bool

IsUpdatedMessage identifies if the processed message should be updated (like with a "refresh" button)

func (MessageRef) WithText

func (msg MessageRef) WithText(text string) Message

WithText attaches a text to a message

type Ref

type Ref interface {
	GetChannel() string
	GetUser() string
	GetTimestamp() string
	GetThread() string
	IsInternalMessage() bool
	IsUpdatedMessage() bool
	WithText(text string) Message
	GetUniqueKey() string
}

Ref is the context of a message: the author, channel, timestamp etc

Jump to

Keyboard shortcuts

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