Skip to content
This repository was archived by the owner on Jan 28, 2019. It is now read-only.

Commit 2da959c

Browse files
jack-stripepvzig
authored andcommitted
add optional id parameter to sendMessage
1 parent 0343045 commit 2da959c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/SKRTMAPI/SKRTMAPI.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ public final class SKRTMAPI: RTMDelegate {
107107
rtm.disconnect()
108108
}
109109

110-
public func sendMessage(_ message: String, channelID: String) throws {
110+
public func sendMessage(_ message: String, channelID: String, id: String? = nil) throws {
111111
guard connected else {
112112
throw SlackError.rtmConnectionError
113113
}
114114
do {
115-
let string = try format(message: message, channel: channelID)
115+
let string = try format(message: message, channel: channelID, id: id)
116116
try rtm.sendMessage(string)
117117
} catch let error {
118118
throw error
@@ -142,9 +142,9 @@ public final class SKRTMAPI: RTMDelegate {
142142
self.adapter?.initialSetup(json: response, instance: self)
143143
}
144144

145-
private func format(message: String, channel: String, threadTs: String? = nil, broadcastReply: Bool = false) throws -> String {
145+
private func format(message: String, channel: String, id: String? = nil, threadTs: String? = nil, broadcastReply: Bool = false) throws -> String {
146146
let json: [String: Any?] = [
147-
"id": Date().slackTimestamp,
147+
"id": id ?? Date().slackTimestamp,
148148
"type": "message",
149149
"channel": channel,
150150
"text": message.slackFormatEscaping,

0 commit comments

Comments
 (0)