Browse Source

Add sendPart

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

+ 2
- 1
CHANGELOG View File

@@ -1,6 +1,7 @@
1 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 5
  * (Internal) Moved message processors into their own package
5 6
 
6 7
 v0.10.0

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

@@ -10,11 +10,16 @@ internal fun IrcClient.sendCapabilityList() = send("CAP", "LS", "302")
10 10
 internal fun IrcClient.sendCapabilityEnd() = send("CAP", "END")
11 11
 
12 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 16
 /** Sends a request to join the given channel. */
16 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 23
 /** Sends a request to see the modes of a given target. */
19 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,6 +28,18 @@ internal class MessageBuildersTest {
28 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 43
     @Test
32 44
     fun `sendModeRequest sends correct MODE message`() {
33 45
         mockClient.sendModeRequest("#TheGibson")

Loading…
Cancel
Save