Small fixes

This commit is contained in:
Tulir Asokan 2018-06-14 13:36:53 +03:00
parent 3a27831112
commit feaf75b327
5 changed files with 53 additions and 29 deletions

View file

@ -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 {