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

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