Documentation
¶
Overview ¶
types holds common data structures used across GEC components.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Message ¶
type Message struct {
Source Source `mapstructure:"source"`
ID string `mapstructure:"id"`
Timestamp int64 `mapstructure:"ts"`
Message string `mapstructure:"msg"`
Sentiment int `mapstructure:"sentiment"`
}
Message is, simply, the message to be passed between recipients
func NewMessage ¶
NewMessage accepts a source, id and string, and returns a new Message
func ParseMessage ¶
ParseMessage accepts a map, probably from redis, and turns it into a valid Message for processing
func (Message) GetTimestamp ¶ added in v1.1.0
GetTimestamp takes the unixtimestamp stored within a Message and returns a localised time.Time based on this.
Note: to get the time in UTC you'll need to do
m.GetTimestamp().UTC()
type Source ¶
type Source uint8
Source signifies the source of a message; whether it's come in from whatsapp, slack, some kind of auto-responder, or just completely unknown
const ( // SourceUnknown is where we simply ust don't know where a message comes from, // and is largely only used for zero'd messages, or when errors stop the // processing of messages. SourceUnknown Source = iota // SourceWhatsapp means a message has come from WhatsApp and usually signifies // a message from someone seeking advice SourceWhatsapp // SourceAutoresponse means a message was generated from an application in the // processing pipeline somewhere, like the various autoresponses the gec-bot // provides SourceAutoresponse // SourceSlack usually means a message from the GEC _back_ to recipients; though // in the future perhaps we'd want to allow slack users to message too... // dunno SourceSlack )
func (Source) MarshalBinary ¶ added in v1.2.0
MarshalBinary implements the encoding.BinaryMarshaler interface in order to serialise data to redis correctly
func (*Source) UnmarshalBinary ¶ added in v1.2.0
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface in order to serialise data _from_ redis correctly