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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519
  1. = KtIrc {version}
  2. Chris Smith
  3. :version: 1.1.1
  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. .Gradle (using Kotlin DSL)
  32. [source,kotlin,subs="attributes"]
  33. ----
  34. repositories {
  35. jcenter()
  36. }
  37. dependencies {
  38. implementation("com.dmdirc:ktirc:{version}")
  39. }
  40. ----
  41. .Gradle (using Groovy DSL)
  42. [source,groovy,subs="attributes"]
  43. ----
  44. buildscript {
  45. repositories {
  46. jcenter()
  47. }
  48. }
  49. implementation 'com.dmdirc:ktirc:{version}'
  50. ----
  51. .Maven
  52. [source,xml,subs="attributes"]
  53. ----
  54. <repositories>
  55. <repository>
  56. <id>jcenter</id>
  57. <url>https://jcenter.bintray.com</url>
  58. </repository>
  59. </repositories>
  60. <dependencies>
  61. <dependency>
  62. <groupId>com.dmdirc</groupId>
  63. <artifactId>ktirc</artifactId>
  64. <version>{version}</version>
  65. </dependency>
  66. </dependencies>
  67. ----
  68. === Creating your first client
  69. KtIrc provides a DSL ("domain specific language") for configuring a
  70. client that allows you to set the connection details, the user's
  71. details, and configure the behaviour of KtIrc itself. The DSL is
  72. accessed through the `IrcClient` function. For full details of all
  73. supported options, see the <<IrcClient DSL>> reference.
  74. A basic client will look like this:
  75. [source,kotlin]
  76. ----
  77. val client = IrcClient {
  78. server {
  79. host = "my.server.com"
  80. }
  81. profile {
  82. nickname = "nick"
  83. username = "username"
  84. realName = "Hi there"
  85. }
  86. }
  87. ----
  88. === Connecting and handling events
  89. Getting KtIrc to start connecting is as simple as calling the `connect()`
  90. method, but before that we probably want to add an event listener to deal
  91. with incoming messages:
  92. [source,kotlin]
  93. ----
  94. client.onEvent { event -> <1>
  95. when (event) { <2>
  96. is ServerReady ->
  97. client.sendJoin("#ktirc") <3>
  98. is ServerDisconnected ->
  99. client.connect()
  100. is MessageReceived ->
  101. if (event.message == "!test") <4>
  102. client.reply(event, "Test successful!") <5>
  103. }
  104. }
  105. client.connect() <6>
  106. ----
  107. <1> An event listener is registered using the `onEvent` method. It receives
  108. a single IrcEvent.
  109. <2> A Kotlin `when` statement provides a convenient way to switch on the
  110. type of event received.
  111. <3> Most common IRC commands have `send` methods defined to quickly and
  112. safely send the message with the right formatting.
  113. <4> Kotlin smart-casts the event, so you can access the properties specific
  114. to the matched event class, such as `message`.
  115. <5> The IrcClient class provides useful methods to react and respond to
  116. events.
  117. <6> The connect() method starts connecting and returns immediately. You'll
  118. receive events updating you on the progress.
  119. In this example, we're waiting for three events: `ServerReady`, which occurs
  120. after we have connected and the server has sent us all of the pre-amble
  121. such as its configuration and capabilities; `ServerDisconnected` which
  122. is raised whenever KtIrc gets disconnected from (or fails to connect to) the
  123. IRC server; and `MessageReceived` which occurs, unsuprisingly, whenever a
  124. message is received. KtIrc has many events: for more information, see the
  125. <<Events>> reference.
  126. [CAUTION]
  127. ====
  128. With this code, KtIrc will immediately try to reconnect as soon as it is
  129. disconnected. If the server closes the connection early (due to, for
  130. example, a bad password or the user being banned) this will result in a
  131. huge number of connection attempts in a short time. In real code you should
  132. always delay reconnections -- preferably with a backoff -- to avoid
  133. excessive connection attempts.
  134. ====
  135. You can see that KtIrc provides a number of useful methods for sending
  136. requests to the server, and reacting and responding to events. IRC
  137. commands that KtIrc supports can be invoked using the `send*` methods,
  138. which are documented in the <<Messages>> reference. Other useful methods
  139. such as `reply` can be found in the <<Utility methods>> reference.
  140. === Mandatory event handling
  141. In order to properly connect to IRC, stay connected, and handle
  142. incoming messages properly, the following events MUST be handled:
  143. .<<NicknameChangeRequired>>
  144. The nickname change required event occurs when connecting to a server
  145. if our initial nickname is taken. A new nickname must be supplied
  146. to continue connecting.
  147. .<<ServerDisconnected>>
  148. When KtIrc becomes disconnected from a server, or fails a connection
  149. attempt, it will raise this event. If you wish to stay connected
  150. to IRC you must call the `connect()` method to start a reconnection
  151. attempt after an appropriate delay.
  152. .<<BatchReceived>>
  153. On servers that support the IRCv3 batch capability, some incoming
  154. messages may be sent inside a batch. These could include join or
  155. quit messages during a netsplit, or other important messages you
  156. may need to process. At minimum, when receiving a BatchReceived
  157. event you should apply your normal processing to all the events
  158. contained within.
  159. === Versioning and deprecation
  160. As of version 1.0.0, KtIrc adheres to semantic versioning: you can
  161. expect to upgrade between minor versions without problems (e.g. from `1.1.2`
  162. to `1.13.7`); major version changes include breaking changes such as the
  163. removal of methods. You should check the changelog before updating to
  164. a new major version.
  165. Where at all possible, methods will be deprecated for a full major version
  166. cycle before being removed. e.g., a method deprecated in `0.5.0` will be
  167. present in all `1.x.x` releases and will likely be removed fully in `2.0.0`.
  168. This gives users of the library opportunity to migrate away from deprecated
  169. methods in advance of their removal.
  170. In KtIrc, we define a breaking change as one that either:
  171. * removes public methods, classes, or fields; or
  172. * adds required parameters to an existing public method; or
  173. * significantly alters the default behaviour without any API changes
  174. Note that changes that don't meet this threshold to be classed as "breaking"
  175. may still cause errors in downstream projects. In particular, new enum
  176. values may be added which could cause compilation errors if they are
  177. used exhaustively (e.g. in a `return when` construct with no `else` clause).
  178. == IrcClient DSL
  179. The DSL for creating a new `IrcClient` allows you to set a number of
  180. options relating to how KtIrc connects, what user details it provides,
  181. and how it behaves. The full range of options available in the DSL is
  182. shown below:
  183. [source,kotlin]
  184. ----
  185. server {
  186. host = "irc.example.com"
  187. port = 6667
  188. useTls = true
  189. password = "H4ckTh3Pl4n3t"
  190. }
  191. profile {
  192. nickname = "MyBot"
  193. username = "bot"
  194. realName = "Botomatic v1.2"
  195. }
  196. behaviour {
  197. requestModesOnJoin = true
  198. alwaysEchoMessages = true
  199. preferIPv6 = false
  200. sendPings {
  201. sendPeriod = Duration.ofSeconds(120)
  202. responseGracePeriod = Duration.ofSeconds(30)
  203. incomingLinesResetTimer = true
  204. }
  205. }
  206. sasl {
  207. mechanisms += "PLAIN"
  208. username = "botaccount"
  209. password = "s3cur3"
  210. }
  211. ----
  212. === Server settings
  213. The server block allows you to specify the details of the IRC server you
  214. wish to connect to:
  215. * `host` - the hostname or IP address of the server *(required)*
  216. * `port` - the port to connect on _(default: 6697)_
  217. * `useTls` - whether to use a secure connection or not _(default: true)_
  218. * `password` - the password to provide to the server _(default: null)_
  219. An alternative more compact syntax is available for configuring server details:
  220. [source,kotlin]
  221. ----
  222. server("irc.example.com", 6667, true, "H4ckTh3Pl4n3t")
  223. ----
  224. You can, if you wish, combine the two or use named parameters:
  225. [source,kotlin]
  226. ----
  227. server(useTls = true, port = 6697) {
  228. host = "irc.example.com"
  229. password = "H4ckTh3Pl4n3t"
  230. }
  231. ----
  232. === User profile
  233. The user profile controls how KtIrc will present itself to the IRC server, and
  234. how other users on that server will see the KtIrc user:
  235. * `nickname` - the initial nickname you wish to use *(required)*
  236. * `username` - the "username" to provide to the server _(default: KtIrc)_
  237. * `realName` - the "real name" that will be seen by other clients
  238. _(default: KtIrc User)_
  239. [TIP]
  240. ====
  241. The "username" is sometimes called the "ident" or "gecos". Some IRC servers
  242. will check for an ident reply from your host and use that in place of the
  243. username provided if it gets a response. The username (or ident reply)
  244. becomes part of your client's hostmask, and is visible to other users. It
  245. is unrelated to nickserv or other account usernames.
  246. ====
  247. As with the <<Server settings>> you can use a more compact syntax:
  248. [source,kotlin]
  249. ----
  250. profile("nickname", "username", "real name")
  251. ----
  252. === Behaviour
  253. The behaviour block allows you to tweak how KtIrc itself operates. These
  254. options allow you perform common operations automatically, or enjoy more
  255. advanced IRC features even if the server doesn't support them:
  256. * `requestModesOnJoin` - if enabled, automatically requests channel modes
  257. when the client joins a new channel _(default: false)_
  258. * `alwaysEchoMessages` - if enabled, every message you send will result
  259. in a `MessageReceived` event being returned. Servers that support the
  260. IRCv3 `echo-message` capability will do this automatically; enabling the
  261. behaviour will make all servers act the same way _(default: false)_
  262. * `preferIPv6` - if enabled, KtIrc will prefer to connect over IPv6 if the
  263. server publishes AAAA DNS records. If disabled, KtIrc will prefer IPv4.
  264. If the server is available exclusively on IPv4 or IPv6 then this option
  265. has no effect. _(default: true)_
  266. The behaviour block is optional in its entirety.
  267. ==== Ping timeouts
  268. The behaviour config has an optional `sendPings` configuration, which
  269. instructs KtIrc to automatically send ping requests to the server.
  270. This ensures that the server is still connected and operating properly,
  271. and will trigger a disconnect if that is not the case.
  272. The sendPings block looks like:
  273. [source,kotlin]
  274. ----
  275. sendPings {
  276. sendPeriod = Duration.ofSeconds(120) <1>
  277. responseGracePeriod = Duration.ofSeconds(30) <2>
  278. incomingLinesResetTimer = true <3>
  279. }
  280. ----
  281. <1> The `sendPeriod` defines how often KtIrc should send pings. Most
  282. applications will probably want to send pings somewhere between
  283. every 30 seconds and every minute or two. If the `sendPings`
  284. block is present, this field is required.
  285. <2> The `responseGracePeriod` defines how long KtIrc will wait for a
  286. response from the server before it considers the server to be
  287. malfunctioning. Setting this too low will result in disconnects
  288. when the connection to the server is merely suffering from high
  289. latency, rather than irreparably broken. If the `sendPings`
  290. block is present, this field is required.
  291. <3> The only optional field in the `sendPings` block, the
  292. `incomingLinesResetTimer` setting determines whether KtIrc will
  293. treat _any_ incoming line in the same way as a `PONG` response;
  294. in effect it prevents KtIrc from disconnecting from a server
  295. suffering from high latency as long as the server keeps sending
  296. _something_. When disabled (or not specified), KtIrc will require
  297. an explicit `PONG` reply.
  298. === SASL configuration
  299. SASL ("Simple Authentication and Security Layer") is a standard mechanism
  300. for securely authenticating to a service that has recently been adopted
  301. for use in IRC. SASL supports a number of 'mechanisms' that describe how
  302. the data will be exchanged between the client and server. KtIrc supports
  303. the following mechanisms:
  304. * `EXTERNAL` - the server uses some external means to authenticate the
  305. client, instead of a username and password. On most servers this
  306. means checking the client certificate against one registered with
  307. the user's account. _(disabled by default)_
  308. * `PLAIN` - the client sends the username and password in plain text
  309. during the connection phase. This offers slightly more security
  310. than calling `nickserv identify` (for example) after connecting.
  311. * `SCRAM-SHA-1` - this mechanism involves a "salted challenge" being
  312. completed which results in both the server and the client proving that
  313. they know the user's password, but without it every being transmitted.
  314. This is based on the `SHA-1` algorithm which has known issues, but is
  315. more than sufficient when used in this manner.
  316. * `SCRAM-SHA-256` - the same as `SCRAM-SHA-1` but using the `SHA-256`
  317. algorithm instead, which is more modern and secure.
  318. To use `PLAIN`, `SCRAM-SHA-1` or `SCRAM-SHA-256`, you must supply a username
  319. and password in the configuration:
  320. [source,kotlin]
  321. ----
  322. sasl {
  323. username = "botaccount"
  324. password = "s3cur3"
  325. }
  326. ----
  327. KtIrc enables `SCRAM-SHA-256`, `SCRAM-SHA-1` and `PLAIN` by default, and will
  328. use them in that order of preference if the server supports more than one.
  329. You can modify the `mechanisms` parameter if you wish to disable one:
  330. [source,kotlin]
  331. ----
  332. sasl {
  333. mechanisms -= "PLAIN"
  334. username = "botaccount"
  335. password = "s3cur3"
  336. }
  337. ----
  338. You can also clear all the default mechanisms and provide your own list:
  339. [source,kotlin]
  340. ----
  341. sasl {
  342. mechanisms("SCRAM-SHA-256", "PLAIN")
  343. username = "botaccount"
  344. password = "s3cur3"
  345. }
  346. ----
  347. If you wish to enable the `EXTERNAL` mechanism, you do not need to provide
  348. a username or password:
  349. [source,kotlin]
  350. ----
  351. sasl {
  352. mechanisms("EXTERNAL")
  353. }
  354. ----
  355. Alternatively, if you wish to enable `EXTERNAL` but fall back to other
  356. mechanisms if it doesn't work:
  357. [source,kotlin]
  358. ----
  359. sasl {
  360. mechanisms += "EXTERNAL"
  361. username = "botaccount"
  362. password = "s3cur3"
  363. }
  364. ----
  365. The SASL block is optional in its entirety.
  366. == State
  367. KtIrc attempts to track all reasonable state of the IRC network. This includes
  368. details about the server, channels the client is joined to, and users that are
  369. also in those channels. The state is exposed in a several fields accessible
  370. from the `IrcClient`:
  371. === ServerState
  372. The server state provides information about the server, and our connection to
  373. it.
  374. [IMPORTANT]
  375. ====
  376. The server state will be updated frequently while KtIrc is connecting to a
  377. server. The values within it should not be relied upon until a `ServerReady`
  378. event is received, as they may be incomplete or estimates before then.
  379. ====
  380. .serverState.status (ServerStatus)
  381. Provides an enum containing the current server state. One of:
  382. * `Disconnected` - the server is not connected
  383. * `Connecting` - we are attempting to establish a connection
  384. * `Negotiating` - we are logging in, negotiating capabilities, etc
  385. * `Ready` - we are connected and commands may be sent
  386. .serverState.localNickname (String) [DEPRECATED]
  387. The current nickname we are using on the IRC server. While connecting this
  388. will default to the nickname from the <<User profile>>, but it may be updated
  389. if e.g. the nick is in use or not allowed.
  390. [WARNING]
  391. ====
  392. This property is deprecated in favour of the <<LocalUser>> property of `IrcClient`.
  393. You should migrate to using `localUser.nickname` in place of `serverSate.localNickname`.
  394. ====
  395. .serverState.serverName (String)
  396. The name the server uses for itself. While connecting this defaults to the
  397. hostname given in the <<Server settings>>, but it will be updated to the
  398. value provided by the server. For example, you may connect to
  399. `irc.example.com` and during the negotiation phase KtIrc will see that it
  400. is actually talking to `server3.uk.irc.example.com` and update the
  401. serverName to reflect that.
  402. [TIP]
  403. ====
  404. For a user-friendly identifier most servers provide a `NETWORK` token in
  405. the ISUPPORT reply, which is available via the <<Features>> property.
  406. ====
  407. .serverState.channelModePrefix (ModePrefixMapping)
  408. Provides a mapping from channel user modes (such as "o" for op, "v" for
  409. voice) to the prefixes used before nicknames (such as "@" and "+").
  410. To map prefixes to modes, you can use the `getMode()` or `getModes()`
  411. functions:
  412. [source,kotlin]
  413. ----
  414. getMode('@') == 'o'
  415. getModes("@+") == "ov"
  416. ----
  417. .serverState.channelTypes (String)
  418. Contains the types of channels that are allowed by the server, such as
  419. `\#&amp;` for normal channels ("#") and local channels ("&").
  420. ==== Capabilities
  421. The IRCv3 specifications introduce the concept of 'capability negotiation'.
  422. This allows the client and server to negotiate and enable new capabilities
  423. that are mutually supported.
  424. The capabilities state contains the following properties:
  425. .serverState.capabilities.negotiationState (CapabilitiesNegotiationState)
  426. The current state of negotiating with the server. One of:
  427. * `AWAITING_LIST` - we have requested a list of capabitilies and are awaiting
  428. a reply
  429. * `AWAITING_ACK` - we have sent the capabilities we want to enable, and are
  430. waitin for the server to acknowledge them
  431. * `AUTHENTICATING` - we are attempting to authenticate with SASL
  432. * `FINISHED` - we have completed negotiation
  433. Where a server does not support IRCv3 capability negotiation, the state will
  434. remain at `AWAITING_LIST`.
  435. .serverState.capabilities.advertisedCapabilities (Map<String, String>)
  436. Contains a map of capability names to values that the server offered. This
  437. should only be required for advance use cases, such as looking up the
  438. languages offered by a server when providing the user with a choice of
  439. translations.
  440. .serverState.capabilities.enabledCapabilities (Map<Capability, String>)
  441. Contains a map of capabilities that KtIrc has successfully negotiated with
  442. the server.
  443. ===== Supported capabilities
  444. * `sasl` - used to perform SASL authentication during connection
  445. * `message-tags` - allows arbitrary tags on messages
  446. * `server-time` - the server adds a timestamp tag to each incoming message
  447. * `account-tag` - the server adds an account tag to incoming user messages
  448. * `userhost-in-names` - the NAMES reply includes users hosts not just nicknames
  449. * `multi-prefix` - all modes are included in nick prefixes (e.g. `@+nick`)
  450. * `extended-join` - more information is sent when a user joins a channel
  451. * `batch` - allows multi-line responses to be batched together
  452. * `echo-message` - echos the client's own messages back to it
  453. * `draft/labeled-responses` - responses are labeled so the client knows which
  454. incoming message corresponds to which command it sent
  455. * `account-notify` - the server sends a message when a user's account changes
  456. * `away-notify` - the server sends a message when a user's away state changes
  457. * `chghost` - the server sends a message when a user's host changes
  458. ==== Features
  459. Features are KtIrc's way of exposing the information the server declares in
  460. its ISUPPORT messages. These describe how the server is configured, and what
  461. limits are placed on clients. You access features using the `features` map
  462. in the server state:
  463. [source,kotlin]
  464. ----
  465. ircClient.serverState.features[ServerFeature.Network]
  466. ----
  467. The following features are available:
  468. * `Network` - the name of the network the server belongs to __(String?)__
  469. * `ServerCaseMapping` - the current case mapping of the server __(CaseMapping!)__
  470. * `Modeprefixes` - the user mode prefix mapping (e.g. ov to @+) __(ModePrefixMapping!)__
  471. * `MaximumChannels` - the maximum number of channels a user can join __(Int?)__
  472. * `ChannelModes` - the modes supported in channels __(Array<String>?)__
  473. * `ChannelTypes` - the types of channel supported (e.g. "#&") __(String!)__
  474. * `MaximumChannelNameLength` - how long channel names may be __(Int!)__
  475. * `WhoxSupport` - whether the server supports extended whos ("WHOX") __(Boolean!)__
  476. [NOTE]
  477. ====
  478. If the server does not define a feature, KtIrc will either fall back to a
  479. default value based on the IRC RFCs or common practice (for those features
  480. identified with a non-null type such as `Int!` or `String!`); otherwise
  481. the value of the feature will be `null` (such as for those identified as
  482. `Int?` or `String?` types).
  483. ====
  484. === UserState
  485. The client's UserState object tracks the details of all users in common
  486. channels. It can be used to find the most up-to-date and comprehensive
  487. information for those users, as well as the set of channels that we share
  488. with them.
  489. The UserState is accessed via the `userState` property of IrcClient and
  490. acts as a map, accessible using either a nickname or a `User` object:
  491. [source,kotlin]
  492. ----
  493. ircClient.userState["acidBurn"]
  494. val user: User = myIrcEvent.user
  495. ircClient.userState[user]
  496. ----
  497. The UserState returns a `KnownUser` object which exposes a `details`
  498. property containing the <<User>> details, and a `channels` property
  499. containing the common channel names. You can also use the `in`
  500. operator to check if the user is in a channel:
  501. [source,kotlin]
  502. ----
  503. ircClient.userState["acidBurn"]?.let { knownUser -> <1>
  504. val accountName = knownUser.account
  505. val inChannel = "#channel" in knownUser <2>
  506. val allChannels = knownUser.channels <3>
  507. }
  508. ----
  509. <1> If the user isn't known, the call to `get` (using the `[]` operator)
  510. returns null, so we use a `let` statement to deal only with the case
  511. that the user is found.
  512. <2> Check if the user is present on the common channel `#channel`. If
  513. the KtIrc client is not joined to that channel, it will always return
  514. false. You can also use the `contains("#channel")` method instead of
  515. the `in` operator.
  516. <3> Returns all common channels we share with the user; will never
  517. include channels that the KtIrc client is not joined to.
  518. ==== User
  519. User objects have the following properties:
  520. * `nickname` - the current nickname of the user, always set
  521. * `ident` - the ident (username/"gecos") of the user, if known (null otherwise)
  522. * `hostname` - the hostname of the user, if known (null otherwise)
  523. * `account` - the account of the user, if known (null if account unknown, or user not registered)
  524. * `realName` - the real name of the user, if known (null otherwise)
  525. * `awayMessage` - the away message of the user, if known (null if away state unknown, or user not away)
  526. === LocalUser
  527. Contains a <<User>> instance corresponding to our own details on the IRC
  528. network. This is the same instance that would be returned from
  529. `ircClient.userState[nickname]` for the current nickname.
  530. While connecting this will default to a User with only a nickname, which will
  531. be taken from the <<User profile>>. It will be updated as more information
  532. is received from the IRC server.
  533. === ChannelState
  534. The ChannelState keeps track of the state for all channels that the client
  535. is joined to. It is indexed by channel name:
  536. [source,kotlin]
  537. ----
  538. ircClient.channelState["#ktirc"]
  539. ----
  540. Each channel's state contains the following properties:
  541. * `receivingUserList` - boolean value indicating whether we are in the process
  542. of receiving the list of users for the channel. If we are, the `users`
  543. property will be incomplete.
  544. * `modesDiscovered` - boolean value indicating whether we have received the
  545. full set of modes set on the channel. The `requestModesOnJoin` <<Behaviour>>
  546. allows you to make KtIrc request these automatically.
  547. * `topic` - a ChannelTopic object representing the current channel topic.
  548. If no topic is set, then a ChannelTopic with `null` properties will be
  549. provided.
  550. * `users` - a map of all known users in the channel, see <<Channel users>>
  551. for more information
  552. * `modes` - A map of the current channel modes and their values. Only
  553. complete if `modesDiscovered` is true.
  554. ==== Channel users
  555. Channel users are accessed using the `users` property, which provides an
  556. iterable map of nickname to `ChannelUser`. Each `ChannelUser` contains
  557. the nickname and current modes for that user. To get further details about
  558. a user, such as their hostmask or real name, you should query the <<UserState>>
  559. with the given nickname.
  560. [source,kotlin]
  561. ----
  562. ircClient.channelState["#ktirc"]?.users?.forEach { user ->
  563. println("${user.nickname} has modes ${user.modes}")
  564. }
  565. ----
  566. == Events
  567. Incoming lines from the IRC server are converted by KtIrc to subclasses of
  568. `IrcEvent`. These, along with other more advance events, are then published
  569. to users of the client using the `onEvent` method in `IrcClient`.
  570. All events extend `IrcEvent`, which offers a single `metadata` property.
  571. This contains details related to the event:
  572. * `time` - the time at which the message occurred (if the server supports
  573. the `server-time` capability), or the time at which we received it.
  574. Always present.
  575. * `batchId` - an opaque string identifier for the batch the message is
  576. part of (if the server supports the `batch` capability). Null for
  577. messages not in a batch.
  578. * `messageId` - a unique, opaque string identifier for the message if
  579. the server supports the `msgid` tag. Null otherwise.
  580. * `label` - a unique, opaque string identifier that ties a message to
  581. a labelled command that was sent by KtIrc, if the server supports
  582. the `labelled-replies` capability. Null otherwise.
  583. Several specialised versions of `IrcEvent` are used which allow for easier
  584. processing:
  585. .TargetedEvent
  586. A `TargetedEvent` is one that is targeted at either a user or a channel.
  587. `TargetedEvent` exposes a string `target` property that identifies the
  588. target of the message. This allows you to direct messages to the right
  589. handler or UI component more easily:
  590. [source,kotlin]
  591. ----
  592. ircClient.onEvent { event ->
  593. when (event) {
  594. is TargetedEvent -> dispatchEvent(event.target, event)
  595. }
  596. }
  597. ----
  598. .SourcedEvent
  599. A large number of events come from a remote IRC user, and it can be
  600. useful to handle these in the same way. KtIrc offers a `SourcedEvent`
  601. interface for all events that originate from a user, and it exposes
  602. a single `user` property:
  603. [source,kotlin]
  604. ----
  605. ircClient.onEvent { event ->
  606. when (event) {
  607. is SourcedEvent -> notifyAboutUserActivity(event.user)
  608. }
  609. }
  610. ----
  611. .ChannelMembershipAdjustment
  612. A number of events describe how the membership of a channel changes --
  613. namely, joins, parts, quits, kicks, names replies, and nick changes.
  614. All of these events implement the `ChannelMembershipAdjustment` interface
  615. which reduces the amount of logic you need to do if you wish to maintain
  616. a membership list (for example in a UI). The interface exposes three
  617. properties:
  618. * `addedUser` - a single nickname to be added _(String)_
  619. * `removedUser` - a single nickname to be removed _(String)_
  620. * `replacedUsers` - a list of nicknames to replace any existing ones with
  621. _(Array<String>)_
  622. All the properties are nullable, and most events will only populate
  623. one of the three.
  624. === Server events
  625. ==== ServerConnecting
  626. * Type: IrcEvent
  627. * Properties: _(none)_
  628. This event is raised by KtIrc as soon as it starts attempting to connect to
  629. a server. It will be followed by either a <<ServerConnected>> or a
  630. <<ServerConnectionError>> event at some point.
  631. ==== ServerConnected
  632. * Type: IrcEvent
  633. * Properties: _(none)_
  634. This event is raised by KtIrc when it has connected to the server, and is
  635. starting the process of registering, negotiating capabilities, etc.
  636. The server will *not* yet be ready for use - a <<ServerReady>> event will
  637. follow once all of the initial setup has completed.
  638. ==== ServerConnectionError
  639. * Type: IrcEvent
  640. * Properties:
  641. ** `error`: `ConnectionError` - the type of error that occurred
  642. ** `details`: `String?` - information about the error, if available
  643. This event is raised by KtIrc when a problem occurred while connecting
  644. to the server. The `ConnectionError` enum will provide the cause of
  645. the error, if known:
  646. * `UnresolvableAddress` - the hostname provided could not be resolved
  647. to an IP address
  648. * `ConnectionRefused` - the server did not answer a connection request
  649. on the given port
  650. * `BadTlsCertificate` - there was an issue with the TLS certificate the
  651. server presented (e.g. it was out of date, for the wrong domain, etc)
  652. * `Unknown` - the exact cause of the error isn't known
  653. This event will be followed by a <<ServerDisconnected>> event.
  654. ==== ServerWelcome
  655. * Type: IrcEvent
  656. * Properties:
  657. ** `server`: `String` - the name the server supplied for itself
  658. ** `localNick`: `String` - the nickname the server says we are using
  659. This event is raised in response to the server sending a 001 WELCOME
  660. message. It contains the name that the server supplied for itself
  661. (for example, KtIrc may connect to a round-robin address like
  662. `irc.example.com` and the server it actually connects to then
  663. identifies itself as `node3.uk.irc.example.com`), and the nickname
  664. that the server says we are using.
  665. ==== ServerReady
  666. * Type: IrcEvent
  667. * Properties: _(none)_
  668. This event is raised by KtIrc when it has connected to a server,
  669. registered with the IRC network, and received all of the server's
  670. initial data describing its configurations and its features.
  671. At this point it is safe to start issuing commands, checking
  672. state, joining channels, etc.
  673. ==== ServerDisconnected
  674. * Type: IrcEvent
  675. * Properties: _(none)_
  676. Raised in all cases where KtIrc has attempted to connect to an IRC server and
  677. has now been disconnected. KtIrc will not automatically attempt to reconnect;
  678. the `connect()` method should be called again after an appropriate delay.
  679. NOTE: All of KtIrc's internal state, such as details about users and
  680. channels, will be reset when disconnected from the server. State should not
  681. be queried until a new <<ServerReady>> event has been received, at which
  682. point it will have been recreated.
  683. ==== MotdLineReceived
  684. * Type: IrcEvent
  685. * Properties:
  686. ** `line`: `String` - the line of the message of the day that was received
  687. ** `first`: `Boolean` - true if the line is the first one received
  688. The MotdLineReceived event is raised whenever the server sends a single
  689. line of its Message of the Day. The `first` parameter is set on the
  690. first line of the MOTD so that special formatting or UI handling can
  691. be applied. When the MOTD is finished, a <<MotdFinished>> event is raised.
  692. ==== MotdFinished
  693. * Type: IrcEvent
  694. * Properties:
  695. ** `missing`: `Boolean` - indicates the MOTD was missing
  696. This event occurs in two circumstances: when the server has sent a
  697. series of <<MotdLineReceived>> events and has reached the end of the
  698. Message of the Day; or when the server has no MOTD to send and
  699. informs the client that the MOTD is missing.
  700. === Channel events
  701. NOTE: Many events such as <<MessageReceived>> apply to both channels and
  702. users. These are documented in the <<Channel/User events>> category.
  703. ==== ChannelJoined
  704. * Type: IrcEvent, TargetedEvent, SourcedEvent, ChannelMembershipAdjustment
  705. * Properties:
  706. ** `user`: `User` - the user that joined the channel
  707. ** `target`: `String` - the channel that was joined
  708. Raised whenever a user joins a channel, including the KtIrc client. You
  709. can determine whether the join applies to another user or the local client
  710. using the <<IsLocalClient>> utility method.
  711. When the local client joins a new channel, this event will typically be
  712. followed by one or more <<ChannelNamesReceived>> events, then
  713. <<ChannelNamesFinished>>, <<ChannelTopicDiscovered>> and if the
  714. `requestModesOnJoin` <<Behaviour>> is enabled a <<ModeChanged>> event.
  715. ==== ChannelJoinFailed
  716. * Type: IrcEvent, TargetedEvent
  717. * Properties:
  718. ** `target`: `String` - the channel that we tried to join
  719. ** `reason`: `JoinError` - the error that prevented us from joining
  720. The ChannelJoinFailed event is raised when we attempt to join a channel
  721. but the server doesn't allow us to do so. The reason parameter enumerates
  722. the possible problems:
  723. * `TooManyChannels` - we are already in the maximum number of channels allowed
  724. by the server.
  725. * `NoHiding` - the channel is no-hiding (+H), but we have invisible join/parts
  726. enabled.
  727. * `NeedKey` - the channel is keyed (+k) and a valid key was not provided
  728. * `NeedInvite` - the channel is invite only (+i) and no invite was received.
  729. * `NeedRegisteredNick` - the channel is limited to registered users only, and we
  730. are not registered.
  731. * `NeedTls` - the channel is secure-only, and we're not using TLS.
  732. * `NeedAdmin` - the channel is limited to server admins and we are not one.
  733. * `NeedOper` - the channel is limited to ircops and we are not one.
  734. * `Banned` - we are banned from the channel.
  735. * `ChannelFull` - the channel is limited (+l) and currently full.
  736. * `BadChannelName` - the channel name is disallowed by the server.
  737. * `Throttled` - we're trying to joiin too many channels and have been throttled.
  738. * `Unknown` - we don't know why.
  739. [WARNING]
  740. ====
  741. ChannelJoinFailed events are generated on a _best-effort_ basis by KtIrc. Error
  742. handling on IRC is very poorly standardised, and varies wildly between server
  743. implementations. For example, trying to join a secure-only channel on an
  744. ircd-seven server will send a NOTICE to the user instead of an error response,
  745. so no `ChannelJoinFailed` event will be raised.
  746. When tracking whether a join suceeded or failed you should combine monitoring
  747. for the response with a reasonable timeout, and assume failure if the timeout
  748. lapses without a <<ChannelJoined>> or <<ChannelJoinFailed>> event occurring.
  749. ====
  750. ==== ChannelParted
  751. * Type: IrcEvent, TargetedEvent, SourcedEvent, ChannelMembershipAdjustment
  752. * Properties:
  753. ** `user`: `User` - the user that parted the channel
  754. ** `target`: `String` - the channel that was parted
  755. ** `reason`: `String` - the user-supplied reason for parting
  756. Raised when any user parts a channel that we are on. Users can supply a reason
  757. when parting a channel; if they have done so the `reason` property will be
  758. non-empty.
  759. ==== ChannelUserKicked
  760. * Type: IrcEvent, TargetedEvent, SourcedEvent, ChannelMembershipAdjustment
  761. * Properties:
  762. ** `user`: `User` - the user that performed the kick
  763. ** `victim`: `String` - the nickname of the user that was kicked
  764. ** `target`: `String` - the channel that the victim was kicked from
  765. ** `reason`: `String` - the user-supplied reason for kicking
  766. This event occurs when a user is kicked (forcibly removed) from a channel.
  767. NOTE: The `user` is the one performing the kick, and will remain in the
  768. channel. The `victim` is the one being forcibly ejected.
  769. ==== ChannelQuit
  770. * Type: IrcEvent, TargetedEvent, SourcedEvent, ChannelMembershipAdjustment
  771. * Properties:
  772. ** `user`: `User` - the user that quit
  773. ** `target`: `String` - the channel that the user was in
  774. ** `reason`: `String` - the user-supplied reason for quitting
  775. After a <<UserQuit>> event, KtIrc will "fan out" the event to all of the
  776. channels that we share with the user and raise a `ChannelQuit` event for
  777. each channel. This is designed to make implementing certain features easier;
  778. if you fully handle a UserQuit event there is no need to also handle the
  779. ChannelQuit events, and vice-versa.
  780. Users and servers can supply a reason when a user quits; if supplied then
  781. the `reason` parameter will be non-empty.
  782. ==== ChannelNickChanged
  783. * Type: IrcEvent, TargetedEvent, SourcedEvent, ChannelMembershipAdjustment
  784. * Properties:
  785. ** `user`: `User` - the user who has changed their nickname
  786. ** `target`: `String` - the channel that the user is in
  787. ** `newNick`: `String` - the user's new nickname
  788. After a <<UserNickChanged>> event, KtIrc will "fan out" the event to
  789. all of the channels that we share with the user and raise a `ChannelNickChanged`
  790. event for each channel. This is designed to make implementing certain features
  791. easier; if you fully handle a UserNickChanged event there is no need to also
  792. handle the ChannelNickChanged events, and vice-versa.
  793. TIP: The user property will contain the user's old details, but you will
  794. not be able to access additional information from the <<UserState>> using
  795. these details as KtIrc will have internally renamed the user to use the
  796. new nickname.
  797. ==== ChannelNamesReceived
  798. * Type: IrcEvent, TargetedEvent
  799. * Properties:
  800. ** `target`: `String` - the channel that the user is in
  801. ** `names`: `List<String>` - the partial list of names that are in the channel
  802. When we join a channel (or manually request it) the IRC server sends the
  803. list of channel members in a sequence of NAMES messages. KtIrc raises a
  804. `ChannelNamesReceived` event for each of these messages.
  805. WARNING: The given names may not be a complete list of members of the channel,
  806. as more names could follow. The format of the names varies between IRC servers
  807. and depending on the IRCv3 <<Capabilities>> that KtIrc negotiated. Most
  808. implementations should simply wait for <<ChannelNamesFinished>> and then request
  809. the complete list of names from KtIrc's <<ChannelState>>.
  810. ==== ChannelNamesFinished
  811. * Type: IrcEvent, TargetedEvent, ChannelMembershipAdjustment
  812. * Properties:
  813. ** `target`: `String` - the channel whose names response has finished
  814. Raised when the IRC server has finished receiving all of the names of users
  815. that are currently in a channel. At this point you can query the channel's
  816. <<ChannelState>> to get a detailed list of members.
  817. ==== ChannelTopicDiscovered
  818. * Type: IrcEvent, TargetedEvent
  819. * Properties:
  820. ** `target`: `String` - the channel whose topic was discovered
  821. ** `topic`: `String?` - the topic in the channel, if any
  822. `ChannelTopicDiscovered` occurs when we join a channel (or manually request
  823. that the server repeats the current topic) and contains the current channel
  824. topic. If there is no topic set, the `topic` parameter will be `null`.
  825. Metadata about the topic, such as who set it and when, is contained in the
  826. <<ChannelTopicMetadataDiscovered>> event which should follow this one, if
  827. the topic was set.
  828. ==== ChannelTopicMetadataDiscovered
  829. * Type: IrcEvent, TargetedEvent
  830. * Properties:
  831. ** `target`: `String` - the channel whose topic metadata was discovered
  832. ** `user`: `User` - the user who set the topic
  833. ** `setTime`: `LocalDateTime` - the time at which the topic was set
  834. Provides meta-data relating to a topic that was previously set on the
  835. channel.
  836. NOTE: The given user may not exist on the network any more, or may have
  837. changed details since the topic was set. You should not expect to be able
  838. to look up the user's details in the <<UserState>>, or interact with them
  839. directly on IRC.
  840. ==== ChannelTopicChanged
  841. * Type: IrcEvent, TargetedEvent, SourcedEvent
  842. * Properties:
  843. ** `user`: `User` - the user who has changed the topic
  844. ** `target`: `String` - the channel that the topic was changed in
  845. ** `topic`: `String?` - the channel's new topic
  846. Raised when a user changes the topic of a channel we are joined to. If
  847. the topic was cleared/removed, the `topic` parameter will be `null`.
  848. ==== ChannelAway
  849. * Type: IrcEvent, TargetedEvent, SourcedEvent
  850. * Properties:
  851. ** `user`: `User` - the user whose away state has changed
  852. ** `target`: `String` - the channel that the user is in
  853. ** `message`: `String?` - the away message, or `null` if the user is back
  854. After a <<UserAway>> event, KtIrc will "fan out" the event to all of the
  855. channels that we share with the user and raise a `ChannelAway`
  856. event for each channel. This is designed to make implementing certain features
  857. easier; if you fully handle a UserAway event there is no need to also
  858. handle the ChannelAway events, and vice-versa.
  859. === Channel/User events
  860. These are events that may be targeted to either a channel or a user. You
  861. can use the <<IsChannel>> method to determine whether the target of one
  862. of these events is a channel or not.
  863. ==== MessageReceived
  864. * Type: IrcEvent, TargetedEvent, SourcedEvent
  865. * Properties:
  866. ** `user`: `User` - the user who sent the message
  867. ** `target`: `String` - the channel or user the message was sent to
  868. ** `message`: `String` - the text of the message
  869. Raised whenever we receive a message on a channel or directly to our
  870. local user. CTCPs and Actions, which are client-side extensions to
  871. messages will not raise this event; instead they will raise
  872. <<CtcpReceived>> and <<ActionReceived>> respectively.
  873. The <<Reply>> function can be used to reply to a message,
  874. automatically selecting the appropriate target and including the
  875. message ID in the reply where supported by the IRC server.
  876. ==== NoticeReceived
  877. * Type: IrcEvent, TargetedEvent, SourcedEvent
  878. * Properties:
  879. ** `user`: `User` - the user who sent the notice
  880. ** `target`: `String` - the channel or user the notice was sent to
  881. ** `message`: `String` - the text of the notice
  882. Raised whenever we receive a notice on a channel or directly to our
  883. local user. CTCP replies, which are client-side extensions to
  884. notices will not raise this event; instead they will raise
  885. <<CtcpReplyReceived>>.
  886. During connection, notices may be received which target either the
  887. magic string `AUTH` or `*`, as the client's nickname is not yet
  888. known.
  889. ==== ActionReceived
  890. * Type: IrcEvent, TargetedEvent, SourcedEvent
  891. * Properties:
  892. ** `user`: `User` - the user who sent the action
  893. ** `target`: `String` - the channel or user the action was sent to
  894. ** `action`: `String` - the text of the action
  895. Raised whenever we receive an 'action' message on a channel or
  896. directly to our local user. Actions are a client-side extension
  897. to the IRC protocol that allow users to describe something they
  898. are doing.
  899. ==== CtcpReceived
  900. * Type: IrcEvent, TargetedEvent, SourcedEvent
  901. * Properties:
  902. ** `user`: `User` - the user who sent the CTCP
  903. ** `target`: `String` - the channel or user the CTCP was sent to
  904. ** `type`: `String` - the type of the CTCP
  905. ** `content`: `String` - the (possibly empty) content of the CTCP
  906. Raised in response to a message that contains a CTCP
  907. (client-to-client protocol) message other than an action.
  908. CTCPs have a type, such as `PING`, `VERSION`, and optionally
  909. some content such as a timestamp or nonce when requesting a PING.
  910. KtIrc does not reply to any CTCPs by itself. Replies to CTCPs are
  911. by convention sent to the originating user, even if the CTCP is
  912. sent to a channel.
  913. ==== CtcpReplyReceived
  914. * Type: IrcEvent, TargetedEvent, SourcedEvent
  915. * Properties:
  916. ** `user`: `User` - the user who sent the CTCP reply
  917. ** `target`: `String` - the channel or user the reply was sent to
  918. ** `type`: `String` - the type of the CTCP reply
  919. ** `content`: `String` - the (possibly empty) content of the CTCP reply
  920. Raised in response to a notice that contains a CTCP
  921. (client-to-client protocol) reply. This usually occurs after we
  922. have issued a CTCP request to a user or channel, and the `content`
  923. argument will contain the remote client's response.
  924. Replies to CTCPs are by convention sent to the originating user,
  925. even if the CTCP is sent to a channel. The `target` parameter
  926. should therefore be the local user in most cases.
  927. ==== ModeChanged
  928. TODO
  929. === User events
  930. TODO
  931. ==== UserAway
  932. * Type: IrcEvent, SourcedEvent
  933. * Properties:
  934. ** `user`: `User` - the user who has changed their away state
  935. ** `message`: `String?` - the away message, or `null` if the user is back
  936. Raised when we are informed that a user has changed away states. If the server
  937. supports the `away-notify` capability we will receive notifications for all
  938. users in our common channels; otherwise, we will only receive notifications
  939. for our own user.
  940. If the user is away but we don't know the reason for it, the `message`
  941. property will be empty.
  942. For each channel the user is on, a <<ChannelAway>> event will be generated.
  943. ==== UserQuit
  944. TODO
  945. ==== UserNickChanged
  946. * Type: IrcEvent, SourcedEvent
  947. * Properties:
  948. ** `user`: `User` - the user who has changed their nickname
  949. ** `newNick`: `String` - the new nickname of the user
  950. Raised when we are informed that a user has changed nicknames.
  951. For each channel the user is on, a <<ChannelNickChanged>> event will be
  952. generated
  953. TIP: The user property will contain the user's old details, but you will
  954. not be able to access additional information from the <<UserState>> using
  955. these details as KtIrc will have internally renamed the user to use the
  956. new nickname.
  957. ==== UserHostChanged
  958. * Type: IrcEvent, SourcedEvent
  959. * Properties:
  960. ** `user`: `User` - the user who has changed their ident/hostname
  961. ** `newIdent`: `String` - the new ident of the user
  962. ** `newHost`: `String` - the new hostname of the user
  963. Raised when we are informed that a user has changed their ident and/or
  964. hostname. This is only supported by servers with the `chghost` capability.
  965. ==== UserAccountChanged
  966. * Type: IrcEvent, SourcedEvent
  967. * Properties:
  968. ** `user`: `User` - the user who has changed their account
  969. ** `newAccount`: `String?` - the new account of the user
  970. Raised when we are informed that a user has changed their account name.
  971. This is only supported by servers with the `account-notify` capability,
  972. and may occur when the user logs in or out of their account.
  973. If the user is no longer logged in to an account, `newAccount` will be
  974. `null`.
  975. === Other events
  976. ==== PingReceived
  977. * Type: IrcEvent
  978. * Properties:
  979. ** `nonce`: `ByteArray` - the unique data that must be included in the reply
  980. Raised when the IRC server sends a PING message to the client. KtIrc will
  981. automatically reply with an appropriate PONG.
  982. ==== PongReceived
  983. * Type: IrcEvent
  984. * Properties:
  985. ** `nonce`: `ByteArray` - the unique data that was sent in the PING
  986. Raised when the IRC server sends a PONG message to the client. KtIrc can
  987. automatically send pings and handle pongs, see <<Ping timeouts>>.
  988. ==== ServerFeaturesUpdated
  989. * Type: IrcEvent
  990. * Properties:
  991. ** `serverFeatures`: `ServerFeatureMap` - the features supplied by the server
  992. Corresponds to the server sending a single 005 ISUPPORT line. Multiple
  993. events of this type may be raised in quick succession when features are
  994. split over multiple lines.
  995. In general, you should wait for a <<ServerReady>> event and then query the
  996. <<Features>> instead of relying on this event.
  997. ==== ServerCapabilitiesReceived
  998. TODO
  999. ==== ServerCapabilitiesAcknowledged
  1000. TODO
  1001. ==== ServerCapabilitiesFinished
  1002. TODO
  1003. ==== AuthenticationMessage
  1004. TODO
  1005. ==== SaslFinished
  1006. TODO
  1007. ==== SaslMechanismNotAvailableError
  1008. TODO
  1009. ==== BatchStarted
  1010. TODO
  1011. ==== BatchFinished
  1012. TODO
  1013. ==== BatchReceived
  1014. TODO
  1015. ==== NicknameChangeFailed
  1016. * Type: IrcEvent
  1017. * Properties:
  1018. ** `cause`: `NicknameChangeError` - the reason the nickname must be changed
  1019. Raised when the server informs us that our desired nickname is not available
  1020. for some reason. The `cause` parameter will contain a specific reason given
  1021. by the server:
  1022. * `ErroneousNickname` - the nickname is not allowed by the server (e.g. it used
  1023. restricted characters)
  1024. * `AlreadyInUse` - the nickname is already in use
  1025. * `Collision` - the nickname has collided with another somehow
  1026. * `NoNicknameGiven` - no nickname was provided
  1027. ==== NicknameChangeRequired
  1028. * Type: IrcEvent, NicknameChangeFailed
  1029. * Properties:
  1030. ** `cause`: `NicknameChangeError` - the reason the nickname must be changed
  1031. Raised during a connection attempt when there is a problem with the nickname
  1032. that KtIrc was told to use. The exact problem will be detailed in the `cause`
  1033. parameter, and has the same options as the <<NicknameChangeFailed>> event.
  1034. Upon receiving this event, a new nickname MUST be chosen and sent to the
  1035. server with the <<sendNickChange>> method. Failure to do so will result
  1036. in the IRC server terminating the connection.
  1037. WARNING: `NicknameChangeRequired` currently extends `NicknameChangeFailed`
  1038. for backwards compatibility. This will be removed in KtIrc 2.0.0, and
  1039. both events will need to be handled separately.
  1040. == Messages
  1041. TODO
  1042. === sendNickChange
  1043. TODO
  1044. == Utility methods
  1045. TODO
  1046. === IsChannel
  1047. TODO
  1048. === IsLocalClient
  1049. TODO
  1050. === React
  1051. TODO
  1052. === Reply
  1053. TODO
  1054. == IRCv3 support
  1055. The following table shows KtIrc's IRCv3 support as of this release:
  1056. [cols=3,options="header,autowidth"]
  1057. |===
  1058. | Feature
  1059. | Status
  1060. | Notes
  1061. 3+h| Capability negotiation
  1062. | https://ircv3.net/specs/core/capability-negotiation.html[CAP]
  1063. | {set:cellbgcolor:#a7eeaa} Supported
  1064. | {set:cellbgcolor!}
  1065. See <<Supported capabilities>> for the caps KtIrc will negotiate
  1066. | https://ircv3.net/specs/core/capability-negotiation.html#cap-ls-version[CAP 302]
  1067. | {set:cellbgcolor:#a7eeaa} Supported
  1068. | {set:cellbgcolor!}
  1069. See <<Supported capabilities>> for the caps KtIrc will negotiate
  1070. | https://ircv3.net/specs/core/capability-negotiation.html#cap-notify[cap-notify]
  1071. | {set:cellbgcolor:#f7d5d3} No support
  1072. | {set:cellbgcolor!}
  1073. 3+h| Published specifications
  1074. | https://ircv3.net/specs/extensions/account-notify-3.1.html[account-notify] v3.1
  1075. | {set:cellbgcolor:#a7eeaa} Supported
  1076. | {set:cellbgcolor!}
  1077. See <<UserAccountChanged>>
  1078. | https://ircv3.net/specs/extensions/account-tag-3.2.html[account-tag] v3.2
  1079. | {set:cellbgcolor:#a7eeaa} Supported
  1080. | {set:cellbgcolor!}
  1081. Accounts are automatically added to `User` properties in events
  1082. | https://ircv3.net/specs/extensions/away-notify-3.1.html[away-notify] v3.1
  1083. | {set:cellbgcolor:#a7eeaa} Supported
  1084. | {set:cellbgcolor!}
  1085. See <<UserAway>>.
  1086. | https://ircv3.net/specs/extensions/batch-3.2.html[batch] v3.2
  1087. | {set:cellbgcolor:#a7eeaa} Supported
  1088. | {set:cellbgcolor!}
  1089. See <<BatchReceived>>
  1090. | https://ircv3.net/specs/extensions/chghost-3.2.html[chghost] v3.2
  1091. | {set:cellbgcolor:#a7eeaa} Supported
  1092. | {set:cellbgcolor!}
  1093. See <<UserHostChanged>>
  1094. | https://ircv3.net/specs/extensions/echo-message-3.2.html[echo-message] v3.2
  1095. | {set:cellbgcolor:#a7eeaa} Supported
  1096. | {set:cellbgcolor!}
  1097. See also the `alwaysEchoMessages` <<Behaviour>>
  1098. | https://ircv3.net/specs/extensions/extended-join-3.1.html[extended-join] v3.1
  1099. | {set:cellbgcolor:#a7eeaa} Supported
  1100. | {set:cellbgcolor!}
  1101. Additional details are automatically added to `User` properties in events
  1102. | https://ircv3.net/specs/extensions/invite-notify-3.2.html[invite-notify] v3.2
  1103. | {set:cellbgcolor:#f7d5d3} No support
  1104. | {set:cellbgcolor!}
  1105. | https://ircv3.net/specs/extensions/message-tags.html[message-tags]
  1106. | {set:cellbgcolor:#a7eeaa} Supported
  1107. | {set:cellbgcolor!}
  1108. Exposed in the metadata property of <<Events>>
  1109. | https://ircv3.net/specs/core/monitor-3.2.html[monitor]
  1110. | {set:cellbgcolor:#f7d5d3} No support
  1111. | {set:cellbgcolor!}
  1112. | https://ircv3.net/specs/extensions/multi-prefix-3.1.html[multi-prefix] v3.1
  1113. | {set:cellbgcolor:#a7eeaa} Supported
  1114. | {set:cellbgcolor!}
  1115. Automatically included in <<ChannelState>>
  1116. | https://ircv3.net/specs/extensions/sasl-3.1.html[SASL] v3.1
  1117. | {set:cellbgcolor:#a7eeaa} Supported
  1118. | {set:cellbgcolor!}
  1119. See <<SASL configuration>>
  1120. | https://ircv3.net/specs/extensions/sasl-3.2.html[SASL] v3.2
  1121. | {set:cellbgcolor:#eeeeaa} Partial support
  1122. | {set:cellbgcolor!}
  1123. Notifications via `cap-notify` not yet supported. See <<SASL configuration>>
  1124. | https://ircv3.net/specs/extensions/server-time-3.2.html[server-time] v3.2
  1125. | {set:cellbgcolor:#a7eeaa} Supported
  1126. | {set:cellbgcolor!}
  1127. Exposed in the metadata property of <<Events>>
  1128. | https://ircv3.net/specs/extensions/sts.html[sts]
  1129. | {set:cellbgcolor:#f7d5d3} No support
  1130. | {set:cellbgcolor!}
  1131. | https://ircv3.net/specs/extensions/userhost-in-names-3.2.html[userhost-in-names] v3.2
  1132. | {set:cellbgcolor:#a7eeaa} Supported
  1133. | {set:cellbgcolor!}
  1134. Automatically included in <<UserState>>
  1135. | https://ircv3.net/specs/extensions/webirc.html[webirc]
  1136. | {set:cellbgcolor:#f7d5d3} No support
  1137. | {set:cellbgcolor!}
  1138. 3+h| Draft specifications
  1139. | https://github.com/ircv3/ircv3-specifications/pull/363[brb]
  1140. | {set:cellbgcolor:#f7d5d3} No support
  1141. | {set:cellbgcolor!}
  1142. | https://github.com/ircv3/ircv3-specifications/pull/308[channel renaming]
  1143. | {set:cellbgcolor:#f7d5d3} No support
  1144. | {set:cellbgcolor!}
  1145. | https://github.com/ircv3/ircv3-specifications/pull/349[chathistory]
  1146. | {set:cellbgcolor:#f7d5d3} No support
  1147. | {set:cellbgcolor!}
  1148. | https://github.com/ircv3/ircv3-specifications/pull/346[delivered]
  1149. | {set:cellbgcolor:#f7d5d3} No support
  1150. | {set:cellbgcolor!}
  1151. | https://github.com/ircv3/ircv3-specifications/pull/304[editmsg]
  1152. | {set:cellbgcolor:#f7d5d3} No support
  1153. | {set:cellbgcolor!}
  1154. | https://ircv3.net/specs/extensions/labeled-response.html[labeled-response]
  1155. | {set:cellbgcolor:#a7eeaa} Supported
  1156. | {set:cellbgcolor!}
  1157. Exposed in the metadata property of <<Events>>
  1158. | https://ircv3.net/specs/extensions/message-ids.html[message-ids]
  1159. | {set:cellbgcolor:#f7d5d3} No support
  1160. | {set:cellbgcolor!}
  1161. | https://github.com/ircv3/ircv3-specifications/pull/330[migrate]
  1162. | {set:cellbgcolor:#f7d5d3} No support
  1163. | {set:cellbgcolor!}
  1164. | https://ircv3.net/specs/client-tags/react.html[react]
  1165. | {set:cellbgcolor:#eeeeaa} Partial support
  1166. | {set:cellbgcolor!}
  1167. Sending via <<React>> method, no events generated
  1168. | https://github.com/ircv3/ircv3-specifications/pull/347[read]
  1169. | {set:cellbgcolor:#f7d5d3} No support
  1170. | {set:cellbgcolor!}
  1171. | https://github.com/ircv3/ircv3-specifications/pull/276[register]
  1172. | {set:cellbgcolor:#f7d5d3} No support
  1173. | {set:cellbgcolor!}
  1174. | https://ircv3.net/specs/client-tags/reply.html[reply]
  1175. | {set:cellbgcolor:#eeeeaa} Partial support
  1176. | {set:cellbgcolor!}
  1177. Sending via <<Reply>> method, not processed on incoming messages
  1178. | https://github.com/ircv3/ircv3-specifications/pull/306[resume]
  1179. | {set:cellbgcolor:#f7d5d3} No support
  1180. | {set:cellbgcolor!}
  1181. | https://github.com/ircv3/ircv3-specifications/pull/361[setname]
  1182. | {set:cellbgcolor:#f7d5d3} No support
  1183. | {set:cellbgcolor!}
  1184. | https://github.com/ircv3/ircv3-specifications/pull/357[standard replies]
  1185. | {set:cellbgcolor:#f7d5d3} No support
  1186. | {set:cellbgcolor!}
  1187. | https://github.com/ircv3/ircv3-specifications/pull/348[typing]
  1188. | {set:cellbgcolor:#f7d5d3} No support
  1189. | {set:cellbgcolor!}
  1190. 3+h|Vendor specifications
  1191. |===