Small fixes
This commit is contained in:
parent
3a27831112
commit
feaf75b327
5 changed files with 53 additions and 29 deletions
|
@ -65,6 +65,10 @@ func (evt *Event) Interface() *maubot.Event {
|
|||
return mbEvent
|
||||
}
|
||||
|
||||
func (evt *Event) MarkRead() error {
|
||||
return evt.Client.MarkRead(evt.RoomID, evt.ID)
|
||||
}
|
||||
|
||||
func (evt *Event) Reply(text string) (string, error) {
|
||||
return evt.SendRawEvent(maubot.EventMessage,
|
||||
SetReply(
|
||||
|
|
|
@ -57,7 +57,21 @@ func (client *Client) ParseEvent(evt *gomatrix.Event) *Event {
|
|||
}
|
||||
|
||||
func (client *Client) AddEventHandler(evt maubot.EventType, handler maubot.EventHandler) {
|
||||
client.syncer.OnEventType(evt, handler)
|
||||
client.syncer.OnEventType(evt, func(evt *maubot.Event) bool {
|
||||
if evt.Sender == client.UserID {
|
||||
return false
|
||||
}
|
||||
return handler(evt)
|
||||
})
|
||||
}
|
||||
|
||||
func (client *Client) GetEvent(roomID, eventID string) *maubot.Event {
|
||||
evt, err := client.Client.GetEvent(roomID, eventID)
|
||||
if err != nil {
|
||||
log.Warnf("Failed to get event %s @ %s: %v", eventID, roomID, err)
|
||||
return nil
|
||||
}
|
||||
return client.ParseEvent(evt).Interface()
|
||||
}
|
||||
|
||||
func (client *Client) onJoin(evt *maubot.Event) bool {
|
||||
|
|
|
@ -41,7 +41,7 @@ func TrimReplyFallbackText(text string) string {
|
|||
for len(lines) > 0 && strings.HasPrefix(lines[0], "> ") {
|
||||
lines = lines[1:]
|
||||
}
|
||||
return strings.Join(lines, "\n")
|
||||
return strings.TrimSpace(strings.Join(lines, "\n"))
|
||||
}
|
||||
|
||||
func RemoveReplyFallback(evt *maubot.Event) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue