mirror of https://github.com/gissleh/irc.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
1.1 KiB
47 lines
1.1 KiB
package list
|
|
|
|
// A User represents a member of a userlist.
|
|
type User struct {
|
|
Nick string `json:"nick"`
|
|
User string `json:"user,omitempty"`
|
|
Host string `json:"host,omitempty"`
|
|
Account string `json:"account,omitempty"`
|
|
Away string `json:"away,omitempty"`
|
|
Modes string `json:"modes"`
|
|
Prefixes string `json:"prefixes"`
|
|
PrefixedNick string `json:"prefixedNick"`
|
|
}
|
|
|
|
// UserPatch is used in List.Patch to apply changes to a user
|
|
type UserPatch struct {
|
|
User string
|
|
Host string
|
|
Account string
|
|
ClearAccount bool
|
|
Away string
|
|
ClearAway bool
|
|
}
|
|
|
|
// HighestMode returns the highest mode.
|
|
func (user *User) HighestMode() rune {
|
|
if len(user.Modes) == 0 {
|
|
return 0
|
|
}
|
|
|
|
return rune(user.Modes[0])
|
|
}
|
|
|
|
// IsAway returns true if user.Away is non-empty
|
|
func (user *User) IsAway() bool {
|
|
return user.Away != ""
|
|
}
|
|
|
|
// PrefixedNick gets the full nick.
|
|
func (user *User) updatePrefixedNick() {
|
|
if len(user.Prefixes) == 0 {
|
|
user.PrefixedNick = user.Nick
|
|
return
|
|
}
|
|
|
|
user.PrefixedNick = string(user.Prefixes[0]) + user.Nick
|
|
}
|