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.

Events.kt 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. package com.dmdirc.ktirc.events
  2. import com.dmdirc.ktirc.model.Capability
  3. import com.dmdirc.ktirc.model.ConnectionError
  4. import com.dmdirc.ktirc.model.ServerFeatureMap
  5. import com.dmdirc.ktirc.model.User
  6. import java.time.LocalDateTime
  7. /** Base class for all events. */
  8. sealed class IrcEvent(val time: LocalDateTime)
  9. /** Raised when a connection to the server is being established. */
  10. class ServerConnecting(time: LocalDateTime) : IrcEvent(time)
  11. /** Raised when the connection to the server has been established. The server will not be ready for use yet. */
  12. class ServerConnected(time: LocalDateTime) : IrcEvent(time)
  13. /** Raised when the connection to the server has ended. */
  14. class ServerDisconnected(time: LocalDateTime) : IrcEvent(time)
  15. /** Raised when an error occurred trying to connect. */
  16. class ServerConnectionError(time: LocalDateTime, val error: ConnectionError, val details: String?) : IrcEvent(time)
  17. /** Raised when the server is ready for use. */
  18. class ServerReady(time: LocalDateTime) : IrcEvent(time)
  19. /** Raised when the server initially welcomes us to the IRC network. */
  20. class ServerWelcome(time: LocalDateTime, val server: String, val localNick: String) : IrcEvent(time)
  21. /** Raised when the features supported by the server have changed. This may occur numerous times. */
  22. class ServerFeaturesUpdated(time: LocalDateTime, val serverFeatures: ServerFeatureMap) : IrcEvent(time)
  23. /** Raised whenever a PING is received from the server. */
  24. class PingReceived(time: LocalDateTime, val nonce: ByteArray) : IrcEvent(time)
  25. /** Raised when a user joins a channel. */
  26. class ChannelJoined(time: LocalDateTime, val user: User, val channel: String) : IrcEvent(time)
  27. /** Raised when a user leaves a channel. */
  28. class ChannelParted(time: LocalDateTime, val user: User, val channel: String, val reason: String = "") : IrcEvent(time)
  29. /** Raised when a [victim] is kicked from a channel. */
  30. class ChannelUserKicked(time: LocalDateTime, val user: User, val channel: String, val victim: String, val reason: String = "") : IrcEvent(time)
  31. /** Raised when a user quits, and is in a channel. */
  32. class ChannelQuit(time: LocalDateTime, val user: User, val channel: String, val reason: String = "") : IrcEvent(time)
  33. /** Raised when a user changes nickname, and is in a channel. */
  34. class ChannelNickChanged(time: LocalDateTime, val user: User, val channel: String, val newNick: String) : IrcEvent(time)
  35. /** Raised when a batch of the channel's member list has been received. More batches may follow. */
  36. class ChannelNamesReceived(time: LocalDateTime, val channel: String, val names: List<String>) : IrcEvent(time)
  37. /** Raised when the entirety of the channel's member list has been received. */
  38. class ChannelNamesFinished(time: LocalDateTime, val channel: String) : IrcEvent(time)
  39. /** Raised when a channel topic is discovered (not changed). Usually followed by [ChannelTopicMetadataDiscovered] if the [topic] is non-null. */
  40. class ChannelTopicDiscovered(time: LocalDateTime, val channel: String, val topic: String?) : IrcEvent(time)
  41. /** Raised when a channel topic's metadata is discovered. */
  42. class ChannelTopicMetadataDiscovered(time: LocalDateTime, val channel: String, val user: User, val setTime: LocalDateTime) : IrcEvent(time)
  43. /**
  44. * Raised when a channel's topic is changed.
  45. *
  46. * If the topic has been unset (cleared), [topic] will be `null`
  47. */
  48. class ChannelTopicChanged(time: LocalDateTime, val user: User, val channel: String, val topic: String?) : IrcEvent(time)
  49. /** Raised when a message is received. */
  50. class MessageReceived(time: LocalDateTime, val user: User, val target: String, val message: String, val messageId: String? = null) : IrcEvent(time)
  51. /**
  52. * Raised when a notice is received.
  53. *
  54. * The [user] may in fact be a server, or have a nickname of `*` while connecting.
  55. */
  56. class NoticeReceived(time: LocalDateTime, val user: User, val target: String, val message: String) : IrcEvent(time)
  57. /** Raised when an action is received. */
  58. class ActionReceived(time: LocalDateTime, val user: User, val target: String, val action: String, val messageId: String? = null) : IrcEvent(time)
  59. /** Raised when a CTCP is received. */
  60. class CtcpReceived(time: LocalDateTime, val user: User, val target: String, val type: String, val content: String) : IrcEvent(time)
  61. /** Raised when a CTCP reply is received. */
  62. class CtcpReplyReceived(time: LocalDateTime, val user: User, val target: String, val type: String, val content: String) : IrcEvent(time)
  63. /** Raised when a user quits. */
  64. class UserQuit(time: LocalDateTime, val user: User, val reason: String = "") : IrcEvent(time)
  65. /** Raised when a user changes nickname. */
  66. class UserNickChanged(time: LocalDateTime, val user: User, val newNick: String) : IrcEvent(time)
  67. /**
  68. * Raised when a user's account changes (i.e., they auth'd or deauth'd with services).
  69. *
  70. * This event is only raised if the server supports the `account-notify` capability.
  71. */
  72. class UserAccountChanged(time: LocalDateTime, val user: User, val newAccount: String?) : IrcEvent(time)
  73. /** Raised when available server capabilities are received. More batches may follow. */
  74. class ServerCapabilitiesReceived(time: LocalDateTime, val capabilities: Map<Capability, String>) : IrcEvent(time)
  75. /** Raised when our requested capabilities are acknowledged. More batches may follow. */
  76. class ServerCapabilitiesAcknowledged(time: LocalDateTime, val capabilities: Map<Capability, String>) : IrcEvent(time)
  77. /** Raised when the server has finished sending us capabilities. */
  78. class ServerCapabilitiesFinished(time: LocalDateTime) : IrcEvent(time)
  79. /** Raised when a line of the Message Of the Day has been received. */
  80. class MotdLineReceived(time: LocalDateTime, val line: String, val first: Boolean = false) : IrcEvent(time)
  81. /** Raised when a Message Of the Day has completed. */
  82. class MotdFinished(time: LocalDateTime, val missing: Boolean = false) : IrcEvent(time)
  83. /**
  84. * Raised when a mode change occurs.
  85. *
  86. * If [discovered] is true then the event is in response to the server providing the full set of modes on the target,
  87. * and the given modes are thus exhaustive. Otherwise, the modes are a sequence of changes to apply to the existing
  88. * state.
  89. */
  90. class ModeChanged(time: LocalDateTime, val target: String, val modes: String, val arguments: Array<String>, val discovered: Boolean = false) : IrcEvent(time)
  91. /** Raised when an AUTHENTICATION message is received. [argument] is `null` if the server sent an empty reply ("+") */
  92. class AuthenticationMessage(time: LocalDateTime, val argument: String?) : IrcEvent(time)
  93. /** Raised when a SASL attempt finishes, successfully or otherwise. */
  94. class SaslFinished(time: LocalDateTime, var success: Boolean) : IrcEvent(time)
  95. /** Raised when the server says our SASL mechanism isn't available, but gives us a list of others. */
  96. class SaslMechanismNotAvailableError(time: LocalDateTime, var mechanisms: Collection<String>) : IrcEvent(time)