Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a967b8f7d | |||
| 5f53f89693 | |||
| 30d701f6de | |||
| 82e200f4cc | |||
| 6cca5c3956 | |||
| 43f184a8ed | |||
| c5ce209e54 | |||
| fc336cd2ee | |||
| 7138cf3f4f |
@@ -18,6 +18,7 @@ DerivedData
|
||||
*.xcuserstate
|
||||
.build
|
||||
Packages/
|
||||
*.xcodeproj/
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
|
||||
+5
-4
@@ -27,8 +27,9 @@ let package = Package(
|
||||
name: "SlackKit",
|
||||
targets: [],
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/open-swift/C7.git", majorVersion: 0, minor: 5),
|
||||
.Package(url: "https://github.com/czechboy0/Jay.git", majorVersion: 0, minor: 5),
|
||||
.Package(url: "https://github.com/Zewo/WebSocket", majorVersion: 0, minor: 5),
|
||||
]
|
||||
.Package(url: "https://github.com/open-swift/C7.git", majorVersion: 0, minor: 7),
|
||||
.Package(url: "https://github.com/czechboy0/Jay.git", majorVersion: 0, minor: 6),
|
||||
.Package(url: "https://github.com/Zewo/WebSocket", majorVersion: 0, minor: 6),
|
||||
],
|
||||
exclude: ["Examples"]
|
||||
)
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||

|
||||
##iOS/OS X Slack Client Library
|
||||
##Alpha Linux Slack Client Library
|
||||
###Description
|
||||
This is a Slack client library for iOS and OS X written in Swift. It's intended to expose all of the functionality of Slack's [Real Time Messaging API](https://api.slack.com/rtm) as well as the [web APIs](https://api.slack.com/web) that are accessible by [bot users](https://api.slack.com/bot-users).
|
||||
This is a Slack client library for Linux written in Swift. It's intended to expose all of the functionality of Slack's [Real Time Messaging API](https://api.slack.com/rtm) as well as the [web APIs](https://api.slack.com/web) that are accessible by [bot users](https://api.slack.com/bot-users).
|
||||
|
||||
###Disclaimer: The linux version of SlackKit is a pre-release alpha. Feel free to report issues you come across.
|
||||
###Known Issues:
|
||||
- File upload is currently broken.
|
||||
- Attachments are currently broken.
|
||||
###Installation
|
||||
|
||||
####Swift Package Manager
|
||||
Add SlackKit to your Package.swift
|
||||
|
||||
@@ -12,28 +17,36 @@ import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 1)
|
||||
.Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 0, minor: 0)
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Run `swift-build` on your application’s main directory.
|
||||
####Development
|
||||
1. Install Homebrew: `/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
|
||||
2. Install `swiftenv`: `brew install kylef/formulae/swiftenv`
|
||||
3. Configure your shell: `echo 'if which swiftenv > /dev/null; then eval "$(swiftenv init -)"; fi' >> ~/.bash_profile`
|
||||
4. Download and install the latest Zewo compatible snapshot:
|
||||
```
|
||||
swiftenv install DEVELOPMENT-SNAPSHOT-2016-04-12-a
|
||||
swiftenv local DEVELOPMENT-SNAPSHOT-2016-04-12-a
|
||||
```
|
||||
5. Install and Link OpenSSL: `brew install openssl`, `brew link openssl --force`
|
||||
|
||||
####CocoaPods
|
||||
Add the pod to your podfile:
|
||||
To build an application that uses SlackKit in Xcode, simply use SwiftPM:
|
||||
```
|
||||
pod 'SlackKit'
|
||||
```
|
||||
and run
|
||||
```
|
||||
pod install
|
||||
swift build -Xswiftc -I/usr/local/include -Xlinker -L/usr/local/lib -X
|
||||
```
|
||||
|
||||
|
||||
To use the library in your project import it:
|
||||
```
|
||||
import SlackKit
|
||||
```
|
||||
|
||||
####Deployment
|
||||
Deploy your application to Heroku using [this buildpack](https://github.com/pvzig/heroku-buildpack-swift). For more detailed instructions please see [this post](https://medium.com/@pvzig/building-slack-bots-in-swift-b99e243e444c).
|
||||
|
||||
###Usage
|
||||
To use SlackKit you'll need a bearer token which identifies a single user. You can generate a [full access token or create one using OAuth 2](https://api.slack.com/web).
|
||||
|
||||
@@ -47,11 +60,6 @@ If you want to receive messages from the Slack RTM API, connect to it.
|
||||
client.connect()
|
||||
```
|
||||
|
||||
You can also set options for a ping/pong interval, timeout interval, and automatic reconnection:
|
||||
```swift
|
||||
client.connect(pingInterval: 2, timeout: 10, reconnect: false)
|
||||
```
|
||||
|
||||
Once connected, the client will begin to consume any messages sent by the Slack RTM API.
|
||||
|
||||
####Web API Methods
|
||||
@@ -73,7 +81,7 @@ SlackKit currently supports the a subset of the Slack Web APIs that are availabl
|
||||
- files.comments.edit
|
||||
- files.comments.delete
|
||||
- files.delete
|
||||
- files.upload
|
||||
- ~~files.upload~~
|
||||
- groups.close
|
||||
- groups.history
|
||||
- groups.info
|
||||
@@ -216,18 +224,6 @@ func subteamSelfAdded(subteamID: String)
|
||||
func subteamSelfRemoved(subteamID: String)
|
||||
```
|
||||
|
||||
###Examples
|
||||
####Leaderboard
|
||||
Included in the OSX-Sample is an example application of a bot you might make using SlackKit. It’s a basic leaderboard scoring bot, in the spirit of [PlusPlus](https://plusplus.chat).
|
||||
|
||||
To configure it, enter your bot’s API token in `AppDelegate.swift` for the Leaderboard bot:
|
||||
|
||||
```swift
|
||||
let learderboard = Leaderboard(token: "SLACK_AUTH_TOKEN")
|
||||
```
|
||||
|
||||
It adds a point for every `@thing++`, subtracts a point for every `@thing--`, and shows a leaderboard when asked `@botname leaderboard`.
|
||||
|
||||
###Get In Touch
|
||||
[@pvzig](https://twitter.com/pvzig)
|
||||
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// SlackKit.h
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for SlackKit.
|
||||
FOUNDATION_EXPORT double SlackKitVersionNumber;
|
||||
|
||||
//! Project version string for SlackKit.
|
||||
FOUNDATION_EXPORT const unsigned char SlackKitVersionString[];
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:SlackRTMKit.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -1,72 +0,0 @@
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "7C8CB4917A87F5E5383E6800524CC50437576509",
|
||||
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
|
||||
|
||||
},
|
||||
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
|
||||
"7C8CB4917A87F5E5383E6800524CC50437576509" : 0,
|
||||
"15033DFF73D1DAA84A806DC9B6994613D8A2EB4F" : 0,
|
||||
"4B8317071C2E8191C0071D14B19E229FF434BD5B" : 0,
|
||||
"8951CEB15DDB2D711276960E67900B8AA34FF427" : 0,
|
||||
"10A2CB6C4392F0E306FF8D509BE5E88232276EA4" : 0,
|
||||
"269ADF55FAAC04D68303BE30B6BD693E717155DE" : 0,
|
||||
"997F6D72B6636BD16A82A9AFFBB55CCAE1A5596D" : 0,
|
||||
"704B817219E4CBC31AA92368EF54A4E2835A8C3D" : 0
|
||||
},
|
||||
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "06B58BC9-590E-416B-85DA-67AE0673C049",
|
||||
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
|
||||
"7C8CB4917A87F5E5383E6800524CC50437576509" : "SlackKit\/",
|
||||
"15033DFF73D1DAA84A806DC9B6994613D8A2EB4F" : "SlackKit\/Packages\/IP-0.5.0\/",
|
||||
"4B8317071C2E8191C0071D14B19E229FF434BD5B" : "SlackKit\/Packages\/WebSocket-0.5.1\/",
|
||||
"8951CEB15DDB2D711276960E67900B8AA34FF427" : "SlackKit\/Packages\/MediaType-0.5.0\/",
|
||||
"10A2CB6C4392F0E306FF8D509BE5E88232276EA4" : "SlackKit\/Packages\/String-0.5.1\/",
|
||||
"269ADF55FAAC04D68303BE30B6BD693E717155DE" : "SlackKit\/Packages\/CHTTPParser-0.5.0\/",
|
||||
"997F6D72B6636BD16A82A9AFFBB55CCAE1A5596D" : "SlackKit\/Packages\/TCPSSL-0.5.1\/",
|
||||
"704B817219E4CBC31AA92368EF54A4E2835A8C3D" : "SlackKit\/Packages\/POSIX-0.5.0\/"
|
||||
},
|
||||
"DVTSourceControlWorkspaceBlueprintNameKey" : "SlackKit",
|
||||
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
|
||||
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "SlackKit.xcodeproj",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Zewo\/String.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "10A2CB6C4392F0E306FF8D509BE5E88232276EA4"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/VeniceX\/IP.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "15033DFF73D1DAA84A806DC9B6994613D8A2EB4F"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Zewo\/CHTTPParser.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "269ADF55FAAC04D68303BE30B6BD693E717155DE"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Zewo\/WebSocket",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "4B8317071C2E8191C0071D14B19E229FF434BD5B"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Zewo\/POSIX.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "704B817219E4CBC31AA92368EF54A4E2835A8C3D"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/pvzig\/SlackRTMKit.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "7C8CB4917A87F5E5383E6800524CC50437576509"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Zewo\/MediaType.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8951CEB15DDB2D711276960E67900B8AA34FF427"
|
||||
},
|
||||
{
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/VeniceX\/TCPSSL.git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
|
||||
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "997F6D72B6636BD16A82A9AFFBB55CCAE1A5596D"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,467 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "9999"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_C7"
|
||||
BuildableName = "libC7.dylib"
|
||||
BlueprintName = "C7"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_Jay"
|
||||
BuildableName = "libJay.dylib"
|
||||
BlueprintName = "Jay"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "NO"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_JayExample"
|
||||
BuildableName = "JayExample"
|
||||
BlueprintName = "JayExample"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_String"
|
||||
BuildableName = "libString.dylib"
|
||||
BlueprintName = "String"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_StructuredData"
|
||||
BuildableName = "libStructuredData.dylib"
|
||||
BlueprintName = "StructuredData"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_MediaType"
|
||||
BuildableName = "libMediaType.dylib"
|
||||
BlueprintName = "MediaType"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_CURIParser"
|
||||
BuildableName = "libCURIParser.dylib"
|
||||
BlueprintName = "CURIParser"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_URI"
|
||||
BuildableName = "libURI.dylib"
|
||||
BlueprintName = "URI"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_S4"
|
||||
BuildableName = "libS4.dylib"
|
||||
BlueprintName = "S4"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_HTTP"
|
||||
BuildableName = "libHTTP.dylib"
|
||||
BlueprintName = "HTTP"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_CLibvenice"
|
||||
BuildableName = "libCLibvenice.dylib"
|
||||
BlueprintName = "CLibvenice"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_Venice"
|
||||
BuildableName = "libVenice.dylib"
|
||||
BlueprintName = "Venice"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_POSIX"
|
||||
BuildableName = "libPOSIX.dylib"
|
||||
BlueprintName = "POSIX"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_IP"
|
||||
BuildableName = "libIP.dylib"
|
||||
BlueprintName = "IP"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_TCP"
|
||||
BuildableName = "libTCP.dylib"
|
||||
BlueprintName = "TCP"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_CHTTPParser"
|
||||
BuildableName = "libCHTTPParser.dylib"
|
||||
BlueprintName = "CHTTPParser"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_HTTPParser"
|
||||
BuildableName = "libHTTPParser.dylib"
|
||||
BlueprintName = "HTTPParser"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_HTTPSerializer"
|
||||
BuildableName = "libHTTPSerializer.dylib"
|
||||
BlueprintName = "HTTPSerializer"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_HTTPClient"
|
||||
BuildableName = "libHTTPClient.dylib"
|
||||
BlueprintName = "HTTPClient"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_File"
|
||||
BuildableName = "libFile.dylib"
|
||||
BlueprintName = "File"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_OpenSSL"
|
||||
BuildableName = "libOpenSSL.dylib"
|
||||
BlueprintName = "OpenSSL"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_TCPSSL"
|
||||
BuildableName = "libTCPSSL.dylib"
|
||||
BlueprintName = "TCPSSL"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_HTTPSClient"
|
||||
BuildableName = "libHTTPSClient.dylib"
|
||||
BlueprintName = "HTTPSClient"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_Event"
|
||||
BuildableName = "libEvent.dylib"
|
||||
BlueprintName = "Event"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_Base64"
|
||||
BuildableName = "libBase64.dylib"
|
||||
BlueprintName = "Base64"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_WebSocket"
|
||||
BuildableName = "libWebSocket.dylib"
|
||||
BlueprintName = "WebSocket"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "NO"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_Botly"
|
||||
BuildableName = "Botly"
|
||||
BlueprintName = "Botly"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_SlackKit"
|
||||
BuildableName = "libSlackKit.dylib"
|
||||
BlueprintName = "SlackKit"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_C7"
|
||||
BuildableName = "libC7.dylib"
|
||||
BlueprintName = "C7"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_C7"
|
||||
BuildableName = "libC7.dylib"
|
||||
BlueprintName = "C7"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "______Target_C7"
|
||||
BuildableName = "libC7.dylib"
|
||||
BlueprintName = "C7"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>SchemeUserState</key>
|
||||
<dict>
|
||||
<key>SlackKit.xcscheme</key>
|
||||
<dict></dict>
|
||||
</dict>
|
||||
<key>SuppressBuildableAutocreation</key>
|
||||
<dict></dict>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// SlackKit.h
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for SlackKit.
|
||||
FOUNDATION_EXPORT double SlackKitVersionNumber;
|
||||
|
||||
//! Project version string for SlackKit.
|
||||
FOUNDATION_EXPORT const unsigned char SlackKitVersionString[];
|
||||
@@ -48,7 +48,7 @@ public struct Attachment {
|
||||
text = attachment?["text"] as? String
|
||||
imageURL = attachment?["image_url"] as? String
|
||||
thumbURL = attachment?["thumb_url"] as? String
|
||||
fields = (attachment?["fields"] as? [[String: Any]])?.objectArrayFromDictionaryArray(intializer: {(field) -> AttachmentField? in
|
||||
fields = (attachment?["fields"] as? [Any])?.objectArrayFromDictionaryArray(intializer: {(field) -> AttachmentField? in
|
||||
return AttachmentField(field: field)
|
||||
})
|
||||
}
|
||||
@@ -85,8 +85,8 @@ public struct Attachment {
|
||||
return attachment
|
||||
}
|
||||
|
||||
private func fieldJSONArray(fields: [AttachmentField]?) -> [[String: Any]] {
|
||||
var returnValue = [[String: Any]]()
|
||||
private func fieldJSONArray(fields: [AttachmentField]?) -> [Any] {
|
||||
var returnValue = [Any]()
|
||||
if let f = fields {
|
||||
for field in f {
|
||||
returnValue.append(field.dictionary())
|
||||
|
||||
@@ -225,9 +225,9 @@ public class SlackClient {
|
||||
|
||||
private func enumerateSubteams(subteams: [String: Any]?) {
|
||||
if let subteams = subteams {
|
||||
if let all = subteams["all"] as? [[String: Any]] {
|
||||
if let all = subteams["all"] as? [Any] {
|
||||
for item in all {
|
||||
let u = UserGroup(userGroup: item)
|
||||
let u = UserGroup(userGroup: item as? [String: Any])
|
||||
self.userGroups[u!.id!] = u
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ extension SlackClient {
|
||||
internal func stripString(string: String) -> String? {
|
||||
var strippedString = string
|
||||
if string[string.startIndex] == "@" || string[string.startIndex] == "#" {
|
||||
strippedString.characters.remove(at: string.startIndex.advanced(by:1))
|
||||
strippedString.characters.remove(at: string.startIndex)
|
||||
}
|
||||
return strippedString
|
||||
}
|
||||
|
||||
@@ -144,7 +144,6 @@ internal struct Event {
|
||||
let emailDomain: String?
|
||||
let reaction: String?
|
||||
let replyTo: Double?
|
||||
let reactions: [[String: Any]]?
|
||||
let edited: Edited?
|
||||
let bot: Bot?
|
||||
let channel: Channel?
|
||||
@@ -186,7 +185,6 @@ internal struct Event {
|
||||
emailDomain = event["email_domain"] as? String
|
||||
reaction = event["reaction"] as? String
|
||||
replyTo = event["reply_to"] as? Double
|
||||
reactions = event["reactions"] as? [[String: Any]]
|
||||
bot = Bot(bot: event["bot"] as? [String: Any])
|
||||
edited = Edited(edited:event["edited"] as? [String: Any])
|
||||
dndStatus = DoNotDisturbStatus(status: event["dnd_status"] as? [String: Any])
|
||||
|
||||
@@ -99,7 +99,7 @@ public struct File {
|
||||
stars = file?["num_stars"] as? Int
|
||||
isStarred = file?["is_starred"] as? Bool
|
||||
pinnedTo = file?["pinned_to"] as? [String]
|
||||
if let reactions = file?["reactions"] as? [[String: Any]] {
|
||||
if let reactions = file?["reactions"] as? [Any] {
|
||||
self.reactions = Reaction.reactionsFromArray(array: reactions)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,8 +70,8 @@ public class Message {
|
||||
pinnedTo = message?["pinned_to"] as? [String]
|
||||
comment = Comment(comment: message?["comment"] as? [String: Any])
|
||||
file = File(file: message?["file"] as? [String: Any])
|
||||
reactions = messageReactions(reactions: message?["reactions"] as? [[String: Any]])
|
||||
attachments = (message?["attachments"] as? [[String: Any]])?.objectArrayFromDictionaryArray(intializer: {(attachment) -> Attachment? in
|
||||
reactions = messageReactions(reactions: message?["reactions"] as? [Any])
|
||||
attachments = (message?["attachments"] as? [Any])?.objectArrayFromDictionaryArray(intializer: {(attachment) -> Attachment? in
|
||||
return Attachment(attachment: attachment)
|
||||
})
|
||||
}
|
||||
@@ -91,11 +91,11 @@ public class Message {
|
||||
file = nil
|
||||
}
|
||||
|
||||
private func messageReactions(reactions: [[String: Any]]?) -> [String: Reaction] {
|
||||
private func messageReactions(reactions: [Any]?) -> [String: Reaction] {
|
||||
var returnValue = [String: Reaction]()
|
||||
if let r = reactions {
|
||||
for react in r {
|
||||
if let reaction = Reaction(reaction: react), reactionName = reaction.name {
|
||||
if let reaction = Reaction(reaction: react as? [String: Any]), reactionName = reaction.name {
|
||||
returnValue[reactionName] = reaction
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
import HTTPSClient
|
||||
import Jay
|
||||
|
||||
@@ -72,44 +71,6 @@ internal struct NetworkInterface {
|
||||
}
|
||||
}
|
||||
|
||||
internal func postRequest(endpoint: SlackAPIEndpoint, token: String, parameters: [String: Any]?, successClosure: ([String: Any])->Void, errorClosure: (SlackError)->Void) {
|
||||
let requestString = "\(apiUrl)\(endpoint.rawValue)?token=\(token)"
|
||||
do {
|
||||
var response: Response?
|
||||
let headers: Headers = ["Content-Type": "application/x-www-form-urlencoded"]
|
||||
var body = ""
|
||||
if let params = parameters {
|
||||
body = requestStringFromParameters(parameters: params)
|
||||
} else {
|
||||
body = ""
|
||||
}
|
||||
|
||||
response = try client?.post(requestString, headers: headers, body: body)
|
||||
|
||||
let data = try response?.body.becomeBuffer()
|
||||
if let data = data {
|
||||
let json = try Jay().jsonFromData(data.bytes)
|
||||
if let result = json as? [String: Any] {
|
||||
if (result["ok"] as? Bool == true) {
|
||||
successClosure(result)
|
||||
} else {
|
||||
if let errorString = result["error"] as? String {
|
||||
throw ErrorDispatcher.dispatch(error: errorString)
|
||||
} else {
|
||||
throw SlackError.UnknownError
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch let error {
|
||||
if let slackError = error as? SlackError {
|
||||
errorClosure(slackError)
|
||||
} else {
|
||||
errorClosure(SlackError.UnknownError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Currently Unsupported
|
||||
/*internal func uploadRequest(token: String, data: NSData, parameters: [String: Any]?, successClosure: ([String: Any])->Void, errorClosure: (SlackError)->Void) {
|
||||
var requestString = "\(apiUrl)\(SlackAPIEndpoint.FilesUpload.rawValue)?token=\(token)"
|
||||
@@ -171,17 +132,16 @@ internal struct NetworkInterface {
|
||||
var requestString = ""
|
||||
for key in parameters.keys {
|
||||
if let value = parameters[key] as? String {
|
||||
#if os(Linux)
|
||||
if let encodedValue = value.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()) {
|
||||
requestString += "&\(key)=\(encodedValue)"
|
||||
}
|
||||
#else
|
||||
if let encodedValue = value.addingPercentEncoding(withAllowedCharacters: NSCharacterSet.urlQueryAllowed()) {
|
||||
requestString += "&\(key)=\(encodedValue)"
|
||||
}
|
||||
#endif
|
||||
do {
|
||||
let encodedValue = try value.percentEncoded(allowing: .uriQueryAllowed)
|
||||
requestString += "&\(key)=\(encodedValue)"
|
||||
} catch _ {
|
||||
print("Error encoding parameters.")
|
||||
}
|
||||
} else if let value = parameters[key] as? Int {
|
||||
requestString += "&\(key)=\(value)"
|
||||
} else if let value = parameters[key] as? Bool {
|
||||
requestString += "&\(key)=\(value)"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ public class SlackWebAPI {
|
||||
|
||||
public func sendMessage(channel: 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?) {
|
||||
let parameters: [String: Any?] = ["channel":channel, "text":text.slackFormatEscaping(), "as_user":asUser, "parse":parse?.rawValue, "link_names":linkNames, "unfurl_links":unfurlLinks, "unfurlMedia":unfurlMedia, "username":username, "attachments":encodeAttachments(attachments: attachments), "icon_url":iconURL, "icon_emoji":iconEmoji]
|
||||
client.api.postRequest(endpoint: .ChatPostMessage, token: client.token, parameters: filterNilParameters(parameters: parameters), successClosure: {
|
||||
client.api.request(endpoint: .ChatPostMessage, token: client.token, parameters: filterNilParameters(parameters: parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?((ts: response["ts"] as? String, response["channel"] as? String))
|
||||
}) {(error) -> Void in
|
||||
@@ -207,7 +207,7 @@ public class SlackWebAPI {
|
||||
|
||||
public func updateMessage(channel: String, ts: String, message: String, attachments: [Attachment?]? = nil, parse:ParseMode = .None, linkNames: Bool = false, success: ((updated: Bool)->Void)?, failure: FailureClosure?) {
|
||||
let parameters: [String: Any?] = ["channel": channel, "ts": ts, "text": message.slackFormatEscaping(), "parse": parse.rawValue, "link_names": linkNames, "attachments":encodeAttachments(attachments: attachments)]
|
||||
client.api.postRequest(endpoint: .ChatUpdate, token: client.token, parameters: filterNilParameters(parameters: parameters), successClosure: {
|
||||
client.api.request(endpoint: .ChatUpdate, token: client.token, parameters: filterNilParameters(parameters: parameters), successClosure: {
|
||||
(response) -> Void in
|
||||
success?(updated: true)
|
||||
}) {(error) -> Void in
|
||||
@@ -696,7 +696,7 @@ public class SlackWebAPI {
|
||||
//MARK: - Encode Attachments
|
||||
private func encodeAttachments(attachments: [Attachment?]?) -> String? {
|
||||
if let attachments = attachments {
|
||||
var attachmentArray: [[String: Any]] = []
|
||||
var attachmentArray: [Any] = []
|
||||
for attachment in attachments {
|
||||
if let attachment = attachment {
|
||||
attachmentArray.append(attachment.dictionary())
|
||||
|
||||
@@ -73,17 +73,19 @@ public struct Reaction {
|
||||
self.users = users
|
||||
}
|
||||
|
||||
static func reactionsFromArray(array: [[String: Any]]) -> [String: Reaction] {
|
||||
static func reactionsFromArray(array: [Any]) -> [String: Reaction] {
|
||||
var reactions = [String: Reaction]()
|
||||
var userDictionary = [String: String]()
|
||||
for reaction in array {
|
||||
if let users = reaction["users"] as? [String] {
|
||||
for user in users {
|
||||
userDictionary[user] = user
|
||||
for r in array {
|
||||
if let reaction = r as? [String: Any] {
|
||||
if let users = reaction["users"] as? [String] {
|
||||
for user in users {
|
||||
userDictionary[user] = user
|
||||
}
|
||||
}
|
||||
if let name = reaction["name"] as? String {
|
||||
reactions[name] = Reaction(name: name, users: userDictionary)
|
||||
}
|
||||
}
|
||||
if let name = reaction["name"] as? String {
|
||||
reactions[name] = Reaction(name: name, users: userDictionary)
|
||||
}
|
||||
}
|
||||
return reactions
|
||||
|
||||
Reference in New Issue
Block a user