Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ChannelState.kt 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. package com.dmdirc.ktirc.model
  2. import com.dmdirc.ktirc.io.CaseMapping
  3. /**
  4. * Describes the state of a channel that the client has joined.
  5. */
  6. class ChannelState(val name: String, caseMappingProvider: () -> CaseMapping) {
  7. /**
  8. * Whether or not we are in the process of receiving a user list (which may span many messages).
  9. */
  10. var receivingUserList = false
  11. internal set
  12. /**
  13. * A map of all users in the channel to their current modes.
  14. */
  15. val users = ChannelUserMap(caseMappingProvider)
  16. }
  17. /**
  18. * Describes a user in a channel, and their modes.
  19. */
  20. data class ChannelUser(var nickname: String, var modes: String = "")
  21. /**
  22. * The types of supported channel modes, and what parameters they require.
  23. *
  24. * These must be sorted according to the order they are sent in the CHANMODES server feature.
  25. */
  26. enum class ChannelModeType {
  27. /** The mode adds or removes an entry for a list. It must have a param to add or remove. */
  28. List,
  29. /** The mode has a parameter that must be present to set it or unset it. */
  30. SetUnsetParameter,
  31. /** The mode has a parameter that must be present to set it, but is unset without one. */
  32. SetParameter,
  33. /** The mode does not take parameters in any case. */
  34. NoParameter;
  35. /**
  36. * Whether this mode requires a parameter to be set or not.
  37. */
  38. val needsParameterToSet: Boolean
  39. get() = this != NoParameter
  40. /**
  41. * Whether this mode requires a parameter to be unset or not.
  42. */
  43. val needsParameterToUnset: Boolean
  44. get() = this != NoParameter && this != SetParameter
  45. }