Browse Source

Add sendPart

tags/v0.10.1
Chris Smith 5 years ago
parent
commit
fb92bd5737

+ 2
- 1
CHANGELOG View File

1
 vNEXT (in development)
1
 vNEXT (in development)
2
 
2
 
3
-* Added NickChangeFailed event for when nicknames are in use, banned, etc
3
+ * Added NickChangeFailed event for when nicknames are in use, banned, etc
4
+ * Added sendPart method
4
  * (Internal) Moved message processors into their own package
5
  * (Internal) Moved message processors into their own package
5
 
6
 
6
 v0.10.0
7
 v0.10.0

+ 6
- 1
src/main/kotlin/com/dmdirc/ktirc/messages/MessageBuilders.kt View File

10
 internal fun IrcClient.sendCapabilityEnd() = send("CAP", "END")
10
 internal fun IrcClient.sendCapabilityEnd() = send("CAP", "END")
11
 
11
 
12
 /** Sends a message requesting the specified caps are enabled. */
12
 /** Sends a message requesting the specified caps are enabled. */
13
-internal fun IrcClient.sendCapabilityRequest(capabilities: Collection<String>) = send("CAP", "REQ", capabilities.joinToString(" "))
13
+internal fun IrcClient.sendCapabilityRequest(capabilities: Collection<String>) =
14
+        send("CAP", "REQ", capabilities.joinToString(" "))
14
 
15
 
15
 /** Sends a request to join the given channel. */
16
 /** Sends a request to join the given channel. */
16
 fun IrcClient.sendJoin(channel: String) = send("JOIN", channel)
17
 fun IrcClient.sendJoin(channel: String) = send("JOIN", channel)
17
 
18
 
19
+/** Sends a request to part the given channel. */
20
+fun IrcClient.sendPart(channel: String, reason: String? = null) =
21
+        reason?.let { send("PART", channel, reason) } ?: send("PART", channel)
22
+
18
 /** Sends a request to see the modes of a given target. */
23
 /** Sends a request to see the modes of a given target. */
19
 fun IrcClient.sendModeRequest(target: String) = send("MODE", target)
24
 fun IrcClient.sendModeRequest(target: String) = send("MODE", target)
20
 
25
 

+ 12
- 0
src/test/kotlin/com/dmdirc/ktirc/messages/MessageBuildersTest.kt View File

28
         verify { mockClient.send("JOIN", "#TheGibson") }
28
         verify { mockClient.send("JOIN", "#TheGibson") }
29
     }
29
     }
30
 
30
 
31
+    @Test
32
+    fun `sendPart sends correct PART message without reason`() {
33
+        mockClient.sendPart("#TheGibson")
34
+        verify { mockClient.send("PART", "#TheGibson") }
35
+    }
36
+
37
+    @Test
38
+    fun `sendPart sends correct PART message with reason`() {
39
+        mockClient.sendPart("#TheGibson", "Mess with the best...")
40
+        verify { mockClient.send("PART", "#TheGibson", "Mess with the best...") }
41
+    }
42
+
31
     @Test
43
     @Test
32
     fun `sendModeRequest sends correct MODE message`() {
44
     fun `sendModeRequest sends correct MODE message`() {
33
         mockClient.sendModeRequest("#TheGibson")
45
         mockClient.sendModeRequest("#TheGibson")

Loading…
Cancel
Save