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 5.5KB

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