Update stuff and move pushrules to mautrix-go

This commit is contained in:
Tulir Asokan
2020-04-16 19:27:35 +03:00
parent ff20c2c44f
commit 815190be14
47 changed files with 625 additions and 3439 deletions

View File

@ -21,6 +21,8 @@ import (
"hash/fnv"
"maunium.net/go/tcell"
"maunium.net/go/mautrix/id"
)
var colorNames = []string{
@ -201,8 +203,17 @@ func GetHashColorName(s string) string {
// GetHashColor gets the tcell Color value for the given string.
//
// GetHashColor calls GetHashColorName() and gets the Color value from the tcell.ColorNames map.
func GetHashColor(s string) tcell.Color {
return tcell.ColorNames[GetHashColorName(s)]
func GetHashColor(val interface{}) tcell.Color {
switch str := val.(type) {
case string:
return tcell.ColorNames[GetHashColorName(str)]
case *string:
return tcell.ColorNames[GetHashColorName(*str)]
case id.UserID:
return tcell.ColorNames[GetHashColorName(string(str))]
default:
return tcell.ColorNames["red"]
}
}
// AddColor adds tview color tags to the given string.