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 {
103
103
public func sendMessage( message: String , channelID: String ) {
104
104
if ( connected) {
105
105
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
+ }
108
109
}
109
110
}
110
111
}
Original file line number Diff line number Diff line change @@ -26,20 +26,11 @@ import Foundation
26
26
extension Client {
27
27
28
28
//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
-
38
29
public func getChannelIDByName( name: String ) -> String ? {
39
30
return channels. filter { $0. 1 . name == stripString ( name) } . first? . 0
40
31
}
41
32
42
- public func getUserIdByName ( name: String ) -> String ? {
33
+ public func getUserIDByName ( name: String ) -> String ? {
43
34
return users. filter { $0. 1 . name == stripString ( name) } . first? . 0
44
35
}
45
36
@@ -54,13 +45,14 @@ extension Client {
54
45
}
55
46
56
47
//MARK: - Utilities
57
- internal func stripString( var string: String ) -> String {
48
+ internal func stripString( string: String ) -> String ? {
49
+ var strippedString : String ?
58
50
if string [ string. startIndex] == " @ " {
59
- string = string. substringFromIndex ( string. startIndex. advancedBy ( 1 ) )
51
+ strippedString = string. substringFromIndex ( string. startIndex. advancedBy ( 1 ) )
60
52
} else if string [ string. startIndex] == " # " {
61
- string = string. substringFromIndex ( string. startIndex. advancedBy ( 1 ) )
53
+ strippedString = string. substringFromIndex ( string. startIndex. advancedBy ( 1 ) )
62
54
}
63
- return string
55
+ return strippedString
64
56
}
65
57
66
58
}
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ internal class EventDispatcher {
148
148
// Other clients should ignore this event.
149
149
break
150
150
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)
152
152
case . ReconnectURL:
153
153
// The reconnect_url event is currently unsupported and experimental.
154
154
break
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ public struct File {
62
62
internal( set) public var comments = [ String: Comment] ( )
63
63
internal( set) public var reactions = [ String: Reaction] ( )
64
64
65
- init ? ( file: [ String : AnyObject ] ? ) {
65
+ public init ? ( file: [ String : AnyObject ] ? ) {
66
66
id = file ? [ " id " ] as? String
67
67
created = file ? [ " created " ] as? Int
68
68
name = file ? [ " name " ] as? String
@@ -105,7 +105,7 @@ public struct File {
105
105
106
106
}
107
107
108
- init ? ( id: String ? ) {
108
+ internal init ? ( id: String ? ) {
109
109
self . id = id
110
110
created = nil
111
111
name = nil
You can’t perform that action at this time.
0 commit comments