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

Commit 5f15ba6

Browse files
authored
Merge pull request #3 from johntmcintosh/threads
Add support for sending a threaded message to the WebAPI
2 parents 22d2b69 + 41b3a7b commit 5f15ba6

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/WebAPI.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,15 @@ public final class WebAPI {
217217
}
218218
}
219219

220+
public func sendThreadedMessage(channel: String, thread: String, text: String, username: String? = nil, asUser: Bool? = nil, parse: ParseMode? = nil, linkNames: Bool? = nil, attachments: [Attachment?]? = nil, unfurlLinks: Bool? = nil, unfurlMedia: Bool? = nil, iconURL: String? = nil, iconEmoji: String? = nil, success: (((ts: String?, channel: String?))->Void)?, failure: FailureClosure?) {
221+
let parameters: [String: Any?] = ["token": token, "channel": channel, "thread_ts": thread, "text": text.slackFormatEscaping, "as_user": asUser, "parse": parse?.rawValue, "link_names": linkNames, "unfurl_links": unfurlLinks, "unfurlMedia": unfurlMedia, "username": username, "icon_url": iconURL, "icon_emoji": iconEmoji, "attachments": encodeAttachments(attachments)]
222+
networkInterface.request(.chatPostMessage, parameters: parameters, successClosure: {(response) in
223+
success?((ts: response["ts"] as? String, response["channel"] as? String))
224+
}) {(error) in
225+
failure?(error)
226+
}
227+
}
228+
220229
public func sendMeMessage(channel: String, text: String, success: (((ts: String?, channel: String?))->Void)?, failure: FailureClosure?) {
221230
let parameters: [String: Any?] = ["token": token, "channel": channel, "text": text.slackFormatEscaping]
222231
networkInterface.request(.chatMeMessage, parameters: parameters, successClosure: {(response) in

0 commit comments

Comments
 (0)