diff options
-rw-r--r-- | matrix/rooms/member.go | 1 | ||||
-rw-r--r-- | ui/messages/parser/parser.go | 16 |
2 files changed, 14 insertions, 3 deletions
diff --git a/matrix/rooms/member.go b/matrix/rooms/member.go index 0f7133a..aee7533 100644 --- a/matrix/rooms/member.go +++ b/matrix/rooms/member.go @@ -28,6 +28,7 @@ const ( MembershipJoin Membership = "join" MembershipLeave Membership = "leave" MembershipInvite Membership = "invite" + MembershipBan Membership = "ban" MembershipKnock Membership = "knock" ) diff --git a/ui/messages/parser/parser.go b/ui/messages/parser/parser.go index 0c250da..647b931 100644 --- a/ui/messages/parser/parser.go +++ b/ui/messages/parser/parser.go @@ -115,10 +115,15 @@ func getMembershipEventContent(room *rooms.Room, evt *gomatrix.Event) (sender st case "leave": sender = "<--" if evt.Sender != *evt.StateKey { - reason, _ := evt.Content["reason"].(string) - text = tstring.NewColorTString(fmt.Sprintf("%s kicked %s: %s", senderDisplayname, displayname, reason), tcell.ColorRed) + if prevMembership == "ban" { + text = tstring.NewColorTString(fmt.Sprintf("%s unbanned %s", senderDisplayname, displayname), tcell.ColorGreen) + text.Colorize(len(senderDisplayname)+len(" unbanned "), len(displayname), widget.GetHashColor(*evt.StateKey)) + } else { + reason, _ := evt.Content["reason"].(string) + text = tstring.NewColorTString(fmt.Sprintf("%s kicked %s: %s", senderDisplayname, displayname, reason), tcell.ColorRed) + text.Colorize(len(senderDisplayname)+len(" kicked "), len(displayname), widget.GetHashColor(*evt.StateKey)) + } text.Colorize(0, len(senderDisplayname), widget.GetHashColor(evt.Sender)) - text.Colorize(len(senderDisplayname)+len(" kicked "), len(displayname), widget.GetHashColor(*evt.StateKey)) } else { if displayname == *evt.StateKey { displayname = prevDisplayname @@ -126,6 +131,11 @@ func getMembershipEventContent(room *rooms.Room, evt *gomatrix.Event) (sender st text = tstring.NewColorTString(fmt.Sprintf("%s left the room.", displayname), tcell.ColorRed) text.Colorize(0, len(displayname), widget.GetHashColor(*evt.StateKey)) } + case "ban": + reason, _ := evt.Content["reason"].(string) + text = tstring.NewColorTString(fmt.Sprintf("%s banned %s: %s", senderDisplayname, displayname, reason), tcell.ColorRed) + text.Colorize(len(senderDisplayname)+len(" banned "), len(displayname), widget.GetHashColor(*evt.StateKey)) + text.Colorize(0, len(senderDisplayname), widget.GetHashColor(evt.Sender)) } } else if displayname != prevDisplayname { sender = "---" |