This repository was archived by the owner on Dec 2, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +12
-19
lines changed Expand file tree Collapse file tree 4 files changed +12
-19
lines changed Original file line number Diff line number Diff line change @@ -103,8 +103,9 @@ public class Client: WebSocketDelegate {
103103 public func sendMessage( message: String , channelID: String ) {
104104 if ( connected) {
105105 if let data = formatMessageToSlackJsonString ( msg: message, channel: channelID) {
106- let string = NSString ( data: data, encoding: NSUTF8StringEncoding)
107- webSocket? . writeString ( string as! String )
106+ if let string = NSString ( data: data, encoding: NSUTF8StringEncoding) as? String {
107+ webSocket? . writeString ( string)
108+ }
108109 }
109110 }
110111 }
Original file line number Diff line number Diff line change @@ -26,20 +26,11 @@ import Foundation
2626extension Client {
2727
2828 //MARK: - User & Channel
29- public func getChannelOrUserIdByName( name: String ) -> String ? {
30- if ( name [ name. startIndex] == " @ " ) {
31- return getUserIdByName ( name)
32- } else if ( name [ name. startIndex] == " C " ) {
33- return getChannelIDByName ( name)
34- }
35- return nil
36- }
37-
3829 public func getChannelIDByName( name: String ) -> String ? {
3930 return channels. filter { $0. 1 . name == stripString ( name) } . first? . 0
4031 }
4132
42- public func getUserIdByName ( name: String ) -> String ? {
33+ public func getUserIDByName ( name: String ) -> String ? {
4334 return users. filter { $0. 1 . name == stripString ( name) } . first? . 0
4435 }
4536
@@ -54,13 +45,14 @@ extension Client {
5445 }
5546
5647 //MARK: - Utilities
57- internal func stripString( var string: String ) -> String {
48+ internal func stripString( string: String ) -> String ? {
49+ var strippedString : String ?
5850 if string [ string. startIndex] == " @ " {
59- string = string. substringFromIndex ( string. startIndex. advancedBy ( 1 ) )
51+ strippedString = string. substringFromIndex ( string. startIndex. advancedBy ( 1 ) )
6052 } else if string [ string. startIndex] == " # " {
61- string = string. substringFromIndex ( string. startIndex. advancedBy ( 1 ) )
53+ strippedString = string. substringFromIndex ( string. startIndex. advancedBy ( 1 ) )
6254 }
63- return string
55+ return strippedString
6456 }
6557
6658}
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ internal class EventDispatcher {
148148 // Other clients should ignore this event.
149149 break
150150 case . TeamMigrationStarted:
151- client. connect ( client. pingInterval, timeout: client. timeout, reconnect: client. reconnect)
151+ client. connect ( pingInterval : client. pingInterval, timeout: client. timeout, reconnect: client. reconnect)
152152 case . ReconnectURL:
153153 // The reconnect_url event is currently unsupported and experimental.
154154 break
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ public struct File {
6262 internal( set) public var comments = [ String: Comment] ( )
6363 internal( set) public var reactions = [ String: Reaction] ( )
6464
65- init ? ( file: [ String : AnyObject ] ? ) {
65+ public init ? ( file: [ String : AnyObject ] ? ) {
6666 id = file ? [ " id " ] as? String
6767 created = file ? [ " created " ] as? Int
6868 name = file ? [ " name " ] as? String
@@ -105,7 +105,7 @@ public struct File {
105105
106106 }
107107
108- init ? ( id: String ? ) {
108+ internal init ? ( id: String ? ) {
109109 self . id = id
110110 created = nil
111111 name = nil
You can’t perform that action at this time.
0 commit comments