morpheusv2

A Matrix client written in Go-QT
git clone git://archive.git.mtrnord.blog/Nordgedanken/morpheusv2.git
Log | Files | Refs | README | LICENSE

message.go (2326B)


      1 // Copyright © 2018 MTRNord <info@nordgedanken.de>
      2 //
      3 // Licensed under the Apache License, Version 2.0 (the "License");
      4 // you may not use this file except in compliance with the License.
      5 // You may obtain a copy of the License at
      6 //
      7 //     http://www.apache.org/licenses/LICENSE-2.0
      8 //
      9 // Unless required by applicable law or agreed to in writing, software
     10 // distributed under the License is distributed on an "AS IS" BASIS,
     11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 // See the License for the specific language governing permissions and
     13 // limitations under the License.
     14 
     15 package messages
     16 
     17 import (
     18 	"github.com/matrix-org/gomatrix"
     19 	"time"
     20 )
     21 
     22 // Message holds the needed Message data and allows to work with that. It gets normally loaded from the cache
     23 type Message struct {
     24 	eventID   string
     25 	event     *gomatrix.Event
     26 	authorID  string
     27 	text      string
     28 	timestamp *time.Time
     29 }
     30 
     31 // SetEventID adds the eventID to the current Message
     32 func (m *Message) SetEventID(id string) {
     33 	m.eventID = id
     34 }
     35 
     36 // SetEvent adds the gomatrix Event to the current Message
     37 func (m *Message) SetEvent(event *gomatrix.Event) {
     38 	m.event = event
     39 }
     40 
     41 // SetAuthorMXID adds the author MXID to the current Message
     42 func (m *Message) SetAuthorMXID(mxid string) {
     43 	m.authorID = mxid
     44 }
     45 
     46 // SetMessage adds the message Text to the current Message
     47 func (m *Message) SetMessage(message string) {
     48 	m.text = message
     49 }
     50 
     51 // SetTimestamp adds the Timestamp to the current Message
     52 func (m *Message) SetTimestamp(ts *time.Time) {
     53 	m.timestamp = ts
     54 }
     55 
     56 // GetEventID returns the event ID from the current Message
     57 func (m *Message) GetEventID() (id string) {
     58 	return m.eventID
     59 }
     60 
     61 // GetEvent returns the gomatrix event from the current Message
     62 func (m *Message) GetEvent() (event *gomatrix.Event) {
     63 	return m.event
     64 }
     65 
     66 // GetAuthorMXID returns the authors mxid from the current Message
     67 func (m *Message) GetAuthorMXID() (mxid string) {
     68 	return m.authorID
     69 }
     70 
     71 // GetMessage returns the text from the current Message
     72 func (m *Message) GetMessage() (message string) {
     73 	return m.text
     74 }
     75 
     76 // GetTimestamp returns the timestamp from the current Message
     77 func (m *Message) GetTimestamp() (ts *time.Time) {
     78 	return m.timestamp
     79 }
     80 
     81 // Show adds the current Message to the UI
     82 // TODO implement it
     83 func (m *Message) Show() error {
     84 	return nil
     85 }