Display ban/unban events
This commit is contained in:
parent
709a57d029
commit
fdbb168e2b
@ -28,6 +28,7 @@ const (
|
|||||||
MembershipJoin Membership = "join"
|
MembershipJoin Membership = "join"
|
||||||
MembershipLeave Membership = "leave"
|
MembershipLeave Membership = "leave"
|
||||||
MembershipInvite Membership = "invite"
|
MembershipInvite Membership = "invite"
|
||||||
|
MembershipBan Membership = "ban"
|
||||||
MembershipKnock Membership = "knock"
|
MembershipKnock Membership = "knock"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -115,10 +115,15 @@ func getMembershipEventContent(room *rooms.Room, evt *gomatrix.Event) (sender st
|
|||||||
case "leave":
|
case "leave":
|
||||||
sender = "<--"
|
sender = "<--"
|
||||||
if evt.Sender != *evt.StateKey {
|
if evt.Sender != *evt.StateKey {
|
||||||
|
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)
|
reason, _ := evt.Content["reason"].(string)
|
||||||
text = tstring.NewColorTString(fmt.Sprintf("%s kicked %s: %s", senderDisplayname, displayname, reason), tcell.ColorRed)
|
text = tstring.NewColorTString(fmt.Sprintf("%s kicked %s: %s", senderDisplayname, displayname, reason), tcell.ColorRed)
|
||||||
text.Colorize(0, len(senderDisplayname), widget.GetHashColor(evt.Sender))
|
|
||||||
text.Colorize(len(senderDisplayname)+len(" kicked "), len(displayname), widget.GetHashColor(*evt.StateKey))
|
text.Colorize(len(senderDisplayname)+len(" kicked "), len(displayname), widget.GetHashColor(*evt.StateKey))
|
||||||
|
}
|
||||||
|
text.Colorize(0, len(senderDisplayname), widget.GetHashColor(evt.Sender))
|
||||||
} else {
|
} else {
|
||||||
if displayname == *evt.StateKey {
|
if displayname == *evt.StateKey {
|
||||||
displayname = prevDisplayname
|
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 = tstring.NewColorTString(fmt.Sprintf("%s left the room.", displayname), tcell.ColorRed)
|
||||||
text.Colorize(0, len(displayname), widget.GetHashColor(*evt.StateKey))
|
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 {
|
} else if displayname != prevDisplayname {
|
||||||
sender = "---"
|
sender = "---"
|
||||||
|
Loading…
Reference in New Issue
Block a user