@@ -94,25 +94,38 @@ public final class SKRTMAPI: RTMDelegate {
9494 rtm. disconnect ( )
9595 }
9696
97- public func sendMessage( _ message: String , channelID: String , threadTs : String ? = nil ) throws {
97+ public func sendMessage( _ message: String , channelID: String ) throws {
9898 guard connected else {
9999 throw SlackError . rtmConnectionError
100100 }
101101 do {
102- let string = try format ( message: message, channel: channelID, threadTs : threadTs )
102+ let string = try format ( message: message, channel: channelID)
103103 try rtm. sendMessage ( string)
104104 } catch let error {
105105 throw error
106106 }
107107 }
108108
109- private func format( message: String , channel: String , threadTs: String ? ) throws -> String {
109+ public func sendThreadedMessage( _ message: String , channelID: String , threadTs: String , broadcastReply: Bool = false ) throws {
110+ guard connected else {
111+ throw SlackError . rtmConnectionError
112+ }
113+ do {
114+ let string = try format ( message: message, channel: channelID, threadTs: threadTs, broadcastReply: broadcastReply)
115+ try rtm. sendMessage ( string)
116+ } catch let error {
117+ throw error
118+ }
119+ }
120+
121+ private func format( message: String , channel: String , threadTs: String ? = nil , broadcastReply: Bool = false ) throws -> String {
110122 let json : [ String : Any ? ] = [
111123 " id " : Date ( ) . slackTimestamp,
112124 " type " : " message " ,
113125 " channel " : channel,
114126 " text " : message. slackFormatEscaping,
115- " thread_ts " : threadTs
127+ " thread_ts " : threadTs,
128+ " broadcastReply " : broadcastReply
116129 ]
117130 guard
118131 let data = try ? JSONSerialization . data ( withJSONObject: filterNilParameters ( json) , options: [ ] ) ,
0 commit comments