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.

39 lines
908 B

7 years ago
7 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. Modes string `json:"modes"`
  9. Prefixes string `json:"prefixes"`
  10. PrefixedNick string `json:"prefixedNick"`
  11. }
  12. // UserPatch is used in List.Patch to apply changes to a user
  13. type UserPatch struct {
  14. User string
  15. Host string
  16. Account string
  17. ClearAccount bool
  18. }
  19. // HighestMode returns the highest mode.
  20. func (user *User) HighestMode() rune {
  21. if len(user.Modes) == 0 {
  22. return 0
  23. }
  24. return rune(user.Modes[0])
  25. }
  26. // PrefixedNick gets the full nick.
  27. func (user *User) updatePrefixedNick() {
  28. if len(user.Prefixes) == 0 {
  29. user.PrefixedNick = user.Nick
  30. return
  31. }
  32. user.PrefixedNick = string(user.Prefixes[0]) + user.Nick
  33. }