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.

index.adoc 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  1. = KtIrc {version}
  2. Chris Smith
  3. :version: 0.11.0
  4. :toc: left
  5. :toc-position: left
  6. :toclevels: 5
  7. == About KtIrc
  8. KtIrc is a Kotlin JVM library for connecting to and interacting with IRC servers.
  9. It is still in an early stage of development. Its main features:
  10. .Built for Kotlin
  11. KtIrc is written in and designed for use in Kotlin; it uses extension methods,
  12. DSLs, sealed classes, and so on, to make it much easier to use than an
  13. equivalent Java library.
  14. .Coroutine-powered
  15. KtIrc uses co-routines for all of its input/output which lets it deal with
  16. IRC messages in the background while your app does other things, without
  17. the overhead of creating a new thread per IRC client.
  18. .Modern IRC standards
  19. KtIrc supports many IRCv3 features such as SASL authentication, message IDs,
  20. server timestamps, replies, reactions, account tags, and more. These features
  21. (where server support is available) make it easier to develop bots and
  22. clients, and enhance IRC with new user-facing functionality.
  23. == Getting started
  24. === Installing
  25. All you need to do to start using KtIrc is add a single dependency.
  26. KtIrc is published to JCenter, making it quick and easy to pull in
  27. to almost any project. The examples below show how to add the JCenter
  28. repository and then the KtIrc dependency; you may already be using
  29. JCenter for other dependencies -- in that case just skip the
  30. repository configuration!
  31. [TIP]
  32. ====
  33. KtIrc adheres to semantic versioning: you can expect to upgrade between
  34. minor versions without problems (e.g. from `0.1.2` to `0.13.7`); major
  35. version changes may include breaking changes such as the removal of
  36. deprecated methods. You should check the changelog before updating to
  37. a new major version.
  38. ====
  39. .Gradle (using Kotlin DSL)
  40. [source,kotlin,subs="attributes"]
  41. ----
  42. repositories {
  43. jcenter()
  44. }
  45. dependencies {
  46. implementation("com.dmdirc:ktirc:{version}")
  47. }
  48. ----
  49. .Gradle (using Groovy DSL)
  50. [source,groovy,subs="attributes"]
  51. ----
  52. buildscript {
  53. repositories {
  54. jcenter()
  55. }
  56. }
  57. implementation 'com.dmdirc:ktirc:{version}'
  58. ----
  59. .Maven
  60. [source,xml,subs="attributes"]
  61. ----
  62. <repositories>
  63. <repository>
  64. <id>jcenter</id>
  65. <url>https://jcenter.bintray.com</url>
  66. </repository>
  67. </repositories>
  68. <dependencies>
  69. <dependency>
  70. <groupId>com.dmdirc</groupId>
  71. <artifactId>ktirc</artifactId>
  72. <version>{version}</version>
  73. </dependency>
  74. </dependencies>
  75. ----
  76. === Creating your first client
  77. KtIrc provides a DSL ("domain specific language") for configuring a
  78. client that allows you to set the connection details, the user's
  79. details, and configure the behaviour of KtIrc itself. The DSL is
  80. accessed through the `IrcClient` function. For full details of all
  81. supported options, see the <<IrcClient DSL>> reference.
  82. A basic client will look like this:
  83. [source,kotlin]
  84. ----
  85. val client = IrcClient {
  86. server {
  87. host = "my.server.com"
  88. }
  89. profile {
  90. nickname = "nick"
  91. username = "username"
  92. realName = "Hi there"
  93. }
  94. }
  95. ----
  96. === Connecting and handling events
  97. Getting KtIrc to start connecting is as simple as calling the `connect()`
  98. method, but before that we probably want to add an event listener to deal
  99. with incoming messages:
  100. [source,kotlin]
  101. ----
  102. client.onEvent { event -> <1>
  103. when (event) { <2>
  104. is ServerReady ->
  105. client.sendJoin("#ktirc") <3>
  106. is ServerDisconnected ->
  107. client.connect()
  108. is MessageReceived ->
  109. if (event.message == "!test") <4>
  110. client.reply(event, "Test successful!") <5>
  111. }
  112. }
  113. client.connect() <6>
  114. ----
  115. <1> An event listener is registered using the `onEvent` method. It receives
  116. a single IrcEvent.
  117. <2> A Kotlin `when` statement provides a convenient way to switch on the
  118. type of event received.
  119. <3> Most common IRC commands have `send` methods defined to quickly and
  120. safely send the message with the right formatting.
  121. <4> Kotlin smart-casts the event, so you can access the properties specific
  122. to the matched event class, such as `message`.
  123. <5> The IrcClient class provides useful methods to react and respond to
  124. events.
  125. <6> The connect() method starts connecting and returns immediately. You'll
  126. receive events updating you on the progress.
  127. In this example, we're waiting for three events: `ServerReady`, which occurs
  128. after we have connected and the server has sent us all of the pre-amble
  129. such as its configuration and capabilities; `ServerDisconnected` which
  130. is raised whenever KtIrc gets disconnected from (or fails to connect to) the
  131. IRC server; and `MessageReceived` which occurs, unsuprisingly, whenever a
  132. message is received. KtIrc has many events: for more information, see the
  133. <<Events>> reference.
  134. [CAUTION]
  135. ====
  136. With this code, KtIrc will immediately try to reconnect as soon as it is
  137. disconnected. If the server closes the connection early (due to, for
  138. example, a bad password or the user being banned) this will result in a
  139. huge number of connection attempts in a short time. In real code you should
  140. always delay reconnections -- preferably with a backoff -- to avoid
  141. excessive connection attempts.
  142. ====
  143. You can see that KtIrc provides a number of useful methods for sending
  144. requests to the server, and reacting and responding to events. IRC
  145. commands that KtIrc supports can be invoked using the `send*` methods,
  146. which are documented in the <<Messages>> reference. Other useful methods
  147. such as `reply` can be found in the <<Utility methods>> reference.
  148. == Reference
  149. === IrcClient DSL
  150. The DSL for creating a new `IrcClient` allows you to set a number of
  151. options relating to how KtIrc connects, what user details it provides,
  152. and how it behaves. The full range of options available in the DSL is
  153. shown below:
  154. [source,kotlin]
  155. ----
  156. server {
  157. host = "irc.example.com"
  158. port = 6667
  159. useTls = true
  160. password = "H4ckTh3Pl4n3t"
  161. }
  162. profile {
  163. nickname = "MyBot"
  164. username = "bot"
  165. realName = "Botomatic v1.2"
  166. }
  167. behaviour {
  168. requestModesOnJoin = true
  169. alwaysEchoMessages = true
  170. }
  171. sasl {
  172. mechanisms += "PLAIN"
  173. username = "botaccount"
  174. password = "s3cur3"
  175. }
  176. ----
  177. ==== Server settings
  178. The server block allows you to specify the details of the IRC server you
  179. wish to connect to:
  180. * `host` - the hostname or IP address of the server *(required)*
  181. * `port` - the port to connect on _(default: 6667)_
  182. * `useTls` - whether to use a secure connection or not _(default: false)_
  183. * `password` - the password to provide to the server _(default: null)_
  184. An alternative more compact syntax is available for configuring server details:
  185. [source,kotlin]
  186. ----
  187. server("irc.example.com", 6667, true, "H4ckTh3Pl4n3t")
  188. ----
  189. You can, if you wish, combine the two or use named parameters:
  190. [source,kotlin]
  191. ----
  192. server(useTls = true, port = 6697) {
  193. host = "irc.example.com"
  194. password = "H4ckTh3Pl4n3t"
  195. }
  196. ----
  197. ==== User profile
  198. The user profile controls how KtIrc will present itself to the IRC server, and
  199. how other users on that server will see the KtIrc user:
  200. * `nickname` - the initial nickname you wish to use *(required)*
  201. * `username` - the "username" to provide to the server _(default: KtIrc)_
  202. * `realName` - the "real name" that will be seen by other clients
  203. _(default: KtIrc User)_
  204. [TIP]
  205. ====
  206. The "username" is sometimes called the "ident" or "gecos". Some IRC servers
  207. will check for an ident reply from your host and use that in place of the
  208. username provided if it gets a response. The username (or ident reply)
  209. becomes part of your client's hostmask, and is visible to other users. It
  210. is unrelated to nickserv or other account usernames.
  211. ====
  212. As with the <<Server settings>> you can use a more compact syntax:
  213. [source,kotlin]
  214. ----
  215. profile("nickname", "username", "real name")
  216. ----
  217. ==== Behaviour
  218. The behaviour block allows you to tweak how KtIrc itself operates. These
  219. options allow you perform common operations automatically, or enjoy more
  220. advanced IRC features even if the server doesn't support them:
  221. * `requestModesOnJoin` - if enabled, automatically requests channel modes
  222. when the client joins a new channel _(default: false)_
  223. * `alwaysEchoMessages` - if enabled, every message you send will result
  224. in a `MessageReceived` event being returned. Servers that support the
  225. IRCv3 `echo-message` capability will do this automatically; enabling the
  226. behaviour will make all servers act the same way _(default: false)_
  227. The behaviour block is optional in its entirety.
  228. ==== SASL configuration
  229. SASL ("Simple Authentication and Security Layer") is a standard mechanism
  230. for securely authenticating to a service that has recently been adopted
  231. for use in IRC. SASL supports a number of 'mechanisms' that describe how
  232. the data will be exchanged between the client and server. KtIrc supports
  233. the following mechanisms:
  234. * `EXTERNAL` - the server uses some external means to authenticate the
  235. client, instead of a username and password. On most servers this
  236. means checking the client certificate against one registered with
  237. the user's account. _(disabled by default)_
  238. * `PLAIN` - the client sends the username and password in plain text
  239. during the connection phase. This offers slightly more security
  240. than calling `nickserv identify` (for example) after connecting.
  241. * `SCRAM-SHA-1` - this mechanism involves a "salted challenge" being
  242. completed which results in both the server and the client proving that
  243. they know the user's password, but without it every being transmitted.
  244. This is based on the `SHA-1` algorithm which has known issues, but is
  245. more than sufficient when used in this manner.
  246. * `SCRAM-SHA-256` - the same as `SCRAM-SHA-1` but using the `SHA-256`
  247. algorithm instead, which is more modern and secure.
  248. To use `PLAIN`, `SCRAM-SHA-1` or `SCRAM-SHA-256`, you must supply a username
  249. and password in the configuration:
  250. [source,kotlin]
  251. ----
  252. sasl {
  253. username = "botaccount"
  254. password = "s3cur3"
  255. }
  256. ----
  257. KtIrc enables `SCRAM-SHA-256`, `SCRAM-SHA-1` and `PLAIN` by default, and will
  258. use them in that order of preference if the server supports more than one.
  259. You can modify the `mechanisms` parameter if you wish to disable one:
  260. [source,kotlin]
  261. ----
  262. sasl {
  263. mechanisms -= "PLAIN"
  264. username = "botaccount"
  265. password = "s3cur3"
  266. }
  267. ----
  268. You can also clear all the default mechanisms and provide your own list:
  269. [source,kotlin]
  270. ----
  271. sasl {
  272. mechanisms("SCRAM-SHA-256", "PLAIN")
  273. username = "botaccount"
  274. password = "s3cur3"
  275. }
  276. ----
  277. If you wish to enable the `EXTERNAL` mechanism, you do not need to provide
  278. a username or password:
  279. [source,kotlin]
  280. ----
  281. sasl {
  282. mechanisms("EXTERNAL")
  283. }
  284. ----
  285. Alternatively, if you wish to enable `EXTERNAL` but fall back to other
  286. mechanisms if it doesn't work:
  287. [source,kotlin]
  288. ----
  289. sasl {
  290. mechanisms += "EXTERNAL"
  291. username = "botaccount"
  292. password = "s3cur3"
  293. }
  294. ----
  295. The SASL block is optional in its entirety.
  296. === State
  297. KtIrc attempts to track all reasonable state of the IRC network. This includes
  298. details about the server, channels the client is joined to, and users that are
  299. also in those channels. The state is exposed in a several fields accessible
  300. from the `IrcClient`:
  301. ==== ServerState
  302. The server state provides information about the server, and our connection to
  303. it.
  304. [IMPORTANT]
  305. ====
  306. The server state will be updated frequently while KtIrc is connecting to a
  307. server. The values within it should not be relied upon until a `ServerReady`
  308. event is received, as they may be incomplete or estimates before then.
  309. ====
  310. .serverState.status (ServerStatus)
  311. Provides an enum containing the current server state. One of:
  312. * `Disconnected` - the server is not connected
  313. * `Connecting` - we are attempting to establish a connection
  314. * `Negotiating` - we are logging in, negotiating capabilities, etc
  315. * `Ready` - we are connected and commands may be sent
  316. .serverState.localNickname (String)
  317. The current nickname we are using on the IRC server. While connecting this
  318. will default to the nickname from the <<User profile>>, but it may be updated
  319. if e.g. the nick is in use or not allowed.
  320. .serverState.serverName (String)
  321. The name the server uses for itself. While connecting this defaults to the
  322. hostname given in the <<Server settings>>, but it will be updated to the
  323. value provided by the server. For example, you may connect to
  324. `irc.example.com` and during the negotiation phase KtIrc will see that it
  325. is actually talking to `server3.uk.irc.example.com` and update the
  326. serverName to reflect that.
  327. [TIP]
  328. ====
  329. For a user-friendly identifier most servers provide a `NETWORK` token in
  330. the ISUPPORT reply, which is available via the <<Features>> property.
  331. ====
  332. .serverState.channelModePrefix (ModePrefixMapping)
  333. Provides a mapping from channel user modes (such as "o" for op, "v" for
  334. voice) to the prefixes used before nicknames (such as "@" and "+").
  335. To map prefixes to modes, you can use the `getMode()` or `getModes()`
  336. functions:
  337. [source,kotlin]
  338. ----
  339. getMode('@') == 'o'
  340. getModes("@+") == "ov"
  341. ----
  342. .serverState.channelTypes (String)
  343. Contains the types of channels that are allowed by the server, such as
  344. `\#&amp;` for normal channels ("#") and local channels ("&").
  345. ===== Capabilities
  346. The IRCv3 specifications introduce the concept of 'capability negotiation'.
  347. This allows the client and server to negotiate and enable new capabilities
  348. that are mutually supported.
  349. The capabilities state contains the following properties:
  350. .serverState.capabilities.negotiationState (CapabilitiesNegotiationState)
  351. The current state of negotiating with the server. One of:
  352. * `AWAITING_LIST` - we have requested a list of capabitilies and are awaiting
  353. a reply
  354. * `AWAITING_ACK` - we have sent the capabilities we want to enable, and are
  355. waitin for the server to acknowledge them
  356. * `AUTHENTICATING` - we are attempting to authenticate with SASL
  357. * `FINISHED` - we have completed negotiation
  358. Where a server does not support IRCv3 capability negotiation, the state will
  359. remain at `AWAITING_LIST`.
  360. .serverState.capabilities.advertisedCapabilities (Map<String, String>)
  361. Contains a map of capability names to values that the server offered. This
  362. should only be required for advance use cases, such as looking up the
  363. languages offered by a server when providing the user with a choice of
  364. translations.
  365. .serverState.capabilities.enabledCapabilities (Map<Capability, String>)
  366. Contains a map of capabilities that KtIrc has successfully negotiated with
  367. the server.
  368. ====== Supported capabilities
  369. * `sasl` - used to perform SASL authentication during connection
  370. * `message-tags` - allows arbitrary tags on messages
  371. * `server-time` - the server adds a timestamp tag to each incoming message
  372. * `account-tag` - the server adds an account tag to incoming user messages
  373. * `userhost-in-names` - the NAMES reply includes users hosts not just nicknames
  374. * `multi-prefix` - all modes are included in nick prefixes (e.g. `@+nick`)
  375. * `extended-join` - more information is sent when a user joins a channel
  376. * `batch` - allows multi-line responses to be batched together
  377. * `echo-message` - echos the client's own messages back to it
  378. * `draft/labeled-responses` - responses are labeled so the client knows which
  379. incoming message corresponds to which command it sent
  380. * `account-notify` - the server sends a message when a user's account changes
  381. * `away-notify` - the server sends a message when a user's away state changes
  382. * `chghost` - the server sends a message when a user's host changes
  383. ===== Features
  384. Features are KtIrc's way of exposing the information the server declares in
  385. its ISUPPORT messages. These describe how the server is configured, and what
  386. limits are placed on clients. You access features using the `features` map
  387. in the server state:
  388. [source,kotlin]
  389. ----
  390. ircClient.serverState.features[ServerFeature.Network]
  391. ----
  392. The following features are available:
  393. * `Network` - the name of the network the server belongs to __(String?)__
  394. * `ServerCaseMapping` - the current case mapping of the server __(CaseMapping!)__
  395. * `Modeprefixes` - the user mode prefix mapping (e.g. ov to @+) __(ModePrefixMapping!)__
  396. * `MaximumChannels` - the maximum number of channels a user can join __(Int?)__
  397. * `ChannelModes` - the modes supported in channels __(Array<String>?)__
  398. * `ChannelTypes` - the types of channel supported (e.g. "#&") __(String!)__
  399. * `MaximumChannelNameLength` - how long channel names may be __(Int!)__
  400. * `WhoxSupport` - whether the server supports extended whos ("WHOX") __(Boolean!)__
  401. [NOTE]
  402. ====
  403. If the server does not define a feature, KtIrc will either fall back to a
  404. default value based on the IRC RFCs or common practice (for those features
  405. identified with a non-null type such as `Int!` or `String!`); otherwise
  406. the value of the feature will be `null` (such as for those identified as
  407. `Int?` or `String?` types).
  408. ====
  409. ==== UserState
  410. The client's UserState object tracks the details of all users in common
  411. channels. It can be used to find the most up-to-date and comprehensive
  412. information for those users, as well as the set of channels that we share
  413. with them.
  414. The UserState is accessed via the `userState` property of IrcClient and
  415. acts as a map, accessible using either a nickname or a `User` object:
  416. [source,kotlin]
  417. ----
  418. ircClient.userState["acidBurn"]
  419. val user: User = myIrcEvent.user
  420. ircClient.userState[user]
  421. ----
  422. The UserState returns a `KnownUser` object which exposes a `details`
  423. property containing the user details, and a `channels` property
  424. containing the common channel names. You can also use the `in`
  425. operator to check if the user is in a channel:
  426. [source,kotlin]
  427. ----
  428. ircClient.userState["acidBurn"]?.let { knownUser -> <1>
  429. val accountName = knownUser.account
  430. val inChannel = "#channel" in knownUser <2>
  431. val allChannels = knownUser.channels <3>
  432. }
  433. ----
  434. <1> If the user isn't known, the call to `get` (using the `[]` operator)
  435. returns null, so we use a `let` statement to deal only with the case
  436. that the user is found.
  437. <2> Check if the user is present on the common channel `#channel`. If
  438. the KtIrc client is not joined to that channel, it will always return
  439. false. You can also use the `contains("#channel")` method instead of
  440. the `in` operator.
  441. <3> Returns all common channels we share with the user; will never
  442. include channels that the KtIrc client is not joined to.
  443. ==== ChannelState
  444. The ChannelState keeps track of the state for all channels that the client
  445. is joined to. It is indexed by channel name:
  446. [source,kotlin]
  447. ----
  448. ircClient.channelState["#ktirc"]
  449. ----
  450. Each channel's state contains the following properties:
  451. * `receivingUserList` - boolean value indicating whether we are in the process
  452. of receiving the list of users for the channel. If we are, the `users`
  453. property will be incomplete.
  454. * `modesDiscovered` - boolean value indicating whether we have received the
  455. full set of modes set on the channel. The `requestModesOnJoin` <<Behaviour>>
  456. allows you to make KtIrc request these automatically.
  457. * `topic` - a ChannelTopic object representing the current channel topic.
  458. If no topic is set, then a ChannelTopic with `null` properties will be
  459. provided.
  460. * `users` - a map of all known users in the channel, see <<Channel users>>
  461. for more information
  462. * `modes` - A map of the current channel modes and their values. Only
  463. complete if `modesDiscovered` is true.
  464. ===== Channel users
  465. Channel users are accessed using the `users` property, which provides an
  466. iterable map of nickname to `ChannelUser`. Each `ChannelUser` contains
  467. the nickname and current modes for that user. To get further details about
  468. a user, such as their hostmask or real name, you should query the <<UserState>>
  469. with the given nickname.
  470. [source,kotlin]
  471. ----
  472. ircClient.channelState["#ktirc"]?.users?.forEach { user ->
  473. println("${user.nickname} has modes ${user.modes}")
  474. }
  475. ----
  476. === Events
  477. Incoming lines from the IRC server are covered by KtIrc to subclasses of
  478. `IrcEvent`. These, along with other more advance events, are then published
  479. to users of the client using the `onEvent` method in `IrcClient`.
  480. All events extend `IrcEvent`, which offers a single `metadata` property.
  481. This contains details related to the event:
  482. * `time` - the time at which the message occurred (if the server supports
  483. the `server-time` capability), or the time at which we received it.
  484. Always present.
  485. * `batchId` - an opaque string identifier for the batch the message is
  486. part of (if the server supports the `batch` capability). Null for
  487. messages not in a batch.
  488. * `messageId` - a unique, opaque string identifier for the message if
  489. the server supports the `msgid` tag. Null otherwise.
  490. * `label` - a unique, opaque string identifier that ties a message to
  491. a labelled command that was sent by KtIrc, if the server supports
  492. the `labelled-replies` capability. Null otherwise.
  493. Several specialised versions of `IrcEvent` are used which allow for easier
  494. processing:
  495. .TargetedEvent
  496. A `TargetedEvent` is one that is targeted at either a user or a channel.
  497. `TargetedEvent` exposes a string `target` property that identifies the
  498. target of the message. This allows you to direct messages to the right
  499. handler or UI component more easily:
  500. [source,kotlin]
  501. ----
  502. ircClient.onEvent { event ->
  503. when (event) {
  504. is TargetedEvent -> dispatchEvent(event.target, event)
  505. }
  506. }
  507. ----
  508. .SourcedEvent
  509. A large number of events come from a remote IRC user, and it can be
  510. useful to handle these in the same way. KtIrc offers a `SourcedEvent`
  511. interface for all events that originate from a user, and it exposes
  512. a single `user` property:
  513. [source,kotlin]
  514. ----
  515. ircClient.onEvent { event ->
  516. when (event) {
  517. is SourcedEvent -> notifyAboutUserActivity(event.user)
  518. }
  519. }
  520. ----
  521. .ChannelMembershipAdjustment
  522. A number of events describe how the membership of a channel changes --
  523. namely, joins, parts, quits, kicks, names replies, and nick changes.
  524. All of these events implement the `ChannelMembershipAdjustment` interface
  525. which reduces the amount of logic you need to do if you wish to maintain
  526. a membership list (for example in a UI). The interface exposes three
  527. properties:
  528. * `addedUser` - a single nickname to be added _(String)_
  529. * `removedUser` - a single nickname to be removed _(String)_
  530. * `replacedUsers` - a list of nicknames to replace any existing ones with
  531. _(Array<String>)_
  532. All the properties are nullable, and most events will only populate
  533. one of the three.
  534. ==== Server events
  535. ===== ServerConnecting
  536. * Type: IrcEvent
  537. * Properties: _(none)_
  538. This event is raised by KtIrc as soon as it starts attempting to connect to
  539. a server. It will be followed by either a <<ServerConnected>> or a
  540. <<ServerConnectionError>> event at some point.
  541. ===== ServerConnected
  542. * Type: IrcEvent
  543. * Properties: _(none)_
  544. This event is raised by KtIrc when it has connected to the server, and is
  545. starting the process of registering, negotiating capabilities, etc.
  546. The server will *not* yet be ready for use - a <<ServerReady>> event will
  547. follow once all of the initial setup has completed.
  548. ===== ServerConnectionError
  549. * Type: IrcEvent
  550. * Properties:
  551. ** `error`: `ConnectionError` - the type of error that occurred
  552. ** `details`: `String?` - information about the error, if available
  553. This event is raised by KtIrc when a problem occurred while connecting
  554. to the server. The `ConnectionError` enum will provide the cause of
  555. the error, if known:
  556. * `UnresolvableAddress` - the hostname provided could not be resolved
  557. to an IP address
  558. * `ConnectionRefused` - the server did not answer a connection request
  559. on the given port
  560. * `BadTlsCertificate` - there was an issue with the TLS certificate the
  561. server presented (e.g. it was out of date, for the wrong domain, etc)
  562. * `Unknown` - the exact cause of the error isn't known
  563. This event will be followed by a <<ServerDisconnected>> event.
  564. ===== ServerWelcome
  565. * Type: IrcEvent
  566. * Properties:
  567. ** `server`: `String` - the name the server supplied for itself
  568. ** `localNick`: `String` - the nickname the server says we are using
  569. This event is raised in response to the server sending a 001 WELCOME
  570. message. It contains the name that the server supplied for itself
  571. (for example, KtIrc may connect to a round-robin address like
  572. `irc.example.com` and the server it actually connects to then
  573. identifies itself as `node3.uk.irc.example.com`), and the nickname
  574. that the server says we are using.
  575. ===== ServerFeaturesUpdated
  576. * Type: IrcEvent
  577. * Properties:
  578. ** `serverFeatures`: `ServerFeatureMap` - the features supplied by the server
  579. Corresponds to the server sending a single 005 ISUPPORT line. Multiple
  580. events of this type may be raised in quick succession when features are
  581. split over multiple lines.
  582. In general, you should wait for a <<ServerReady>> event and then query the
  583. <<Features>> instead of relying on this event.
  584. ===== ServerReady
  585. * Type: IrcEvent
  586. * Properties: _(none)_
  587. This event is raised by KtIrc when it has connected to a server,
  588. registered with the IRC network, and received all of the server's
  589. initial data describing its configurations and its features.
  590. At this point it is safe to start issuing commands, checking
  591. state, joining channels, etc.
  592. ===== PingReceived
  593. * Type: IrcEvent
  594. * Properties:
  595. ** `nonce`: `ByteArray` - the unique data that must be included in the reply
  596. Raised when the IRC server sends a PING message to the client. KtIrc will
  597. automatically reply with an appropriate PONG.
  598. ===== ServerCapabilitiesReceived
  599. TODO
  600. ===== ServerCapabilitiesAcknowledged
  601. TODO
  602. ===== ServerCapabilitiesFinished
  603. TODO
  604. ===== MotdLineReceived
  605. TODO
  606. ===== MotdFinished
  607. TODO
  608. ==== Channel events
  609. ===== ChannelJoined
  610. TODO
  611. ===== ChannelJoinFailed
  612. TODO
  613. ===== ChannelParted
  614. TODO
  615. ===== ChannelUserKicked
  616. TODO
  617. ===== ChannelQuit
  618. TODO
  619. ===== ChannelNickChanged
  620. TODO
  621. ===== ChannelNamesReceived
  622. TODO
  623. ===== ChannelNamesFinished
  624. TODO
  625. ===== ChannelTopicDiscovered
  626. TODO
  627. ===== ChannelTopicMetadataDiscovered
  628. TODO
  629. ===== ChannelTopicChanged
  630. TODO
  631. ==== Channel/User events
  632. TODO
  633. ===== MessageReceived
  634. TODO
  635. ===== NoticeReceived
  636. TODO
  637. ===== ActionReceived
  638. TODO
  639. ===== CtcpReceived
  640. TODO
  641. ===== CtcpReplyReceived
  642. TODO
  643. ===== UserQuit
  644. TODO
  645. ===== UserNickChanged
  646. TODO
  647. ===== UserHostChanged
  648. TODO
  649. ===== UserAccountChanged
  650. TODO
  651. ===== ModeChanged
  652. TODO
  653. ==== Other events
  654. ===== AuthenticationMessage
  655. TODO
  656. ===== SaslFinished
  657. TODO
  658. ===== SaslMechanismNotAvailableError
  659. TODO
  660. ===== BatchStarted
  661. TODO
  662. ===== BatchFinished
  663. TODO
  664. ===== BatchReceived
  665. TODO
  666. ===== NicknameChangeFailed
  667. TODO
  668. === Messages
  669. TODO
  670. === Utility methods
  671. TODO
  672. === IRCv3 support
  673. TODO