Mirror of github.com/gissleh/irc
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

6 years ago
6 years ago
6 years ago
6 years ago
  1. package list
  2. // A User represents a member of a userlist.
  3. type User struct {
  4. Nick string `json:"nick"`
  5. User string `json:"user,omitempty"`
  6. Host string `json:"host,omitempty"`
  7. Account string `json:"account,omitempty"`
  8. Away string `json:"away,omitempty"`
  9. Modes string `json:"modes"`
  10. Prefixes string `json:"prefixes"`
  11. PrefixedNick string `json:"prefixedNick"`
  12. }
  13. // UserPatch is used in List.Patch to apply changes to a user
  14. type UserPatch struct {
  15. User string
  16. Host string
  17. Account string
  18. ClearAccount bool
  19. Away string
  20. ClearAway bool
  21. }
  22. // HighestMode returns the highest mode.
  23. func (user *User) HighestMode() rune {
  24. if len(user.Modes) == 0 {
  25. return 0
  26. }
  27. return rune(user.Modes[0])
  28. }
  29. // IsAway returns true if user.Away is non-empty
  30. func (user *User) IsAway() bool {
  31. return user.Away != ""
  32. }
  33. // PrefixedNick gets the full nick.
  34. func (user *User) updatePrefixedNick() {
  35. if len(user.Prefixes) == 0 {
  36. user.PrefixedNick = user.Nick
  37. return
  38. }
  39. user.PrefixedNick = string(user.Prefixes[0]) + user.Nick
  40. }