Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b00bf0b2a3 | |||
| b877fac99b | |||
| f50107f261 | |||
| 0274f5842e | |||
| a9708d001a | |||
| 465a3860ee | |||
| 9bf2961dc7 | |||
| d81f2ab221 | |||
| 337e3b7709 | |||
| f50efd5f7a | |||
| f80dcf4ae9 | |||
| 13b8b36c10 | |||
| 696da2722b | |||
| 461115f6d3 | |||
| 38aaedee2a | |||
| 98a3973ab0 | |||
| 846bc84035 | |||
| 283e3c0614 | |||
| 44568d407c | |||
| b8f20d7397 | |||
| 2770499879 | |||
| 38e64939f1 | |||
| 71f066a6f8 | |||
| 4e87bea2fa | |||
| 3d6516922f | |||
| 1b98af2b11 | |||
| 750604a801 | |||
| 47f5d040a2 | |||
| 3c34557617 | |||
| d60b8bf88a | |||
| f2f95b7a26 | |||
| c4b38dbc14 | |||
| 7fffbc8dba | |||
| ab39fda0f5 | |||
| 11e9f2e9ab | |||
| a93b4b7966 | |||
| b639fff78e | |||
| 6075577ec5 | |||
| 7a967b8f7d | |||
| 5f53f89693 | |||
| 30d701f6de | |||
| 82e200f4cc | |||
| 6cca5c3956 | |||
| 43f184a8ed | |||
| c5ce209e54 | |||
| fc336cd2ee | |||
| 7138cf3f4f | |||
| 00b2605a37 | |||
| 2561e8ba48 | |||
| 00b0823dbd | |||
| b88ef3638c | |||
| 1675aa82fb | |||
| 01be45e979 | |||
| dc3336a807 | |||
| 5962ce5115 | |||
| db6bf52eaa | |||
| 32ae1ed7a2 | |||
| 2e4b4390b3 | |||
| 07861887f1 | |||
| 1c9b7bb011 | |||
| 59e1e8856d | |||
| 76b33dba0e | |||
| 6040d8deaa |
+5
-5
@@ -16,10 +16,10 @@ DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
|
||||
# SwiftPM
|
||||
Packages/
|
||||
.build
|
||||
Packages/
|
||||
*.xcodeproj/
|
||||
*.DS_Store
|
||||
|
||||
# CocoaPods
|
||||
#
|
||||
@@ -28,10 +28,10 @@ Packages/
|
||||
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
|
||||
#
|
||||
Pods/
|
||||
SlackKit.xcworkspace
|
||||
|
||||
# Carthage
|
||||
#
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
Carthage/Checkouts
|
||||
# Carthage/Checkouts
|
||||
|
||||
Carthage/Build
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
3.0.2
|
||||
@@ -1 +0,0 @@
|
||||
github "daltoniam/Starscream" "1.1.3"
|
||||
@@ -0,0 +1,9 @@
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "echobot",
|
||||
targets: [],
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 0, minor: 0),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,35 @@
|
||||
import Foundation
|
||||
import SlackKit
|
||||
|
||||
class Echobot: MessageEventsDelegate {
|
||||
|
||||
let client: SlackClient
|
||||
|
||||
init(token: String) {
|
||||
client = SlackClient(apiToken: token)
|
||||
client.messageEventsDelegate = self
|
||||
}
|
||||
|
||||
// MARK: MessageEventsDelegate
|
||||
func sent(_ message: Message, client: SlackClient) {}
|
||||
func changed(_ message: Message, client: SlackClient) {}
|
||||
func deleted(_ message: Message?, client: SlackClient) {}
|
||||
func received(_ message: Message, client: SlackClient) {
|
||||
listen(message: message)
|
||||
}
|
||||
|
||||
// MARK: Echobot Internal Logic
|
||||
private func listen(message: Message) {
|
||||
if let channel = message.channel, let text = message.text, let id = client.authenticatedUser?.id {
|
||||
if id != message.user && message.user != nil {
|
||||
client.webAPI.sendMessage(channel:channel, text: text, linkNames: true, success: {(response) in
|
||||
}, failure: { (error) in
|
||||
print("Echobot failed to reply due to error:\(error)")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let echobot = Echobot(token: "xoxb-SLACK_API_TOKEN")
|
||||
echobot.client.connect()
|
||||
@@ -0,0 +1,8 @@
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "leaderboard",
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 0, minor: 0),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,141 @@
|
||||
import Foundation
|
||||
import SlackKit
|
||||
|
||||
class Leaderboard: MessageEventsDelegate {
|
||||
|
||||
var leaderboard: [String: Int] = [String: Int]()
|
||||
let atSet = CharacterSet(charactersIn: "@")
|
||||
|
||||
let client: SlackClient
|
||||
|
||||
init(token: String) {
|
||||
client = SlackClient(apiToken: token)
|
||||
client.messageEventsDelegate = self
|
||||
}
|
||||
|
||||
enum Command: String {
|
||||
case leaderboard = "leaderboard"
|
||||
}
|
||||
|
||||
enum Trigger: String {
|
||||
case plusPlus = "++"
|
||||
case minusMinus = "--"
|
||||
}
|
||||
|
||||
// MARK: MessageEventsDelegate
|
||||
func sent(_ message: Message, client: SlackClient) {}
|
||||
func changed(_ message: Message, client: SlackClient) {}
|
||||
func deleted(_ message: Message?, client: SlackClient) {}
|
||||
func received(_ message: Message, client: SlackClient) {
|
||||
listen(message: message)
|
||||
}
|
||||
|
||||
// MARK: Leaderboard Internal Logic
|
||||
private func listen(message: Message) {
|
||||
if let id = client.authenticatedUser?.id, let text = message.text {
|
||||
if text.lowercased().contains(Command.leaderboard.rawValue) && text.contains(id) {
|
||||
handleCommand(command: .leaderboard, channel: message.channel)
|
||||
}
|
||||
}
|
||||
if message.text?.contains(Trigger.plusPlus.rawValue) == true {
|
||||
handleMessageWithTrigger(message: message, trigger: .plusPlus)
|
||||
}
|
||||
if message.text?.contains(Trigger.minusMinus.rawValue) == true {
|
||||
handleMessageWithTrigger(message: message, trigger: .minusMinus)
|
||||
}
|
||||
}
|
||||
|
||||
private func handleMessageWithTrigger(message: Message, trigger: Trigger) {
|
||||
if let text = message.text, let start = text.range(of: "@")?.lowerBound, let end = text.range(of: trigger.rawValue)?.lowerBound {
|
||||
let string = String(text.characters[start...end].dropLast().dropFirst())
|
||||
let users = client.users.values.filter{$0.id == self.userID(string: string)}
|
||||
if users.count > 0 {
|
||||
let idString = userID(string: string)
|
||||
initalizationForValue(dictionary: &leaderboard, value: idString)
|
||||
scoringForValue(dictionary: &leaderboard, value: idString, trigger: trigger)
|
||||
} else {
|
||||
initalizationForValue(dictionary: &leaderboard, value: string)
|
||||
scoringForValue(dictionary: &leaderboard, value: string, trigger: trigger)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleCommand(command: Command, channel:String?) {
|
||||
switch command {
|
||||
case .leaderboard:
|
||||
if let id = channel {
|
||||
client.webAPI.sendMessage(channel:id, text: "Leaderboard", linkNames: true, attachments: [constructLeaderboardAttachment()], success: {(response) in
|
||||
print(response)
|
||||
}, failure: { (error) in
|
||||
print("Leaderboard failed to post due to error:\(error)")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func initalizationForValue( dictionary: inout [String: Int], value: String) {
|
||||
if dictionary[value] == nil {
|
||||
dictionary[value] = 0
|
||||
}
|
||||
}
|
||||
|
||||
private func scoringForValue( dictionary: inout [String: Int], value: String, trigger: Trigger) {
|
||||
switch trigger {
|
||||
case .plusPlus:
|
||||
dictionary[value]?+=1
|
||||
case .minusMinus:
|
||||
dictionary[value]?-=1
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Leaderboard Interface
|
||||
private func constructLeaderboardAttachment() -> Attachment? {
|
||||
let 💯 = AttachmentField(title: "💯", value: swapIDsForNames(string: topItems(dictionary: &leaderboard)), short: true)
|
||||
let 💩 = AttachmentField(title: "💩", value: swapIDsForNames(string: bottomItems(dictionary: &leaderboard)), short: true)
|
||||
return Attachment(fallback: "Leaderboard", title: "Leaderboard", colorHex: AttachmentColor.good.rawValue, text: "", fields: [💯, 💩])
|
||||
}
|
||||
|
||||
private func topItems(dictionary: inout [String: Int]) -> String {
|
||||
let sortedKeys = dictionary.keys.sorted(by: { (k1: String, k2: String) -> Bool in
|
||||
return dictionary[k1]! > dictionary[k2]!
|
||||
}).filter({ dictionary[$0]! > 0})
|
||||
let sortedValues = dictionary.values.sorted(by: {$0 > $1}).filter({$0 > 0})
|
||||
return leaderboardString(keys: sortedKeys, values: sortedValues)
|
||||
}
|
||||
|
||||
private func bottomItems( dictionary: inout [String: Int]) -> String {
|
||||
let sortedKeys = dictionary.keys.sorted(by: { (k1: String, k2: String) -> Bool in
|
||||
return dictionary[k1]! < dictionary[k2]!
|
||||
}).filter({ dictionary[$0]! < 0})
|
||||
let sortedValues = dictionary.values.sorted(by: {$0 < $1}).filter({$0 < 0})
|
||||
return leaderboardString(keys: sortedKeys, values: sortedValues)
|
||||
}
|
||||
|
||||
private func leaderboardString(keys: [String], values: [Int]) -> String {
|
||||
var returnValue = ""
|
||||
for i in 0..<values.count {
|
||||
returnValue += keys[i] + " (" + "\(values[i])" + ")\n"
|
||||
}
|
||||
return returnValue
|
||||
}
|
||||
|
||||
// MARK: - Utilities
|
||||
private func swapIDsForNames(string: String) -> String {
|
||||
var returnString = string
|
||||
for key in client.users.keys {
|
||||
if let name = client.users[key]?.name {
|
||||
if returnString.contains(key) {
|
||||
returnString = returnString.replacingOccurrences(of: key, with: "@"+name)
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnString
|
||||
}
|
||||
|
||||
private func userID(string: String) -> String {
|
||||
return string.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
|
||||
}
|
||||
}
|
||||
|
||||
let leaderboard = Leaderboard(token: "xoxb-SLACK_API_TOKEN")
|
||||
leaderboard.client.connect()
|
||||
@@ -0,0 +1,9 @@
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "robot-or-not-bot",
|
||||
targets: [],
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 0, minor: 0),
|
||||
]
|
||||
)
|
||||
@@ -0,0 +1,117 @@
|
||||
import Foundation
|
||||
import SlackKit
|
||||
|
||||
class RobotOrNotBot: MessageEventsDelegate {
|
||||
|
||||
let verdicts: [String:Bool] = [
|
||||
"Mr. Roboto" : false,
|
||||
"Service Kiosks": false,
|
||||
"Darth Vader": false,
|
||||
"K-9": true,
|
||||
"Emotions": false,
|
||||
"Self-Driving Cars": false,
|
||||
"Telepresence Robots": false,
|
||||
"Roomba": true,
|
||||
"Assembly-Line Robot": false,
|
||||
"ASIMO": false,
|
||||
"KITT": false,
|
||||
"USS Enterprise": false,
|
||||
"Transformers": true,
|
||||
"Jaegers": false,
|
||||
"The Major": false,
|
||||
"Siri": false,
|
||||
"The Terminator": true,
|
||||
"Commander Data": false,
|
||||
"Marvin the Paranoid Android": true,
|
||||
"Pinocchio": false,
|
||||
"Droids": true,
|
||||
"Hitchbot": false,
|
||||
"Mars Rovers": false,
|
||||
"Space Probes": false,
|
||||
"Sasquatch": false,
|
||||
"Toaster": false,
|
||||
"Toaster Oven": false,
|
||||
"Cylons": false,
|
||||
"V'ger": true,
|
||||
"Ilia Robot": false,
|
||||
"The TARDIS": false,
|
||||
"Johnny 5": true,
|
||||
"Twiki": true,
|
||||
"Dr. Theopolis": false,
|
||||
"robots.txt": false,
|
||||
"Lobot": false,
|
||||
"Vicki": true,
|
||||
"GlaDOS": false,
|
||||
"Turrets": true,
|
||||
"Wheatley": true,
|
||||
"Herbie the Love Bug": false,
|
||||
"Iron Man": false,
|
||||
"Ultron": false,
|
||||
"The Vision": false,
|
||||
"Clockwork Droids": false,
|
||||
"Podcasts": false,
|
||||
"Cars": false,
|
||||
"Swimming Pool Cleaners": false,
|
||||
"Burritos": false,
|
||||
"Prince Robot IV": false,
|
||||
"Daleks": false,
|
||||
"Cybermen": false,
|
||||
"The Internet of Things": false,
|
||||
"Nanobots": true,
|
||||
"Two Intermeshed Gears": false,
|
||||
"Crow T. Robot": true,
|
||||
"Tom Servo": true,
|
||||
"Thomas and Friends": false,
|
||||
"Replicants": false,
|
||||
"Chatbots": false,
|
||||
"Agents": false,
|
||||
"Lego Simulated Worm Toy": true,
|
||||
"Ghosts": false,
|
||||
"Exos": true,
|
||||
"Rasputin": false,
|
||||
"Tamagotchi": false,
|
||||
"T-1000": true,
|
||||
"The Tin Woodman": false,
|
||||
"Mic N. The Robot": true,
|
||||
"Robot Or Not Bot": false
|
||||
]
|
||||
|
||||
let client: SlackClient
|
||||
|
||||
init(token: String) {
|
||||
client = SlackClient(apiToken: token)
|
||||
client.messageEventsDelegate = self
|
||||
}
|
||||
|
||||
// MARK: MessageEventsDelegate
|
||||
func received(_ message: Message, client: SlackClient) {
|
||||
if let id = client.authenticatedUser?.id {
|
||||
if message.text?.contains(id) == true {
|
||||
handleMessage(message: message)
|
||||
}
|
||||
}
|
||||
}
|
||||
func changed(_ message: Message, client: SlackClient) {}
|
||||
func deleted(_ message: Message?, client: SlackClient) {}
|
||||
func sent(_ message: Message, client: SlackClient) {}
|
||||
|
||||
private func handleMessage(message: Message) {
|
||||
if let text = message.text?.lowercased(), let channel = message.channel {
|
||||
for (robot, verdict) in verdicts {
|
||||
let lowerbot = robot.lowercased()
|
||||
if text.contains(lowerbot) {
|
||||
if verdict == true {
|
||||
client.webAPI.addReaction(name: "robot_face", channel: channel, timestamp: message.ts, success: nil, failure: nil)
|
||||
} else {
|
||||
client.webAPI.addReaction(name: "no_entry_sign", channel: channel, timestamp: message.ts, success: nil, failure: nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
client.webAPI.addReaction(name: "question", channel: channel, timestamp: message.ts, success: nil, failure: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let slackbot = RobotOrNotBot(token: "xoxb-SLACK_API_TOKEN")
|
||||
slackbot.client.connect()
|
||||
@@ -1,58 +0,0 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "16x16",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "16x16",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "32x32",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "32x32",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "128x128",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "128x128",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "256x256",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "256x256",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "512x512",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "mac",
|
||||
"size" : "512x512",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
@@ -1,680 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6233" systemVersion="14A329f" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6233"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
<connections>
|
||||
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModuleProvider="target">
|
||||
<connections>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
|
||||
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
|
||||
<items>
|
||||
<menuItem title="OSX-Sample" id="1Xt-HY-uBw">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="OSX-Sample" systemMenu="apple" id="uQy-DD-JDr">
|
||||
<items>
|
||||
<menuItem title="About OSX-Sample" id="5kV-Vb-QxS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
|
||||
<menuItem title="Preferences…" keyEquivalent="," id="BOF-NM-1cW"/>
|
||||
<menuItem isSeparatorItem="YES" id="wFC-TO-SCJ"/>
|
||||
<menuItem title="Services" id="NMo-om-nkz">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Services" systemMenu="services" id="hz9-B4-Xy5"/>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="4je-JR-u6R"/>
|
||||
<menuItem title="Hide OSX-Sample" keyEquivalent="h" id="Olw-nP-bQN">
|
||||
<connections>
|
||||
<action selector="hide:" target="-1" id="PnN-Uc-m68"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Hide Others" keyEquivalent="h" id="Vdr-fp-XzO">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="hideOtherApplications:" target="-1" id="VT4-aY-XCT"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Show All" id="Kd2-mp-pUS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="unhideAllApplications:" target="-1" id="Dhg-Le-xox"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
|
||||
<menuItem title="Quit OSX-Sample" keyEquivalent="q" id="4sb-4s-VLi">
|
||||
<connections>
|
||||
<action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="File" id="dMs-cI-mzQ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="File" id="bib-Uj-vzu">
|
||||
<items>
|
||||
<menuItem title="New" keyEquivalent="n" id="Was-JA-tGl">
|
||||
<connections>
|
||||
<action selector="newDocument:" target="-1" id="4Si-XN-c54"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Open…" keyEquivalent="o" id="IAo-SY-fd9">
|
||||
<connections>
|
||||
<action selector="openDocument:" target="-1" id="bVn-NM-KNZ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Open Recent" id="tXI-mr-wws">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Open Recent" systemMenu="recentDocuments" id="oas-Oc-fiZ">
|
||||
<items>
|
||||
<menuItem title="Clear Menu" id="vNY-rz-j42">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="clearRecentDocuments:" target="-1" id="Daa-9d-B3U"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="m54-Is-iLE"/>
|
||||
<menuItem title="Close" keyEquivalent="w" id="DVo-aG-piG">
|
||||
<connections>
|
||||
<action selector="performClose:" target="-1" id="HmO-Ls-i7Q"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Save…" keyEquivalent="s" id="pxx-59-PXV">
|
||||
<connections>
|
||||
<action selector="saveDocument:" target="-1" id="teZ-XB-qJY"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Save As…" keyEquivalent="S" id="Bw7-FT-i3A">
|
||||
<connections>
|
||||
<action selector="saveDocumentAs:" target="-1" id="mDf-zr-I0C"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Revert to Saved" id="KaW-ft-85H">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="revertDocumentToSaved:" target="-1" id="iJ3-Pv-kwq"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="aJh-i4-bef"/>
|
||||
<menuItem title="Page Setup…" keyEquivalent="P" id="qIS-W8-SiK">
|
||||
<modifierMask key="keyEquivalentModifierMask" shift="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="runPageLayout:" target="-1" id="Din-rz-gC5"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Print…" keyEquivalent="p" id="aTl-1u-JFS">
|
||||
<connections>
|
||||
<action selector="print:" target="-1" id="qaZ-4w-aoO"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Edit" id="5QF-Oa-p0T">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Edit" id="W48-6f-4Dl">
|
||||
<items>
|
||||
<menuItem title="Undo" keyEquivalent="z" id="dRJ-4n-Yzg">
|
||||
<connections>
|
||||
<action selector="undo:" target="-1" id="M6e-cu-g7V"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Redo" keyEquivalent="Z" id="6dh-zS-Vam">
|
||||
<connections>
|
||||
<action selector="redo:" target="-1" id="oIA-Rs-6OD"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="WRV-NI-Exz"/>
|
||||
<menuItem title="Cut" keyEquivalent="x" id="uRl-iY-unG">
|
||||
<connections>
|
||||
<action selector="cut:" target="-1" id="YJe-68-I9s"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Copy" keyEquivalent="c" id="x3v-GG-iWU">
|
||||
<connections>
|
||||
<action selector="copy:" target="-1" id="G1f-GL-Joy"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Paste" keyEquivalent="v" id="gVA-U4-sdL">
|
||||
<connections>
|
||||
<action selector="paste:" target="-1" id="UvS-8e-Qdg"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Paste and Match Style" keyEquivalent="V" id="WeT-3V-zwk">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="pasteAsPlainText:" target="-1" id="cEh-KX-wJQ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Delete" id="pa3-QI-u2k">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="delete:" target="-1" id="0Mk-Ml-PaM"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Select All" keyEquivalent="a" id="Ruw-6m-B2m">
|
||||
<connections>
|
||||
<action selector="selectAll:" target="-1" id="VNm-Mi-diN"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="uyl-h8-XO2"/>
|
||||
<menuItem title="Find" id="4EN-yA-p0u">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Find" id="1b7-l0-nxx">
|
||||
<items>
|
||||
<menuItem title="Find…" tag="1" keyEquivalent="f" id="Xz5-n4-O0W">
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="cD7-Qs-BN4"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Find and Replace…" tag="12" keyEquivalent="f" id="YEy-JH-Tfz">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="WD3-Gg-5AJ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Find Next" tag="2" keyEquivalent="g" id="q09-fT-Sye">
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="NDo-RZ-v9R"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Find Previous" tag="3" keyEquivalent="G" id="OwM-mh-QMV">
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="HOh-sY-3ay"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Use Selection for Find" tag="7" keyEquivalent="e" id="buJ-ug-pKt">
|
||||
<connections>
|
||||
<action selector="performFindPanelAction:" target="-1" id="U76-nv-p5D"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Jump to Selection" keyEquivalent="j" id="S0p-oC-mLd">
|
||||
<connections>
|
||||
<action selector="centerSelectionInVisibleArea:" target="-1" id="IOG-6D-g5B"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Spelling and Grammar" id="Dv1-io-Yv7">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Spelling" id="3IN-sU-3Bg">
|
||||
<items>
|
||||
<menuItem title="Show Spelling and Grammar" keyEquivalent=":" id="HFo-cy-zxI">
|
||||
<connections>
|
||||
<action selector="showGuessPanel:" target="-1" id="vFj-Ks-hy3"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Check Document Now" keyEquivalent=";" id="hz2-CU-CR7">
|
||||
<connections>
|
||||
<action selector="checkSpelling:" target="-1" id="fz7-VC-reM"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="bNw-od-mp5"/>
|
||||
<menuItem title="Check Spelling While Typing" id="rbD-Rh-wIN">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleContinuousSpellChecking:" target="-1" id="7w6-Qz-0kB"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Check Grammar With Spelling" id="mK6-2p-4JG">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleGrammarChecking:" target="-1" id="muD-Qn-j4w"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Correct Spelling Automatically" id="78Y-hA-62v">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticSpellingCorrection:" target="-1" id="2lM-Qi-WAP"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Substitutions" id="9ic-FL-obx">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Substitutions" id="FeM-D8-WVr">
|
||||
<items>
|
||||
<menuItem title="Show Substitutions" id="z6F-FW-3nz">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="orderFrontSubstitutionsPanel:" target="-1" id="oku-mr-iSq"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="gPx-C9-uUO"/>
|
||||
<menuItem title="Smart Copy/Paste" id="9yt-4B-nSM">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleSmartInsertDelete:" target="-1" id="3IJ-Se-DZD"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Smart Quotes" id="hQb-2v-fYv">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticQuoteSubstitution:" target="-1" id="ptq-xd-QOA"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Smart Dashes" id="rgM-f4-ycn">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticDashSubstitution:" target="-1" id="oCt-pO-9gS"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Smart Links" id="cwL-P1-jid">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticLinkDetection:" target="-1" id="Gip-E3-Fov"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Data Detectors" id="tRr-pd-1PS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticDataDetection:" target="-1" id="R1I-Nq-Kbl"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Text Replacement" id="HFQ-gK-NFA">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleAutomaticTextReplacement:" target="-1" id="DvP-Fe-Py6"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Transformations" id="2oI-Rn-ZJC">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Transformations" id="c8a-y6-VQd">
|
||||
<items>
|
||||
<menuItem title="Make Upper Case" id="vmV-6d-7jI">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="uppercaseWord:" target="-1" id="sPh-Tk-edu"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Make Lower Case" id="d9M-CD-aMd">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="lowercaseWord:" target="-1" id="iUZ-b5-hil"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Capitalize" id="UEZ-Bs-lqG">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="capitalizeWord:" target="-1" id="26H-TL-nsh"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Speech" id="xrE-MZ-jX0">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Speech" id="3rS-ZA-NoH">
|
||||
<items>
|
||||
<menuItem title="Start Speaking" id="Ynk-f8-cLZ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="startSpeaking:" target="-1" id="654-Ng-kyl"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Stop Speaking" id="Oyz-dy-DGm">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="stopSpeaking:" target="-1" id="dX8-6p-jy9"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Format" id="jxT-CU-nIS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Format" id="GEO-Iw-cKr">
|
||||
<items>
|
||||
<menuItem title="Font" id="Gi5-1S-RQB">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Font" systemMenu="font" id="aXa-aM-Jaq">
|
||||
<items>
|
||||
<menuItem title="Show Fonts" keyEquivalent="t" id="Q5e-8K-NDq">
|
||||
<connections>
|
||||
<action selector="orderFrontFontPanel:" target="YLy-65-1bz" id="WHr-nq-2xA"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Bold" tag="2" keyEquivalent="b" id="GB9-OM-e27">
|
||||
<connections>
|
||||
<action selector="addFontTrait:" target="YLy-65-1bz" id="hqk-hr-sYV"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Italic" tag="1" keyEquivalent="i" id="Vjx-xi-njq">
|
||||
<connections>
|
||||
<action selector="addFontTrait:" target="YLy-65-1bz" id="IHV-OB-c03"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Underline" keyEquivalent="u" id="WRG-CD-K1S">
|
||||
<connections>
|
||||
<action selector="underline:" target="-1" id="FYS-2b-JAY"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="5gT-KC-WSO"/>
|
||||
<menuItem title="Bigger" tag="3" keyEquivalent="+" id="Ptp-SP-VEL">
|
||||
<connections>
|
||||
<action selector="modifyFont:" target="YLy-65-1bz" id="Uc7-di-UnL"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Smaller" tag="4" keyEquivalent="-" id="i1d-Er-qST">
|
||||
<connections>
|
||||
<action selector="modifyFont:" target="YLy-65-1bz" id="HcX-Lf-eNd"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="kx3-Dk-x3B"/>
|
||||
<menuItem title="Kern" id="jBQ-r6-VK2">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Kern" id="tlD-Oa-oAM">
|
||||
<items>
|
||||
<menuItem title="Use Default" id="GUa-eO-cwY">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="useStandardKerning:" target="-1" id="6dk-9l-Ckg"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Use None" id="cDB-IK-hbR">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="turnOffKerning:" target="-1" id="U8a-gz-Maa"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Tighten" id="46P-cB-AYj">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="tightenKerning:" target="-1" id="hr7-Nz-8ro"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Loosen" id="ogc-rX-tC1">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="loosenKerning:" target="-1" id="8i4-f9-FKE"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Ligatures" id="o6e-r0-MWq">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Ligatures" id="w0m-vy-SC9">
|
||||
<items>
|
||||
<menuItem title="Use Default" id="agt-UL-0e3">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="useStandardLigatures:" target="-1" id="7uR-wd-Dx6"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Use None" id="J7y-lM-qPV">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="turnOffLigatures:" target="-1" id="iX2-gA-Ilz"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Use All" id="xQD-1f-W4t">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="useAllLigatures:" target="-1" id="KcB-kA-TuK"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Baseline" id="OaQ-X3-Vso">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Baseline" id="ijk-EB-dga">
|
||||
<items>
|
||||
<menuItem title="Use Default" id="3Om-Ey-2VK">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="unscript:" target="-1" id="0vZ-95-Ywn"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Superscript" id="Rqc-34-cIF">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="superscript:" target="-1" id="3qV-fo-wpU"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Subscript" id="I0S-gh-46l">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="subscript:" target="-1" id="Q6W-4W-IGz"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Raise" id="2h7-ER-AoG">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="raiseBaseline:" target="-1" id="4sk-31-7Q9"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Lower" id="1tx-W0-xDw">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="lowerBaseline:" target="-1" id="OF1-bc-KW4"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="Ndw-q3-faq"/>
|
||||
<menuItem title="Show Colors" keyEquivalent="C" id="bgn-CT-cEk">
|
||||
<connections>
|
||||
<action selector="orderFrontColorPanel:" target="-1" id="mSX-Xz-DV3"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="iMs-zA-UFJ"/>
|
||||
<menuItem title="Copy Style" keyEquivalent="c" id="5Vv-lz-BsD">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="copyFont:" target="-1" id="GJO-xA-L4q"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Paste Style" keyEquivalent="v" id="vKC-jM-MkH">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="pasteFont:" target="-1" id="JfD-CL-leO"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Text" id="Fal-I4-PZk">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Text" id="d9c-me-L2H">
|
||||
<items>
|
||||
<menuItem title="Align Left" keyEquivalent="{" id="ZM1-6Q-yy1">
|
||||
<connections>
|
||||
<action selector="alignLeft:" target="-1" id="zUv-R1-uAa"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Center" keyEquivalent="|" id="VIY-Ag-zcb">
|
||||
<connections>
|
||||
<action selector="alignCenter:" target="-1" id="spX-mk-kcS"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Justify" id="J5U-5w-g23">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="alignJustified:" target="-1" id="ljL-7U-jND"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Align Right" keyEquivalent="}" id="wb2-vD-lq4">
|
||||
<connections>
|
||||
<action selector="alignRight:" target="-1" id="r48-bG-YeY"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="4s2-GY-VfK"/>
|
||||
<menuItem title="Writing Direction" id="H1b-Si-o9J">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Writing Direction" id="8mr-sm-Yjd">
|
||||
<items>
|
||||
<menuItem title="Paragraph" enabled="NO" id="ZvO-Gk-QUH">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem id="YGs-j5-SAR">
|
||||
<string key="title"> Default</string>
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="makeBaseWritingDirectionNatural:" target="-1" id="qtV-5e-UBP"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem id="Lbh-J2-qVU">
|
||||
<string key="title"> Left to Right</string>
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="makeBaseWritingDirectionLeftToRight:" target="-1" id="S0X-9S-QSf"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem id="jFq-tB-4Kx">
|
||||
<string key="title"> Right to Left</string>
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="makeBaseWritingDirectionRightToLeft:" target="-1" id="5fk-qB-AqJ"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="swp-gr-a21"/>
|
||||
<menuItem title="Selection" enabled="NO" id="cqv-fj-IhA">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem id="Nop-cj-93Q">
|
||||
<string key="title"> Default</string>
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="makeTextWritingDirectionNatural:" target="-1" id="lPI-Se-ZHp"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem id="BgM-ve-c93">
|
||||
<string key="title"> Left to Right</string>
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="makeTextWritingDirectionLeftToRight:" target="-1" id="caW-Bv-w94"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem id="RB4-Sm-HuC">
|
||||
<string key="title"> Right to Left</string>
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="makeTextWritingDirectionRightToLeft:" target="-1" id="EXD-6r-ZUu"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="fKy-g9-1gm"/>
|
||||
<menuItem title="Show Ruler" id="vLm-3I-IUL">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="toggleRuler:" target="-1" id="FOx-HJ-KwY"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Copy Ruler" keyEquivalent="c" id="MkV-Pr-PK5">
|
||||
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="copyRuler:" target="-1" id="71i-fW-3W2"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Paste Ruler" keyEquivalent="v" id="LVM-kO-fVI">
|
||||
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="pasteRuler:" target="-1" id="cSh-wd-qM2"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="View" id="H8h-7b-M4v">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="View" id="HyV-fh-RgO">
|
||||
<items>
|
||||
<menuItem title="Show Toolbar" keyEquivalent="t" id="snW-S8-Cw5">
|
||||
<modifierMask key="keyEquivalentModifierMask" option="YES" command="YES"/>
|
||||
<connections>
|
||||
<action selector="toggleToolbarShown:" target="-1" id="BXY-wc-z0C"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Customize Toolbar…" id="1UK-8n-QPP">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="runToolbarCustomizationPalette:" target="-1" id="pQI-g3-MTW"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Window" id="aUF-d1-5bR">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
|
||||
<items>
|
||||
<menuItem title="Minimize" keyEquivalent="m" id="OY7-WF-poV">
|
||||
<connections>
|
||||
<action selector="performMiniaturize:" target="-1" id="VwT-WD-YPe"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Zoom" id="R4o-n2-Eq4">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="performZoom:" target="-1" id="DIl-cC-cCs"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="eu3-7i-yIM"/>
|
||||
<menuItem title="Bring All to Front" id="LE2-aR-0XJ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Help" id="wpr-3q-Mcd">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Help" systemMenu="help" id="F2S-fz-NVQ">
|
||||
<items>
|
||||
<menuItem title="OSX-Sample Help" keyEquivalent="?" id="FKE-Sm-Kum">
|
||||
<connections>
|
||||
<action selector="showHelp:" target="-1" id="y7X-2Q-9no"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
<window title="OSX-Sample" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="QvC-M9-y7g">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1177"/>
|
||||
<view key="contentView" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -1,34 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string></string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2016 Launch Software LLC. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,160 +0,0 @@
|
||||
//
|
||||
// Leaderboard.swift
|
||||
// OSX-Sample
|
||||
//
|
||||
// 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 SlackKit
|
||||
import Foundation
|
||||
|
||||
class Leaderboard: MessageEventsDelegate {
|
||||
|
||||
var leaderboard: [String: Int] = [String: Int]()
|
||||
let atSet = NSCharacterSet(charactersInString: "@")
|
||||
|
||||
let client: Client
|
||||
|
||||
init(token: String) {
|
||||
client = Client(apiToken: token)
|
||||
client.messageEventsDelegate = self
|
||||
}
|
||||
|
||||
enum Command: String {
|
||||
case Leaderboard = "leaderboard"
|
||||
}
|
||||
|
||||
enum Trigger: String {
|
||||
case PlusPlus = "++"
|
||||
case MinusMinus = "--"
|
||||
}
|
||||
|
||||
// MARK: MessageEventsDelegate
|
||||
func messageReceived(message: Message) {
|
||||
listen(message)
|
||||
}
|
||||
|
||||
func messageSent(message: Message){}
|
||||
func messageChanged(message: Message){}
|
||||
func messageDeleted(message: Message?){}
|
||||
|
||||
// MARK: Leaderboard Internal Logic
|
||||
private func listen(message: Message) {
|
||||
if let id = client.authenticatedUser?.id, text = message.text {
|
||||
if text.lowercaseString.containsString(Command.Leaderboard.rawValue) && text.containsString(id) == true {
|
||||
handleCommand(.Leaderboard, channel: message.channel)
|
||||
}
|
||||
}
|
||||
if message.text?.containsString(Trigger.PlusPlus.rawValue) == true {
|
||||
handleMessageWithTrigger(message, trigger: .PlusPlus)
|
||||
}
|
||||
if message.text?.containsString(Trigger.MinusMinus.rawValue) == true {
|
||||
handleMessageWithTrigger(message, trigger: .MinusMinus)
|
||||
}
|
||||
}
|
||||
|
||||
private func handleMessageWithTrigger(message: Message, trigger: Trigger) {
|
||||
if let text = message.text,
|
||||
end = text.rangeOfString(trigger.rawValue)?.startIndex.predecessor(),
|
||||
start = text.rangeOfCharacterFromSet(atSet, options: .BackwardsSearch, range: text.startIndex..<end)?.startIndex {
|
||||
let string = text.substringWithRange(start...end)
|
||||
let users = client.users.values.filter{$0.id == self.userID(string)}
|
||||
if users.count > 0 {
|
||||
let idString = userID(string)
|
||||
initalizationForValue(&leaderboard, value: idString)
|
||||
scoringForValue(&leaderboard, value: idString, trigger: trigger)
|
||||
} else {
|
||||
initalizationForValue(&leaderboard, value: string)
|
||||
scoringForValue(&leaderboard, value: string, trigger: trigger)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleCommand(command: Command, channel:String?) {
|
||||
switch command {
|
||||
case .Leaderboard:
|
||||
if let id = channel {
|
||||
client.webAPI.sendMessage(id, text: "", linkNames: true, attachments: [constructLeaderboardAttachment()], success: {(response) in
|
||||
|
||||
}, failure: { (error) in
|
||||
print("Leaderboard failed to post due to error:\(error)")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func initalizationForValue(inout dictionary: [String: Int], value: String) {
|
||||
if dictionary[value] == nil {
|
||||
dictionary[value] = 0
|
||||
}
|
||||
}
|
||||
|
||||
private func scoringForValue(inout dictionary: [String: Int], value: String, trigger: Trigger) {
|
||||
switch trigger {
|
||||
case .PlusPlus:
|
||||
dictionary[value]?+=1
|
||||
case .MinusMinus:
|
||||
dictionary[value]?-=1
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Leaderboard Interface
|
||||
private func constructLeaderboardAttachment() -> Attachment? {
|
||||
let 💯 = AttachmentField(title: "💯", value: swapIDsForNames(topItems(&leaderboard)), short: true)
|
||||
let 💩 = AttachmentField(title: "💩", value: swapIDsForNames(bottomItems(&leaderboard)), short: true)
|
||||
return Attachment(fallback: "Leaderboard", title: "Leaderboard", colorHex: AttachmentColor.Good.rawValue, text: "", fields: [💯, 💩])
|
||||
}
|
||||
|
||||
private func topItems(inout dictionary: [String: Int]) -> String {
|
||||
let sortedKeys = Array(dictionary.keys).sort({dictionary[$0] > dictionary[$1]}).filter({dictionary[$0] > 0})
|
||||
let sortedValues = Array(dictionary.values).sort({$0 > $1}).filter({$0 > 0})
|
||||
return leaderboardString(sortedKeys, values: sortedValues)
|
||||
}
|
||||
|
||||
private func bottomItems(inout dictionary: [String: Int]) -> String {
|
||||
let sortedKeys = Array(dictionary.keys).sort({dictionary[$0] < dictionary[$1]}).filter({dictionary[$0] < 0})
|
||||
let sortedValues = Array(dictionary.values).sort({$0 < $1}).filter({$0 < 0})
|
||||
return leaderboardString(sortedKeys, values: sortedValues)
|
||||
}
|
||||
|
||||
private func leaderboardString(keys: [String], values: [Int]) -> String {
|
||||
var returnValue = ""
|
||||
for i in 0..<values.count {
|
||||
returnValue += keys[i] + " (" + "\(values[i])" + ")\n"
|
||||
}
|
||||
return returnValue
|
||||
}
|
||||
|
||||
// MARK: - Utilities
|
||||
private func swapIDsForNames(string: String) -> String {
|
||||
var returnString = string
|
||||
for key in client.users.keys {
|
||||
if let name = client.users[key]?.name {
|
||||
returnString = returnString.stringByReplacingOccurrencesOfString(key, withString: "@"+name, options: NSStringCompareOptions.LiteralSearch, range: returnString.startIndex..<returnString.endIndex)
|
||||
}
|
||||
}
|
||||
return returnString
|
||||
}
|
||||
|
||||
private func userID(string: String) -> String {
|
||||
return string.stringByTrimmingCharactersInSet(NSCharacterSet.alphanumericCharacterSet().invertedSet)
|
||||
}
|
||||
|
||||
}
|
||||
+4
-3
@@ -27,7 +27,8 @@ let package = Package(
|
||||
name: "SlackKit",
|
||||
targets: [],
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/Starscream.git",
|
||||
majorVersion: 1),
|
||||
]
|
||||
.Package(url: "https://github.com/Zewo/WebSocketClient", majorVersion: 0, minor: 14),
|
||||
.Package(url: "https://github.com/Zewo/HTTPClient.git", majorVersion: 0, minor: 14)
|
||||
],
|
||||
exclude: ["Examples"]
|
||||
)
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
|
||||
use_frameworks!
|
||||
|
||||
target 'SlackKit' do
|
||||
pod 'Starscream'
|
||||
end
|
||||
|
||||
target 'SlackKit_iOS' do
|
||||
pod 'Starscream'
|
||||
end
|
||||
|
||||
target 'SlackKit_tvOS' do
|
||||
pod 'Starscream'
|
||||
end
|
||||
@@ -1,12 +0,0 @@
|
||||
PODS:
|
||||
- Starscream (1.1.3)
|
||||
|
||||
DEPENDENCIES:
|
||||
- Starscream
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Starscream: d662732354b40dd19ed1ece3e3c44c80b536b83c
|
||||
|
||||
PODFILE CHECKSUM: d22778f772dbbded8b17fbebf5fa1c879d785aee
|
||||
|
||||
COCOAPODS: 1.0.0
|
||||
@@ -1,38 +1,13 @@
|
||||

|
||||
##iOS, OS X, and tvOS Slack Client Library
|
||||
###Description
|
||||
This is a Slack client library for OS X, iOS, and tvOS 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).
|
||||
|
||||
####Building the SlackKit Framework
|
||||
To build the SlackKit project directly, first build the dependencies using Carthage or CocoaPods. To use the framework in your application, install it in one of the following ways:
|
||||
   [](https://github.com/apple/swift-package-manager)
|
||||
##Alpha Linux Slack Client Library
|
||||
###Description
|
||||
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.
|
||||
|
||||
###Installation
|
||||
####CocoaPods
|
||||
Add the pod to your podfile:
|
||||
```
|
||||
pod 'SlackKit'
|
||||
```
|
||||
and run
|
||||
```
|
||||
pod install
|
||||
```
|
||||
|
||||
####Carthage
|
||||
|
||||
Add SlackKit to your Cartfile:
|
||||
```
|
||||
github “pvzig/SlackKit” ~> 1.0
|
||||
```
|
||||
and run
|
||||
```
|
||||
carthage bootstrap
|
||||
```
|
||||
**Note:** SlackKit currently takes a _long_ time for the compiler to compile with optimizations turned on. I'm currently exploring a potential fix for this issue. In the meantime, you may want to skip the waiting and build it in the debug configuration instead:
|
||||
```
|
||||
carthage bootstrap --configuration "Debug"
|
||||
```
|
||||
|
||||
Drag the built `SlackKit.framework` into your Xcode project.
|
||||
|
||||
####Swift Package Manager
|
||||
Add SlackKit to your Package.swift
|
||||
@@ -42,18 +17,37 @@ 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-05-09-a
|
||||
swiftenv local DEVELOPMENT-SNAPSHOT-2016-05-09-a
|
||||
```
|
||||
5. Install and Link OpenSSL: `brew install openssl`, `brew link openssl --force`
|
||||
|
||||
To build an application that uses SlackKit in Xcode, simply use SwiftPM. (For the 05-03 snapshot you must run `swift build` before generating an Xcode project:
|
||||
```
|
||||
swift build
|
||||
swift build -Xlinker -L$(pwd)/.build/debug/ -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).
|
||||
|
||||
@@ -67,11 +61,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
|
||||
@@ -93,7 +82,6 @@ SlackKit currently supports the a subset of the Slack Web APIs that are availabl
|
||||
- files.comments.edit
|
||||
- files.comments.delete
|
||||
- files.delete
|
||||
- files.info
|
||||
- files.upload
|
||||
- groups.close
|
||||
- groups.history
|
||||
@@ -151,7 +139,6 @@ There are a number of delegates that you can set to receive callbacks for certai
|
||||
|
||||
#####SlackEventsDelegate
|
||||
```swift
|
||||
func clientConnectionFailed(error: SlackError)
|
||||
func clientConnected()
|
||||
func clientDisconnected()
|
||||
func preferenceChanged(preference: String, value: AnyObject)
|
||||
@@ -238,18 +225,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)
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "SlackKit"
|
||||
s.version = "1.1.1"
|
||||
s.summary = "a Slack client library for OS X, iOS, and tvOS written in Swift"
|
||||
s.homepage = "https://github.com/pvzig/SlackKit"
|
||||
s.license = 'MIT'
|
||||
s.author = { "Peter Zignego" => "peter@launchsoft.co" }
|
||||
s.source = { :git => "https://github.com/pvzig/SlackKit.git", :tag => s.version.to_s }
|
||||
s.social_media_url = 'https://twitter.com/pvzig'
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.10'
|
||||
s.tvos.deployment_target = '9.0'
|
||||
s.requires_arc = true
|
||||
s.source_files = 'SlackKit/Sources/*.swift'
|
||||
s.frameworks = 'Foundation'
|
||||
s.dependency 'Starscream', '~> 1.1.3'
|
||||
end
|
||||
|
||||
@@ -1,826 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
2601D61B1C7646B80012BF22 /* SlackWebAPIErrorDispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2601D61A1C7646B80012BF22 /* SlackWebAPIErrorDispatcher.swift */; };
|
||||
2601D6271C7688610012BF22 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2601D6261C7688610012BF22 /* AppDelegate.swift */; };
|
||||
2601D6291C7688610012BF22 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2601D6281C7688610012BF22 /* Assets.xcassets */; };
|
||||
2601D62C1C7688610012BF22 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2601D62A1C7688610012BF22 /* MainMenu.xib */; };
|
||||
260EC2331C4DC61D0093B253 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2301C4DC61D0093B253 /* Extensions.swift */; };
|
||||
260EC2341C4DC61D0093B253 /* NetworkInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2311C4DC61D0093B253 /* NetworkInterface.swift */; };
|
||||
260EC2351C4DC61D0093B253 /* SlackWebAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2321C4DC61D0093B253 /* SlackWebAPI.swift */; };
|
||||
263993901CE90C87004A6E93 /* SlackKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 2661A6A41BBF62FF0026F67B /* SlackKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
263993971CE90EE0004A6E93 /* Client+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16C98791CE7D3DD00692776 /* Client+Utilities.swift */; };
|
||||
263993981CE90EE0004A6E93 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1881C398E3C00BF7225 /* Channel.swift */; };
|
||||
263993991CE90EE0004A6E93 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1921C398E3C00BF7225 /* User.swift */; };
|
||||
2639939A1CE90EE0004A6E93 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1911C398E3C00BF7225 /* Types.swift */; };
|
||||
2639939B1CE90EE0004A6E93 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1891C398E3C00BF7225 /* Client.swift */; };
|
||||
2639939C1CE90EE0004A6E93 /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18A1C398E3C00BF7225 /* Event.swift */; };
|
||||
2639939D1CE90EE0004A6E93 /* Bot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1871C398E3C00BF7225 /* Bot.swift */; };
|
||||
2639939E1CE90EE0004A6E93 /* Client+EventDispatching.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */; };
|
||||
2639939F1CE90EE0004A6E93 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18E1C398E3C00BF7225 /* File.swift */; };
|
||||
263993A01CE90EE0004A6E93 /* SlackWebAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2321C4DC61D0093B253 /* SlackWebAPI.swift */; };
|
||||
263993A11CE90EE0004A6E93 /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26DF40341C7A0FA300E19241 /* Attachment.swift */; };
|
||||
263993A21CE90EE0004A6E93 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18F1C398E3C00BF7225 /* Message.swift */; };
|
||||
263993A31CE90EE0004A6E93 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1901C398E3C00BF7225 /* Team.swift */; };
|
||||
263993A41CE90EE0004A6E93 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2301C4DC61D0093B253 /* Extensions.swift */; };
|
||||
263993A51CE90EE0004A6E93 /* UserGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1931C398E3C00BF7225 /* UserGroup.swift */; };
|
||||
263993A61CE90EE0004A6E93 /* SlackWebAPIErrorDispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2601D61A1C7646B80012BF22 /* SlackWebAPIErrorDispatcher.swift */; };
|
||||
263993A71CE90EE0004A6E93 /* Client+EventHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */; };
|
||||
263993A81CE90EE0004A6E93 /* NetworkInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2311C4DC61D0093B253 /* NetworkInterface.swift */; };
|
||||
263993A91CE90EE0004A6E93 /* EventDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */; };
|
||||
263993AB1CE90EE0004A6E93 /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4307A07F1CC6D0910011D5DE /* Starscream.framework */; };
|
||||
263993AD1CE90EE0004A6E93 /* SlackKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 2661A6A41BBF62FF0026F67B /* SlackKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
263993B61CE90EED004A6E93 /* Client+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16C98791CE7D3DD00692776 /* Client+Utilities.swift */; };
|
||||
263993B71CE90EED004A6E93 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1881C398E3C00BF7225 /* Channel.swift */; };
|
||||
263993B81CE90EED004A6E93 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1921C398E3C00BF7225 /* User.swift */; };
|
||||
263993B91CE90EED004A6E93 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1911C398E3C00BF7225 /* Types.swift */; };
|
||||
263993BA1CE90EED004A6E93 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1891C398E3C00BF7225 /* Client.swift */; };
|
||||
263993BB1CE90EED004A6E93 /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18A1C398E3C00BF7225 /* Event.swift */; };
|
||||
263993BC1CE90EED004A6E93 /* Bot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1871C398E3C00BF7225 /* Bot.swift */; };
|
||||
263993BD1CE90EED004A6E93 /* Client+EventDispatching.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */; };
|
||||
263993BE1CE90EED004A6E93 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18E1C398E3C00BF7225 /* File.swift */; };
|
||||
263993BF1CE90EED004A6E93 /* SlackWebAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2321C4DC61D0093B253 /* SlackWebAPI.swift */; };
|
||||
263993C01CE90EED004A6E93 /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26DF40341C7A0FA300E19241 /* Attachment.swift */; };
|
||||
263993C11CE90EED004A6E93 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18F1C398E3C00BF7225 /* Message.swift */; };
|
||||
263993C21CE90EED004A6E93 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1901C398E3C00BF7225 /* Team.swift */; };
|
||||
263993C31CE90EED004A6E93 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2301C4DC61D0093B253 /* Extensions.swift */; };
|
||||
263993C41CE90EED004A6E93 /* UserGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1931C398E3C00BF7225 /* UserGroup.swift */; };
|
||||
263993C51CE90EED004A6E93 /* SlackWebAPIErrorDispatcher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2601D61A1C7646B80012BF22 /* SlackWebAPIErrorDispatcher.swift */; };
|
||||
263993C61CE90EED004A6E93 /* Client+EventHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */; };
|
||||
263993C71CE90EED004A6E93 /* NetworkInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 260EC2311C4DC61D0093B253 /* NetworkInterface.swift */; };
|
||||
263993C81CE90EED004A6E93 /* EventDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */; };
|
||||
263993CA1CE90EED004A6E93 /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4307A07F1CC6D0910011D5DE /* Starscream.framework */; };
|
||||
263993CC1CE90EED004A6E93 /* SlackKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 2661A6A41BBF62FF0026F67B /* SlackKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
26BBA1941C398E3C00BF7225 /* Bot.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1871C398E3C00BF7225 /* Bot.swift */; };
|
||||
26BBA1951C398E3C00BF7225 /* Channel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1881C398E3C00BF7225 /* Channel.swift */; };
|
||||
26BBA1961C398E3C00BF7225 /* Client.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1891C398E3C00BF7225 /* Client.swift */; };
|
||||
26BBA1971C398E3C00BF7225 /* Event.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18A1C398E3C00BF7225 /* Event.swift */; };
|
||||
26BBA1981C398E3C00BF7225 /* EventDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */; };
|
||||
26BBA19B1C398E3C00BF7225 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18E1C398E3C00BF7225 /* File.swift */; };
|
||||
26BBA19C1C398E3C00BF7225 /* Message.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA18F1C398E3C00BF7225 /* Message.swift */; };
|
||||
26BBA19D1C398E3C00BF7225 /* Team.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1901C398E3C00BF7225 /* Team.swift */; };
|
||||
26BBA19E1C398E3C00BF7225 /* Types.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1911C398E3C00BF7225 /* Types.swift */; };
|
||||
26BBA19F1C398E3C00BF7225 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1921C398E3C00BF7225 /* User.swift */; };
|
||||
26BBA1A01C398E3C00BF7225 /* UserGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26BBA1931C398E3C00BF7225 /* UserGroup.swift */; };
|
||||
26DF40351C7A0FA300E19241 /* Attachment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26DF40341C7A0FA300E19241 /* Attachment.swift */; };
|
||||
26F4BAC31C9DEBD1000910BA /* Leaderboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 26F4BAC21C9DEBD1000910BA /* Leaderboard.swift */; };
|
||||
4307A0801CC6D0910011D5DE /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4307A07F1CC6D0910011D5DE /* Starscream.framework */; };
|
||||
C16C987A1CE7D3DD00692776 /* Client+Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = C16C98791CE7D3DD00692776 /* Client+Utilities.swift */; };
|
||||
C1A85FF91CE3BCEF00756C40 /* Client+EventDispatching.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */; };
|
||||
C1A85FFA1CE3BCEF00756C40 /* Client+EventHandling.swift in Sources */ = {isa = PBXBuildFile; fileRef = C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
2601D61A1C7646B80012BF22 /* SlackWebAPIErrorDispatcher.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SlackWebAPIErrorDispatcher.swift; path = Sources/SlackWebAPIErrorDispatcher.swift; sourceTree = "<group>"; };
|
||||
2601D6241C7688610012BF22 /* OSX-Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OSX-Sample.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
2601D6261C7688610012BF22 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
2601D6281C7688610012BF22 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
2601D62B1C7688610012BF22 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
|
||||
2601D62D1C7688610012BF22 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
26072A341BB48B3A00CD650C /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
260EC2301C4DC61D0093B253 /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Extensions.swift; path = Sources/Extensions.swift; sourceTree = "<group>"; };
|
||||
260EC2311C4DC61D0093B253 /* NetworkInterface.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NetworkInterface.swift; path = Sources/NetworkInterface.swift; sourceTree = "<group>"; };
|
||||
260EC2321C4DC61D0093B253 /* SlackWebAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SlackWebAPI.swift; path = Sources/SlackWebAPI.swift; sourceTree = "<group>"; };
|
||||
263993B21CE90EE0004A6E93 /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
263993D11CE90EED004A6E93 /* SlackKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SlackKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
2661A6A41BBF62FF0026F67B /* SlackKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SlackKit.h; sourceTree = "<group>"; };
|
||||
268E46131CE8F79D009F19CC /* Info-iOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-iOS.plist"; path = "Supporting Files/Info-iOS.plist"; sourceTree = "<group>"; };
|
||||
268E46141CE8F79D009F19CC /* Info-tvOS.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-tvOS.plist"; path = "Supporting Files/Info-tvOS.plist"; sourceTree = "<group>"; };
|
||||
268E46151CE8F79D009F19CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = "Supporting Files/Info.plist"; sourceTree = "<group>"; };
|
||||
26BBA1871C398E3C00BF7225 /* Bot.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Bot.swift; path = Sources/Bot.swift; sourceTree = "<group>"; };
|
||||
26BBA1881C398E3C00BF7225 /* Channel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Channel.swift; path = Sources/Channel.swift; sourceTree = "<group>"; };
|
||||
26BBA1891C398E3C00BF7225 /* Client.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Client.swift; path = Sources/Client.swift; sourceTree = "<group>"; };
|
||||
26BBA18A1C398E3C00BF7225 /* Event.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Event.swift; path = Sources/Event.swift; sourceTree = "<group>"; };
|
||||
26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = EventDelegate.swift; path = Sources/EventDelegate.swift; sourceTree = "<group>"; };
|
||||
26BBA18E1C398E3C00BF7225 /* File.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = File.swift; path = Sources/File.swift; sourceTree = "<group>"; };
|
||||
26BBA18F1C398E3C00BF7225 /* Message.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Message.swift; path = Sources/Message.swift; sourceTree = "<group>"; };
|
||||
26BBA1901C398E3C00BF7225 /* Team.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Team.swift; path = Sources/Team.swift; sourceTree = "<group>"; };
|
||||
26BBA1911C398E3C00BF7225 /* Types.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Types.swift; path = Sources/Types.swift; sourceTree = "<group>"; };
|
||||
26BBA1921C398E3C00BF7225 /* User.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = User.swift; path = Sources/User.swift; sourceTree = "<group>"; };
|
||||
26BBA1931C398E3C00BF7225 /* UserGroup.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UserGroup.swift; path = Sources/UserGroup.swift; sourceTree = "<group>"; };
|
||||
26DF40341C7A0FA300E19241 /* Attachment.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Attachment.swift; path = Sources/Attachment.swift; sourceTree = "<group>"; };
|
||||
26F4BAC21C9DEBD1000910BA /* Leaderboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Leaderboard.swift; sourceTree = "<group>"; };
|
||||
4307A07F1CC6D0910011D5DE /* Starscream.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Starscream.framework; path = Carthage/Build/Mac/Starscream.framework; sourceTree = "<group>"; };
|
||||
C16C98791CE7D3DD00692776 /* Client+Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Client+Utilities.swift"; path = "Sources/Client+Utilities.swift"; sourceTree = "<group>"; };
|
||||
C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Client+EventDispatching.swift"; path = "Sources/Client+EventDispatching.swift"; sourceTree = "<group>"; };
|
||||
C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Client+EventHandling.swift"; path = "Sources/Client+EventHandling.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
2601D6211C7688610012BF22 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
26072A301BB48B3A00CD650C /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
4307A0801CC6D0910011D5DE /* Starscream.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993AA1CE90EE0004A6E93 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993AB1CE90EE0004A6E93 /* Starscream.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993C91CE90EED004A6E93 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993CA1CE90EED004A6E93 /* Starscream.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
2601D6251C7688610012BF22 /* OSX-Sample */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2601D6261C7688610012BF22 /* AppDelegate.swift */,
|
||||
26F4BAC21C9DEBD1000910BA /* Leaderboard.swift */,
|
||||
2601D6281C7688610012BF22 /* Assets.xcassets */,
|
||||
2601D62A1C7688610012BF22 /* MainMenu.xib */,
|
||||
2601D62D1C7688610012BF22 /* Info.plist */,
|
||||
);
|
||||
path = "OSX-Sample";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
26072A2A1BB48B3A00CD650C = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2661A6811BBF60E60026F67B /* SlackKit */,
|
||||
2601D6251C7688610012BF22 /* OSX-Sample */,
|
||||
26072A351BB48B3A00CD650C /* Products */,
|
||||
CA70A3A1A9A1A259960DFBCF /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
26072A351BB48B3A00CD650C /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
26072A341BB48B3A00CD650C /* SlackKit.framework */,
|
||||
2601D6241C7688610012BF22 /* OSX-Sample.app */,
|
||||
263993B21CE90EE0004A6E93 /* SlackKit.framework */,
|
||||
263993D11CE90EED004A6E93 /* SlackKit.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
2661A6811BBF60E60026F67B /* SlackKit */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
26DF40341C7A0FA300E19241 /* Attachment.swift */,
|
||||
26BBA1871C398E3C00BF7225 /* Bot.swift */,
|
||||
26BBA1881C398E3C00BF7225 /* Channel.swift */,
|
||||
26BBA1891C398E3C00BF7225 /* Client.swift */,
|
||||
C1A85FF71CE3BCEF00756C40 /* Client+EventDispatching.swift */,
|
||||
C1A85FF81CE3BCEF00756C40 /* Client+EventHandling.swift */,
|
||||
C16C98791CE7D3DD00692776 /* Client+Utilities.swift */,
|
||||
26BBA18A1C398E3C00BF7225 /* Event.swift */,
|
||||
26BBA18B1C398E3C00BF7225 /* EventDelegate.swift */,
|
||||
260EC2301C4DC61D0093B253 /* Extensions.swift */,
|
||||
26BBA18E1C398E3C00BF7225 /* File.swift */,
|
||||
26BBA18F1C398E3C00BF7225 /* Message.swift */,
|
||||
260EC2311C4DC61D0093B253 /* NetworkInterface.swift */,
|
||||
260EC2321C4DC61D0093B253 /* SlackWebAPI.swift */,
|
||||
2601D61A1C7646B80012BF22 /* SlackWebAPIErrorDispatcher.swift */,
|
||||
26BBA1901C398E3C00BF7225 /* Team.swift */,
|
||||
26BBA1911C398E3C00BF7225 /* Types.swift */,
|
||||
26BBA1921C398E3C00BF7225 /* User.swift */,
|
||||
26BBA1931C398E3C00BF7225 /* UserGroup.swift */,
|
||||
268E46161CE8F7A2009F19CC /* Supporting Files */,
|
||||
);
|
||||
path = SlackKit;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
268E46161CE8F7A2009F19CC /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2661A6A41BBF62FF0026F67B /* SlackKit.h */,
|
||||
268E46151CE8F79D009F19CC /* Info.plist */,
|
||||
268E46131CE8F79D009F19CC /* Info-iOS.plist */,
|
||||
268E46141CE8F79D009F19CC /* Info-tvOS.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CA70A3A1A9A1A259960DFBCF /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4307A07F1CC6D0910011D5DE /* Starscream.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
26072A311BB48B3A00CD650C /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993901CE90C87004A6E93 /* SlackKit.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993AC1CE90EE0004A6E93 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993AD1CE90EE0004A6E93 /* SlackKit.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993CB1CE90EED004A6E93 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993CC1CE90EED004A6E93 /* SlackKit.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
2601D6231C7688610012BF22 /* OSX-Sample */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 2601D62E1C7688610012BF22 /* Build configuration list for PBXNativeTarget "OSX-Sample" */;
|
||||
buildPhases = (
|
||||
2601D6201C7688610012BF22 /* Sources */,
|
||||
2601D6211C7688610012BF22 /* Frameworks */,
|
||||
2601D6221C7688610012BF22 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "OSX-Sample";
|
||||
productName = "OSX-Sample";
|
||||
productReference = 2601D6241C7688610012BF22 /* OSX-Sample.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
26072A331BB48B3A00CD650C /* SlackKit OS X */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 26072A3C1BB48B3B00CD650C /* Build configuration list for PBXNativeTarget "SlackKit OS X" */;
|
||||
buildPhases = (
|
||||
26072A2F1BB48B3A00CD650C /* Sources */,
|
||||
26072A301BB48B3A00CD650C /* Frameworks */,
|
||||
26072A311BB48B3A00CD650C /* Headers */,
|
||||
26072A321BB48B3A00CD650C /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "SlackKit OS X";
|
||||
productName = SlackRTMKit;
|
||||
productReference = 26072A341BB48B3A00CD650C /* SlackKit.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
263993951CE90EE0004A6E93 /* SlackKit iOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 263993AF1CE90EE0004A6E93 /* Build configuration list for PBXNativeTarget "SlackKit iOS" */;
|
||||
buildPhases = (
|
||||
263993961CE90EE0004A6E93 /* Sources */,
|
||||
263993AA1CE90EE0004A6E93 /* Frameworks */,
|
||||
263993AC1CE90EE0004A6E93 /* Headers */,
|
||||
263993AE1CE90EE0004A6E93 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "SlackKit iOS";
|
||||
productName = SlackRTMKit;
|
||||
productReference = 263993B21CE90EE0004A6E93 /* SlackKit.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
263993B41CE90EED004A6E93 /* SlackKit tvOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 263993CE1CE90EED004A6E93 /* Build configuration list for PBXNativeTarget "SlackKit tvOS" */;
|
||||
buildPhases = (
|
||||
263993B51CE90EED004A6E93 /* Sources */,
|
||||
263993C91CE90EED004A6E93 /* Frameworks */,
|
||||
263993CB1CE90EED004A6E93 /* Headers */,
|
||||
263993CD1CE90EED004A6E93 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "SlackKit tvOS";
|
||||
productName = SlackRTMKit;
|
||||
productReference = 263993D11CE90EED004A6E93 /* SlackKit.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
26072A2B1BB48B3A00CD650C /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0720;
|
||||
LastUpgradeCheck = 0700;
|
||||
ORGANIZATIONNAME = "Launch Software LLC";
|
||||
TargetAttributes = {
|
||||
2601D6231C7688610012BF22 = {
|
||||
CreatedOnToolsVersion = 7.2.1;
|
||||
};
|
||||
26072A331BB48B3A00CD650C = {
|
||||
CreatedOnToolsVersion = 7.0;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 26072A2E1BB48B3A00CD650C /* Build configuration list for PBXProject "SlackKit" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
mainGroup = 26072A2A1BB48B3A00CD650C;
|
||||
productRefGroup = 26072A351BB48B3A00CD650C /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
26072A331BB48B3A00CD650C /* SlackKit OS X */,
|
||||
263993951CE90EE0004A6E93 /* SlackKit iOS */,
|
||||
263993B41CE90EED004A6E93 /* SlackKit tvOS */,
|
||||
2601D6231C7688610012BF22 /* OSX-Sample */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
2601D6221C7688610012BF22 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2601D6291C7688610012BF22 /* Assets.xcassets in Resources */,
|
||||
2601D62C1C7688610012BF22 /* MainMenu.xib in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
26072A321BB48B3A00CD650C /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993AE1CE90EE0004A6E93 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993CD1CE90EED004A6E93 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
2601D6201C7688610012BF22 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
2601D6271C7688610012BF22 /* AppDelegate.swift in Sources */,
|
||||
26F4BAC31C9DEBD1000910BA /* Leaderboard.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
26072A2F1BB48B3A00CD650C /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
C16C987A1CE7D3DD00692776 /* Client+Utilities.swift in Sources */,
|
||||
26BBA1951C398E3C00BF7225 /* Channel.swift in Sources */,
|
||||
26BBA19F1C398E3C00BF7225 /* User.swift in Sources */,
|
||||
26BBA19E1C398E3C00BF7225 /* Types.swift in Sources */,
|
||||
26BBA1961C398E3C00BF7225 /* Client.swift in Sources */,
|
||||
26BBA1971C398E3C00BF7225 /* Event.swift in Sources */,
|
||||
26BBA1941C398E3C00BF7225 /* Bot.swift in Sources */,
|
||||
C1A85FF91CE3BCEF00756C40 /* Client+EventDispatching.swift in Sources */,
|
||||
26BBA19B1C398E3C00BF7225 /* File.swift in Sources */,
|
||||
260EC2351C4DC61D0093B253 /* SlackWebAPI.swift in Sources */,
|
||||
26DF40351C7A0FA300E19241 /* Attachment.swift in Sources */,
|
||||
26BBA19C1C398E3C00BF7225 /* Message.swift in Sources */,
|
||||
26BBA19D1C398E3C00BF7225 /* Team.swift in Sources */,
|
||||
260EC2331C4DC61D0093B253 /* Extensions.swift in Sources */,
|
||||
26BBA1A01C398E3C00BF7225 /* UserGroup.swift in Sources */,
|
||||
2601D61B1C7646B80012BF22 /* SlackWebAPIErrorDispatcher.swift in Sources */,
|
||||
C1A85FFA1CE3BCEF00756C40 /* Client+EventHandling.swift in Sources */,
|
||||
260EC2341C4DC61D0093B253 /* NetworkInterface.swift in Sources */,
|
||||
26BBA1981C398E3C00BF7225 /* EventDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993961CE90EE0004A6E93 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993971CE90EE0004A6E93 /* Client+Utilities.swift in Sources */,
|
||||
263993981CE90EE0004A6E93 /* Channel.swift in Sources */,
|
||||
263993991CE90EE0004A6E93 /* User.swift in Sources */,
|
||||
2639939A1CE90EE0004A6E93 /* Types.swift in Sources */,
|
||||
2639939B1CE90EE0004A6E93 /* Client.swift in Sources */,
|
||||
2639939C1CE90EE0004A6E93 /* Event.swift in Sources */,
|
||||
2639939D1CE90EE0004A6E93 /* Bot.swift in Sources */,
|
||||
2639939E1CE90EE0004A6E93 /* Client+EventDispatching.swift in Sources */,
|
||||
2639939F1CE90EE0004A6E93 /* File.swift in Sources */,
|
||||
263993A01CE90EE0004A6E93 /* SlackWebAPI.swift in Sources */,
|
||||
263993A11CE90EE0004A6E93 /* Attachment.swift in Sources */,
|
||||
263993A21CE90EE0004A6E93 /* Message.swift in Sources */,
|
||||
263993A31CE90EE0004A6E93 /* Team.swift in Sources */,
|
||||
263993A41CE90EE0004A6E93 /* Extensions.swift in Sources */,
|
||||
263993A51CE90EE0004A6E93 /* UserGroup.swift in Sources */,
|
||||
263993A61CE90EE0004A6E93 /* SlackWebAPIErrorDispatcher.swift in Sources */,
|
||||
263993A71CE90EE0004A6E93 /* Client+EventHandling.swift in Sources */,
|
||||
263993A81CE90EE0004A6E93 /* NetworkInterface.swift in Sources */,
|
||||
263993A91CE90EE0004A6E93 /* EventDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
263993B51CE90EED004A6E93 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
263993B61CE90EED004A6E93 /* Client+Utilities.swift in Sources */,
|
||||
263993B71CE90EED004A6E93 /* Channel.swift in Sources */,
|
||||
263993B81CE90EED004A6E93 /* User.swift in Sources */,
|
||||
263993B91CE90EED004A6E93 /* Types.swift in Sources */,
|
||||
263993BA1CE90EED004A6E93 /* Client.swift in Sources */,
|
||||
263993BB1CE90EED004A6E93 /* Event.swift in Sources */,
|
||||
263993BC1CE90EED004A6E93 /* Bot.swift in Sources */,
|
||||
263993BD1CE90EED004A6E93 /* Client+EventDispatching.swift in Sources */,
|
||||
263993BE1CE90EED004A6E93 /* File.swift in Sources */,
|
||||
263993BF1CE90EED004A6E93 /* SlackWebAPI.swift in Sources */,
|
||||
263993C01CE90EED004A6E93 /* Attachment.swift in Sources */,
|
||||
263993C11CE90EED004A6E93 /* Message.swift in Sources */,
|
||||
263993C21CE90EED004A6E93 /* Team.swift in Sources */,
|
||||
263993C31CE90EED004A6E93 /* Extensions.swift in Sources */,
|
||||
263993C41CE90EED004A6E93 /* UserGroup.swift in Sources */,
|
||||
263993C51CE90EED004A6E93 /* SlackWebAPIErrorDispatcher.swift in Sources */,
|
||||
263993C61CE90EED004A6E93 /* Client+EventHandling.swift in Sources */,
|
||||
263993C71CE90EED004A6E93 /* NetworkInterface.swift in Sources */,
|
||||
263993C81CE90EED004A6E93 /* EventDelegate.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
2601D62A1C7688610012BF22 /* MainMenu.xib */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
2601D62B1C7688610012BF22 /* Base */,
|
||||
);
|
||||
name = MainMenu.xib;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXVariantGroup section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
2601D62F1C7688610012BF22 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
INFOPLIST_FILE = "OSX-Sample/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "LS.OSX-Sample";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
2601D6301C7688610012BF22 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CODE_SIGN_IDENTITY = "-";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
INFOPLIST_FILE = "OSX-Sample/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "LS.OSX-Sample";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
26072A3A1BB48B3B00CD650C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
26072A3B1BB48B3B00CD650C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.11;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
26072A3D1BB48B3B00CD650C /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/Mac",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
26072A3E1BB48B3B00CD650C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/Mac",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SKIP_INSTALL = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
263993B01CE90EE0004A6E93 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/iOS",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info-iOS.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
263993B11CE90EE0004A6E93 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/iOS",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info-iOS.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
263993CF1CE90EED004A6E93 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/tvOS",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info-tvOS.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
263993D01CE90EED004A6E93 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)/Carthage/Build/tvOS",
|
||||
);
|
||||
FRAMEWORK_VERSION = A;
|
||||
INFOPLIST_FILE = "$(SRCROOT)/SlackKit/Supporting Files/Info-tvOS.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.launchsoft.SlackKit;
|
||||
PRODUCT_NAME = SlackKit;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
SUPPORTED_PLATFORMS = "appletvsimulator appletvos";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
2601D62E1C7688610012BF22 /* Build configuration list for PBXNativeTarget "OSX-Sample" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
2601D62F1C7688610012BF22 /* Debug */,
|
||||
2601D6301C7688610012BF22 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
26072A2E1BB48B3A00CD650C /* Build configuration list for PBXProject "SlackKit" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
26072A3A1BB48B3B00CD650C /* Debug */,
|
||||
26072A3B1BB48B3B00CD650C /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
26072A3C1BB48B3B00CD650C /* Build configuration list for PBXNativeTarget "SlackKit OS X" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
26072A3D1BB48B3B00CD650C /* Debug */,
|
||||
26072A3E1BB48B3B00CD650C /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
263993AF1CE90EE0004A6E93 /* Build configuration list for PBXNativeTarget "SlackKit iOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
263993B01CE90EE0004A6E93 /* Debug */,
|
||||
263993B11CE90EE0004A6E93 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
263993CE1CE90EED004A6E93 /* Build configuration list for PBXNativeTarget "SlackKit tvOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
263993CF1CE90EED004A6E93 /* Debug */,
|
||||
263993D01CE90EED004A6E93 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 26072A2B1BB48B3A00CD650C /* Project object */;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:SlackRTMKit.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "26072A331BB48B3A00CD650C"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit OS X"
|
||||
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>
|
||||
<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 = "26072A331BB48B3A00CD650C"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit OS X"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "26072A331BB48B3A00CD650C"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit OS X"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993951CE90EE0004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit iOS"
|
||||
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>
|
||||
<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 = "263993951CE90EE0004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit iOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993951CE90EE0004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit iOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,80 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0730"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993B41CE90EED004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit tvOS"
|
||||
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>
|
||||
<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 = "263993B41CE90EED004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit tvOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "263993B41CE90EED004A6E93"
|
||||
BuildableName = "SlackKit.framework"
|
||||
BlueprintName = "SlackKit tvOS"
|
||||
ReferencedContainer = "container:SlackKit.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.1.1</string>
|
||||
<string>1.0.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// Action.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct Action {
|
||||
|
||||
public let name: String?
|
||||
public let text: String?
|
||||
public let type: String?
|
||||
public let value: String?
|
||||
public let style: ActionStyle?
|
||||
public let confirm: Confirm?
|
||||
|
||||
internal init(action:[String: Any]?) {
|
||||
name = action?["name"] as? String
|
||||
text = action?["text"] as? String
|
||||
type = action?["type"] as? String
|
||||
value = action?["value"] as? String
|
||||
style = ActionStyle(rawValue: action?["style"] as? String ?? "")
|
||||
confirm = Confirm(confirm:action?["confirm"] as? [String: Any])
|
||||
}
|
||||
|
||||
public init(name: String, text: String, style: ActionStyle = .defaultStyle, value: String? = nil, confirm: Confirm? = nil) {
|
||||
self.type = "button"
|
||||
self.name = name
|
||||
self.text = text
|
||||
self.value = value
|
||||
self.style = style
|
||||
self.confirm = confirm
|
||||
}
|
||||
|
||||
internal var dictionary: [String: Any] {
|
||||
var dict = [String: Any]()
|
||||
dict["name"] = name
|
||||
dict["text"] = text
|
||||
dict["type"] = type
|
||||
dict["value"] = value
|
||||
dict["style"] = style?.rawValue
|
||||
dict["confirm"] = confirm?.dictionary
|
||||
return dict
|
||||
}
|
||||
|
||||
public struct Confirm {
|
||||
|
||||
public let title: String?
|
||||
public let text: String?
|
||||
public let okText: String?
|
||||
public let dismissText: String?
|
||||
|
||||
internal init(confirm:[String: Any]?) {
|
||||
title = confirm?["title"] as? String
|
||||
text = confirm?["text"] as? String
|
||||
okText = confirm?["ok_text"] as? String
|
||||
dismissText = confirm?["dismiss_text"] as? String
|
||||
}
|
||||
|
||||
public init(text: String, title: String? = nil, okText: String? = nil, dismissText: String? = nil) {
|
||||
self.text = text
|
||||
self.title = title
|
||||
self.okText = okText
|
||||
self.dismissText = dismissText
|
||||
}
|
||||
|
||||
internal var dictionary: [String: Any] {
|
||||
var dict = [String: Any]()
|
||||
dict["title"] = title
|
||||
dict["text"] = text
|
||||
dict["ok_text"] = okText
|
||||
dict["dismiss_text"] = dismissText
|
||||
return dict
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ActionStyle: String {
|
||||
case defaultStyle = "default"
|
||||
case primary = "primary"
|
||||
case danger = "danger"
|
||||
}
|
||||
|
||||
public enum ResponseType: String {
|
||||
case inChannel = "in_channel"
|
||||
case ephemeral = "ephemeral"
|
||||
}
|
||||
@@ -21,11 +21,11 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
public struct Attachment {
|
||||
|
||||
public let fallback: String?
|
||||
public let callbackID: String?
|
||||
public let type: String?
|
||||
public let color: String?
|
||||
public let pretext: String?
|
||||
public let authorName: String?
|
||||
@@ -35,14 +35,17 @@ public struct Attachment {
|
||||
public let titleLink: String?
|
||||
public let text: String?
|
||||
public let fields: [AttachmentField]?
|
||||
public let actions: [Action]?
|
||||
public let imageURL: String?
|
||||
public let thumbURL: String?
|
||||
public let footer: String?
|
||||
public let footerIcon: String?
|
||||
public let ts: Int?
|
||||
|
||||
internal init(attachment: [String: AnyObject]?) {
|
||||
|
||||
internal init(attachment: [String: Any]?) {
|
||||
fallback = attachment?["fallback"] as? String
|
||||
callbackID = attachment?["callback_id"] as? String
|
||||
type = attachment?["attachment_type"] as? String
|
||||
color = attachment?["color"] as? String
|
||||
pretext = attachment?["pretext"] as? String
|
||||
authorName = attachment?["author_name"] as? String
|
||||
@@ -56,11 +59,14 @@ public struct Attachment {
|
||||
footer = attachment?["footer"] as? String
|
||||
footerIcon = attachment?["footer_icon"] as? String
|
||||
ts = attachment?["ts"] as? Int
|
||||
fields = (attachment?["fields"] as? [[String: AnyObject]])?.map { AttachmentField(field: $0) }
|
||||
fields = (attachment?["fields"] as? [[String: Any]])?.map { AttachmentField(field: $0) }
|
||||
actions = (attachment?["actions"] as? [[String: Any]])?.map { Action(action: $0) }
|
||||
}
|
||||
|
||||
public init(fallback: String, title:String, colorHex: String? = nil, pretext: String? = nil, authorName: String? = nil, authorLink: String? = nil, authorIcon: String? = nil, titleLink: String? = nil, text: String? = nil, fields: [AttachmentField]? = nil, imageURL: String? = nil, thumbURL: String? = nil, footer: String? = nil, footerIcon:String? = nil, ts:Int? = nil) {
|
||||
public init(fallback: String, title:String, callbackID: String? = nil, type: String? = nil, colorHex: String? = nil, pretext: String? = nil, authorName: String? = nil, authorLink: String? = nil, authorIcon: String? = nil, titleLink: String? = nil, text: String? = nil, fields: [AttachmentField]? = nil, actions: [Action]? = nil, imageURL: String? = nil, thumbURL: String? = nil, footer: String? = nil, footerIcon:String? = nil, ts:Int? = nil) {
|
||||
self.fallback = fallback
|
||||
self.callbackID = callbackID
|
||||
self.type = type
|
||||
self.color = colorHex
|
||||
self.pretext = pretext
|
||||
self.authorName = authorName
|
||||
@@ -70,6 +76,7 @@ public struct Attachment {
|
||||
self.titleLink = titleLink
|
||||
self.text = text
|
||||
self.fields = fields
|
||||
self.actions = actions
|
||||
self.imageURL = imageURL
|
||||
self.thumbURL = thumbURL
|
||||
self.footer = footer
|
||||
@@ -77,9 +84,11 @@ public struct Attachment {
|
||||
self.ts = ts
|
||||
}
|
||||
|
||||
internal func dictionary() -> [String: AnyObject] {
|
||||
var attachment = [String: AnyObject]()
|
||||
internal var dictionary: [String: Any] {
|
||||
var attachment = [String: Any]()
|
||||
attachment["fallback"] = fallback
|
||||
attachment["callback_id"] = callbackID
|
||||
attachment["attachment_type"] = type
|
||||
attachment["color"] = color
|
||||
attachment["pretext"] = pretext
|
||||
attachment["authorName"] = authorName
|
||||
@@ -88,7 +97,8 @@ public struct Attachment {
|
||||
attachment["title"] = title
|
||||
attachment["title_link"] = titleLink
|
||||
attachment["text"] = text
|
||||
attachment["fields"] = fieldJSONArray(fields)
|
||||
attachment["fields"] = fields?.map{$0.dictionary}
|
||||
attachment["actions"] = actions?.map{$0.dictionary}
|
||||
attachment["image_url"] = imageURL
|
||||
attachment["thumb_url"] = thumbURL
|
||||
attachment["footer"] = footer
|
||||
@@ -96,49 +106,10 @@ public struct Attachment {
|
||||
attachment["ts"] = ts
|
||||
return attachment
|
||||
}
|
||||
|
||||
private func fieldJSONArray(fields: [AttachmentField]?) -> [[String: AnyObject]] {
|
||||
var returnValue = [[String: AnyObject]]()
|
||||
if let f = fields {
|
||||
for field in f {
|
||||
returnValue.append(field.dictionary())
|
||||
}
|
||||
}
|
||||
return returnValue
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct AttachmentField {
|
||||
|
||||
public let title: String?
|
||||
public let value: String?
|
||||
public let short: Bool?
|
||||
|
||||
internal init(field: [String: AnyObject]?) {
|
||||
title = field?["title"] as? String
|
||||
value = field?["value"] as? String
|
||||
short = field?["short"] as? Bool
|
||||
}
|
||||
|
||||
public init(title:String, value:String, short: Bool? = nil) {
|
||||
self.title = title
|
||||
self.value = value.slackFormatEscaping()
|
||||
self.short = short
|
||||
}
|
||||
|
||||
internal func dictionary() -> [String: AnyObject] {
|
||||
var field = [String: AnyObject]()
|
||||
field["title"] = title
|
||||
field["value"] = value
|
||||
field["short"] = short
|
||||
return field
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum AttachmentColor: String {
|
||||
case Good = "good"
|
||||
case Warning = "warning"
|
||||
case Danger = "danger"
|
||||
case good = "good"
|
||||
case warning = "warning"
|
||||
case danger = "danger"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// AttachmentField.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct AttachmentField {
|
||||
|
||||
public let title: String?
|
||||
public let value: String?
|
||||
public let short: Bool?
|
||||
|
||||
internal init(field: [String: Any]?) {
|
||||
title = field?["title"] as? String
|
||||
value = field?["value"] as? String
|
||||
short = field?["short"] as? Bool
|
||||
}
|
||||
|
||||
public init(title:String, value:String, short: Bool? = nil) {
|
||||
self.title = title
|
||||
self.value = value.slackFormatEscaping
|
||||
self.short = short
|
||||
}
|
||||
|
||||
internal var dictionary: [String: Any] {
|
||||
var field = [String: Any]()
|
||||
field["title"] = title
|
||||
field["value"] = value
|
||||
field["short"] = short
|
||||
return field
|
||||
}
|
||||
}
|
||||
@@ -24,13 +24,18 @@
|
||||
public struct Bot {
|
||||
|
||||
public let id: String?
|
||||
internal(set) public var botToken: String?
|
||||
internal(set) public var name: String?
|
||||
internal(set) public var icons: [String: AnyObject]?
|
||||
internal(set) public var icons: [String: Any]?
|
||||
|
||||
internal init(bot: [String: AnyObject]?) {
|
||||
internal init(bot: [String: Any]?) {
|
||||
id = bot?["id"] as? String
|
||||
name = bot?["name"] as? String
|
||||
icons = bot?["icons"] as? [String: AnyObject]
|
||||
icons = bot?["icons"] as? [String: Any]
|
||||
}
|
||||
|
||||
internal init(botUser: [String: Any]?) {
|
||||
id = botUser?["bot_user_id"] as? String
|
||||
botToken = botUser?["bot_access_token"] as? String
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@ public struct Channel {
|
||||
internal(set) public var topic: Topic?
|
||||
internal(set) public var purpose: Topic?
|
||||
internal(set) public var isMember: Bool?
|
||||
internal(set) public var lastRead: String?
|
||||
public var lastRead: String?
|
||||
internal(set) public var latest: Message?
|
||||
internal(set) public var unread: Int?
|
||||
internal(set) public var unreadCountDisplay: Int?
|
||||
public var unread: Int?
|
||||
public var unreadCountDisplay: Int?
|
||||
internal(set) public var hasPins: Bool?
|
||||
internal(set) public var members: [String]?
|
||||
// Client use
|
||||
@@ -49,7 +49,7 @@ public struct Channel {
|
||||
internal(set) public var usersTyping = [String]()
|
||||
internal(set) public var messages = [String: Message]()
|
||||
|
||||
internal init(channel: [String: AnyObject]?) {
|
||||
internal init(channel: [String: Any]?) {
|
||||
id = channel?["id"] as? String
|
||||
name = channel?["name"] as? String
|
||||
created = channel?["created"] as? Int
|
||||
@@ -62,17 +62,17 @@ public struct Channel {
|
||||
isUserDeleted = channel?["is_user_deleted"] as? Bool
|
||||
user = channel?["user"] as? String
|
||||
isOpen = channel?["is_open"] as? Bool
|
||||
topic = Topic(topic: channel?["topic"] as? [String: AnyObject])
|
||||
purpose = Topic(topic: channel?["purpose"] as? [String: AnyObject])
|
||||
topic = Topic(topic: channel?["topic"] as? [String: Any])
|
||||
purpose = Topic(topic: channel?["purpose"] as? [String: Any])
|
||||
isMember = channel?["is_member"] as? Bool
|
||||
lastRead = channel?["last_read"] as? String
|
||||
unread = channel?["unread_count"] as? Int
|
||||
unreadCountDisplay = channel?["unread_count_display"] as? Int
|
||||
hasPins = channel?["has_pins"] as? Bool
|
||||
members = channel?["members"] as? [String]
|
||||
|
||||
if let latestMsgDictionary = channel?["latest"] as? [String: AnyObject] {
|
||||
latest = Message(message: latestMsgDictionary)
|
||||
|
||||
if let latestMesssageDictionary = channel?["latest"] as? [String: Any] {
|
||||
latest = Message(dictionary: latestMesssageDictionary)
|
||||
} else {
|
||||
latest = Message(ts: channel?["latest"] as? String)
|
||||
}
|
||||
|
||||
@@ -21,157 +21,154 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
internal extension Client {
|
||||
|
||||
func dispatch(event: [String: AnyObject]) {
|
||||
let event = Event(event: event)
|
||||
guard let type = event.type else {
|
||||
return
|
||||
}
|
||||
internal extension SlackClient {
|
||||
|
||||
func dispatch(_ anEvent: [String: Any]) {
|
||||
let event = Event(anEvent)
|
||||
let type = event.type ?? .unknown
|
||||
switch type {
|
||||
case .Hello:
|
||||
case .hello:
|
||||
connected = true
|
||||
slackEventsDelegate?.clientConnected()
|
||||
case .Ok:
|
||||
pingRTMServer()
|
||||
connectionEventsDelegate?.connected(self)
|
||||
case .ok:
|
||||
messageSent(event)
|
||||
case .Message:
|
||||
case .message:
|
||||
if (event.subtype != nil) {
|
||||
messageDispatcher(event)
|
||||
} else {
|
||||
messageReceived(event)
|
||||
}
|
||||
case .UserTyping:
|
||||
case .userTyping:
|
||||
userTyping(event)
|
||||
case .ChannelMarked, .IMMarked, .GroupMarked:
|
||||
case .channelMarked, .imMarked, .groupMarked:
|
||||
channelMarked(event)
|
||||
case .ChannelCreated, .IMCreated:
|
||||
case .channelCreated, .imCreated:
|
||||
channelCreated(event)
|
||||
case .ChannelJoined, .GroupJoined:
|
||||
case .channelJoined, .groupJoined:
|
||||
channelJoined(event)
|
||||
case .ChannelLeft, .GroupLeft:
|
||||
case .channelLeft, .groupLeft:
|
||||
channelLeft(event)
|
||||
case .ChannelDeleted:
|
||||
case .channelDeleted:
|
||||
channelDeleted(event)
|
||||
case .ChannelRenamed, .GroupRename:
|
||||
case .channelRenamed, .groupRename:
|
||||
channelRenamed(event)
|
||||
case .ChannelArchive, .GroupArchive:
|
||||
case .channelArchive, .groupArchive:
|
||||
channelArchived(event, archived: true)
|
||||
case .ChannelUnarchive, .GroupUnarchive:
|
||||
case .channelUnarchive, .groupUnarchive:
|
||||
channelArchived(event, archived: false)
|
||||
case .ChannelHistoryChanged, .IMHistoryChanged, .GroupHistoryChanged:
|
||||
case .channelHistoryChanged, .imHistoryChanged, .groupHistoryChanged:
|
||||
channelHistoryChanged(event)
|
||||
case .DNDUpdated:
|
||||
case .dndUpdated:
|
||||
doNotDisturbUpdated(event)
|
||||
case .DNDUpatedUser:
|
||||
case .dndUpatedUser:
|
||||
doNotDisturbUserUpdated(event)
|
||||
case .IMOpen, .GroupOpen:
|
||||
case .imOpen, .groupOpen:
|
||||
open(event, open: true)
|
||||
case .IMClose, .GroupClose:
|
||||
case .imClose, .groupClose:
|
||||
open(event, open: false)
|
||||
case .FileCreated:
|
||||
case .fileCreated:
|
||||
processFile(event)
|
||||
case .FileShared:
|
||||
case .fileShared:
|
||||
processFile(event)
|
||||
case .FileUnshared:
|
||||
case .fileUnshared:
|
||||
processFile(event)
|
||||
case .FilePublic:
|
||||
case .filePublic:
|
||||
processFile(event)
|
||||
case .FilePrivate:
|
||||
case .filePrivate:
|
||||
filePrivate(event)
|
||||
case .FileChanged:
|
||||
case .fileChanged:
|
||||
processFile(event)
|
||||
case .FileDeleted:
|
||||
case .fileDeleted:
|
||||
deleteFile(event)
|
||||
case .FileCommentAdded:
|
||||
case .fileCommentAdded:
|
||||
fileCommentAdded(event)
|
||||
case .FileCommentEdited:
|
||||
case .fileCommentEdited:
|
||||
fileCommentEdited(event)
|
||||
case .FileCommentDeleted:
|
||||
case .fileCommentDeleted:
|
||||
fileCommentDeleted(event)
|
||||
case .PinAdded:
|
||||
case .pinAdded:
|
||||
pinAdded(event)
|
||||
case .PinRemoved:
|
||||
case .pinRemoved:
|
||||
pinRemoved(event)
|
||||
case .Pong:
|
||||
case .pong:
|
||||
pong(event)
|
||||
case .PresenceChange:
|
||||
case .presenceChange:
|
||||
presenceChange(event)
|
||||
case .ManualPresenceChange:
|
||||
case .manualPresenceChange:
|
||||
manualPresenceChange(event)
|
||||
case .PrefChange:
|
||||
case .prefChange:
|
||||
changePreference(event)
|
||||
case .UserChange:
|
||||
case .userChange:
|
||||
userChange(event)
|
||||
case .TeamJoin:
|
||||
case .teamJoin:
|
||||
teamJoin(event)
|
||||
case .StarAdded:
|
||||
case .starAdded:
|
||||
itemStarred(event, star: true)
|
||||
case .StarRemoved:
|
||||
case .starRemoved:
|
||||
itemStarred(event, star: false)
|
||||
case .ReactionAdded:
|
||||
case .reactionAdded:
|
||||
addedReaction(event)
|
||||
case .ReactionRemoved:
|
||||
case .reactionRemoved:
|
||||
removedReaction(event)
|
||||
case .EmojiChanged:
|
||||
case .emojiChanged:
|
||||
emojiChanged(event)
|
||||
case .CommandsChanged:
|
||||
// This functionality is only used by our web client.
|
||||
// The other APIs required to support slash command metadata are currently unstable.
|
||||
case .commandsChanged:
|
||||
// This functionality is only used by our web client.
|
||||
// The other APIs required to support slash command metadata are currently unstable.
|
||||
// Until they are released other clients should ignore this event.
|
||||
break
|
||||
case .TeamPlanChange:
|
||||
case .teamPlanChange:
|
||||
teamPlanChange(event)
|
||||
case .TeamPrefChange:
|
||||
case .teamPrefChange:
|
||||
teamPreferenceChange(event)
|
||||
case .TeamRename:
|
||||
case .teamRename:
|
||||
teamNameChange(event)
|
||||
case .TeamDomainChange:
|
||||
case .teamDomainChange:
|
||||
teamDomainChange(event)
|
||||
case .EmailDomainChange:
|
||||
case .emailDomainChange:
|
||||
emailDomainChange(event)
|
||||
case .TeamProfileChange:
|
||||
case .teamProfileChange:
|
||||
teamProfileChange(event)
|
||||
case .TeamProfileDelete:
|
||||
case .teamProfileDelete:
|
||||
teamProfileDeleted(event)
|
||||
case .TeamProfileReorder:
|
||||
case .teamProfileReorder:
|
||||
teamProfileReordered(event)
|
||||
case .BotAdded:
|
||||
case .botAdded:
|
||||
bot(event)
|
||||
case .BotChanged:
|
||||
case .botChanged:
|
||||
bot(event)
|
||||
case .AccountsChanged:
|
||||
case .accountsChanged:
|
||||
// The accounts_changed event is used by our web client to maintain a list of logged-in accounts.
|
||||
// Other clients should ignore this event.
|
||||
break
|
||||
case .TeamMigrationStarted:
|
||||
case .teamMigrationStarted:
|
||||
connect(pingInterval: pingInterval, timeout: timeout, reconnect: reconnect)
|
||||
case .ReconnectURL:
|
||||
case .reconnectURL:
|
||||
// The reconnect_url event is currently unsupported and experimental.
|
||||
break
|
||||
case .SubteamCreated, .SubteamUpdated:
|
||||
case .subteamCreated, .subteamUpdated:
|
||||
subteam(event)
|
||||
case .SubteamSelfAdded:
|
||||
case .subteamSelfAdded:
|
||||
subteamAddedSelf(event)
|
||||
case.SubteamSelfRemoved:
|
||||
case .subteamSelfRemoved:
|
||||
subteamRemovedSelf(event)
|
||||
case .Error:
|
||||
print("Error: \(event)")
|
||||
break
|
||||
case .unknown:
|
||||
print("Unknown event of type: \(anEvent["type"] ?? "No Type Information")")
|
||||
}
|
||||
}
|
||||
|
||||
func messageDispatcher(event:Event) {
|
||||
guard let value = event.subtype, subtype = MessageSubtype(rawValue:value) else {
|
||||
func messageDispatcher(_ event:Event) {
|
||||
guard let value = event.subtype, let subtype = MessageSubtype(rawValue:value) else {
|
||||
return
|
||||
}
|
||||
switch subtype {
|
||||
case .MessageChanged:
|
||||
case .messageChanged:
|
||||
messageChanged(event)
|
||||
case .MessageDeleted:
|
||||
case .messageDeleted:
|
||||
messageDeleted(event)
|
||||
default:
|
||||
messageReceived(event)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,258 +22,259 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
import Dispatch
|
||||
|
||||
internal extension Client {
|
||||
|
||||
internal extension SlackClient {
|
||||
|
||||
//MARK: - Pong
|
||||
func pong(event: Event) {
|
||||
func pong(_ event: Event) {
|
||||
pong = event.replyTo
|
||||
}
|
||||
|
||||
//MARK: - Messages
|
||||
func messageSent(event: Event) {
|
||||
guard let reply = event.replyTo, message = sentMessages[NSNumber(double: reply).stringValue], channel = message.channel, ts = message.ts else {
|
||||
func messageSent(_ event: Event) {
|
||||
guard let reply = event.replyTo, let message = sentMessages[NSNumber(value: reply).stringValue], let channel = message.channel, let ts = message.ts else {
|
||||
return
|
||||
}
|
||||
|
||||
message.ts = event.ts
|
||||
message.text = event.text
|
||||
channels[channel]?.messages[ts] = message
|
||||
messageEventsDelegate?.messageSent(message)
|
||||
messageEventsDelegate?.sent(message, client: self)
|
||||
}
|
||||
|
||||
func messageReceived(event: Event) {
|
||||
guard let channel = event.channel, message = event.message, id = channel.id, ts = message.ts else {
|
||||
func messageReceived(_ event: Event) {
|
||||
guard let channel = event.channel, let message = event.message, let id = channel.id, let ts = message.ts else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.messages[ts] = message
|
||||
messageEventsDelegate?.messageReceived(message)
|
||||
messageEventsDelegate?.received(message, client:self)
|
||||
}
|
||||
|
||||
func messageChanged(event: Event) {
|
||||
guard let id = event.channel?.id, nested = event.nestedMessage, ts = nested.ts else {
|
||||
func messageChanged(_ event: Event) {
|
||||
guard let id = event.channel?.id, let nested = event.nestedMessage, let ts = nested.ts else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.messages[ts] = nested
|
||||
messageEventsDelegate?.messageChanged(nested)
|
||||
messageEventsDelegate?.changed(nested, client:self)
|
||||
}
|
||||
|
||||
func messageDeleted(event: Event) {
|
||||
guard let id = event.channel?.id, key = event.message?.deletedTs, message = channels[id]?.messages[key] else {
|
||||
func messageDeleted(_ event: Event) {
|
||||
guard let id = event.channel?.id, let key = event.message?.deletedTs, let message = channels[id]?.messages[key] else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.messages.removeValueForKey(key)
|
||||
messageEventsDelegate?.messageDeleted(message)
|
||||
_ = channels[id]?.messages.removeValue(forKey: key)
|
||||
messageEventsDelegate?.deleted(message, client:self)
|
||||
}
|
||||
|
||||
//MARK: - Channels
|
||||
func userTyping(event: Event) {
|
||||
guard let channel = event.channel, channelID = channel.id, user = event.user, userID = user.id where
|
||||
channels.indexForKey(channelID) != nil && !channels[channelID]!.usersTyping.contains(userID) else {
|
||||
return
|
||||
func userTyping(_ event: Event) {
|
||||
guard let channel = event.channel, let channelID = channel.id, let user = event.user, let userID = user.id ,
|
||||
channels.index(forKey: channelID) != nil && !channels[channelID]!.usersTyping.contains(userID) else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
channels[channelID]?.usersTyping.append(userID)
|
||||
channelEventsDelegate?.userTyping(channel, user: user)
|
||||
|
||||
let timeout = dispatch_time(DISPATCH_TIME_NOW, Int64(5.0 * Double(NSEC_PER_SEC)))
|
||||
dispatch_after(timeout, dispatch_get_main_queue()) {
|
||||
if let index = self.channels[channelID]?.usersTyping.indexOf(userID) {
|
||||
self.channels[channelID]?.usersTyping.removeAtIndex(index)
|
||||
channelEventsDelegate?.userTypingIn(channel, user: user, client: self)
|
||||
|
||||
let timeout = DispatchTime.now() + Double(Int64(5.0 * Double(CLOCKS_PER_SEC))) / Double(CLOCKS_PER_SEC)
|
||||
DispatchQueue.main.asyncAfter(deadline: timeout, execute: {
|
||||
if let index = self.channels[channelID]?.usersTyping.index(of: userID) {
|
||||
self.channels[channelID]?.usersTyping.remove(at: index)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func channelMarked(event: Event) {
|
||||
guard let channel = event.channel, id = channel.id, timestamp = event.ts else {
|
||||
|
||||
func channelMarked(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id, let timestamp = event.ts else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.lastRead = event.ts
|
||||
channelEventsDelegate?.channelMarked(channel, timestamp: timestamp)
|
||||
channelEventsDelegate?.marked(channel, timestamp: timestamp, client: self)
|
||||
}
|
||||
|
||||
func channelCreated(event: Event) {
|
||||
guard let channel = event.channel, id = channel.id else {
|
||||
func channelCreated(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id] = channel
|
||||
channelEventsDelegate?.channelCreated(channel)
|
||||
channelEventsDelegate?.created(channel, client: self)
|
||||
}
|
||||
|
||||
func channelDeleted(event: Event) {
|
||||
guard let channel = event.channel, id = channel.id else {
|
||||
func channelDeleted(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels.removeValueForKey(id)
|
||||
channelEventsDelegate?.channelDeleted(channel)
|
||||
channels.removeValue(forKey: id)
|
||||
channelEventsDelegate?.deleted(channel, client: self)
|
||||
}
|
||||
|
||||
func channelJoined(event: Event) {
|
||||
guard let channel = event.channel, id = channel.id else {
|
||||
func channelJoined(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id] = event.channel
|
||||
channelEventsDelegate?.channelJoined(channel)
|
||||
channelEventsDelegate?.joined(channel, client: self)
|
||||
}
|
||||
|
||||
func channelLeft(event: Event) {
|
||||
guard let channel = event.channel, id = channel.id else {
|
||||
func channelLeft(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
if let userID = authenticatedUser?.id, index = channels[id]?.members?.indexOf(userID) {
|
||||
channels[id]?.members?.removeAtIndex(index)
|
||||
if let userID = authenticatedUser?.id, let index = channels[id]?.members?.index(of: userID) {
|
||||
channels[id]?.members?.remove(at: index)
|
||||
}
|
||||
channelEventsDelegate?.channelLeft(channel)
|
||||
channelEventsDelegate?.left(channel, client: self)
|
||||
}
|
||||
|
||||
func channelRenamed(event: Event) {
|
||||
guard let channel = event.channel, id = channel.id else {
|
||||
func channelRenamed(_ event: Event) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.name = channel.name
|
||||
channelEventsDelegate?.channelRenamed(channel)
|
||||
channelEventsDelegate?.renamed(channel, client: self)
|
||||
}
|
||||
|
||||
func channelArchived(event: Event, archived: Bool) {
|
||||
guard let channel = event.channel, id = channel.id else {
|
||||
func channelArchived(_ event: Event, archived: Bool) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.isArchived = archived
|
||||
channelEventsDelegate?.channelArchived(channel)
|
||||
channelEventsDelegate?.archived(channel, client: self)
|
||||
}
|
||||
|
||||
func channelHistoryChanged(event: Event) {
|
||||
func channelHistoryChanged(_ event: Event) {
|
||||
guard let channel = event.channel else {
|
||||
return
|
||||
}
|
||||
channelEventsDelegate?.channelHistoryChanged(channel)
|
||||
channelEventsDelegate?.historyChanged(channel, client: self)
|
||||
}
|
||||
|
||||
//MARK: - Do Not Disturb
|
||||
func doNotDisturbUpdated(event: Event) {
|
||||
func doNotDisturbUpdated(_ event: Event) {
|
||||
guard let dndStatus = event.dndStatus else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.doNotDisturbStatus = dndStatus
|
||||
doNotDisturbEventsDelegate?.doNotDisturbUpdated(dndStatus)
|
||||
doNotDisturbEventsDelegate?.updated(dndStatus, client: self)
|
||||
}
|
||||
|
||||
func doNotDisturbUserUpdated(event: Event) {
|
||||
guard let dndStatus = event.dndStatus, user = event.user, id = user.id else {
|
||||
func doNotDisturbUserUpdated(_ event: Event) {
|
||||
guard let dndStatus = event.dndStatus, let user = event.user, let id = user.id else {
|
||||
return
|
||||
}
|
||||
|
||||
users[id]?.doNotDisturbStatus = dndStatus
|
||||
doNotDisturbEventsDelegate?.doNotDisturbUserUpdated(dndStatus, user: user)
|
||||
doNotDisturbEventsDelegate?.userUpdated(dndStatus, user: user, client: self)
|
||||
}
|
||||
|
||||
//MARK: - IM & Group Open/Close
|
||||
func open(event: Event, open: Bool) {
|
||||
guard let channel = event.channel, id = channel.id else {
|
||||
func open(_ event: Event, open: Bool) {
|
||||
guard let channel = event.channel, let id = channel.id else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.isOpen = open
|
||||
groupEventsDelegate?.groupOpened(channel)
|
||||
groupEventsDelegate?.opened(channel, client: self)
|
||||
}
|
||||
|
||||
//MARK: - Files
|
||||
func processFile(event: Event) {
|
||||
guard let file = event.file, id = file.id else {
|
||||
func processFile(_ event: Event) {
|
||||
guard let file = event.file, let id = file.id else {
|
||||
return
|
||||
}
|
||||
if let comment = file.initialComment, commentID = comment.id {
|
||||
if let comment = file.initialComment, let commentID = comment.id {
|
||||
if files[id]?.comments[commentID] == nil {
|
||||
files[id]?.comments[commentID] = comment
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
files[id] = file
|
||||
fileEventsDelegate?.fileProcessed(file)
|
||||
fileEventsDelegate?.processed(file, client: self)
|
||||
}
|
||||
|
||||
func filePrivate(event: Event) {
|
||||
guard let file = event.file, id = file.id else {
|
||||
func filePrivate(_ event: Event) {
|
||||
guard let file = event.file, let id = file.id else {
|
||||
return
|
||||
}
|
||||
|
||||
files[id]?.isPublic = false
|
||||
fileEventsDelegate?.fileMadePrivate(file)
|
||||
fileEventsDelegate?.madePrivate(file, client: self)
|
||||
}
|
||||
|
||||
func deleteFile(event: Event) {
|
||||
guard let file = event.file, id = file.id else {
|
||||
func deleteFile(_ event: Event) {
|
||||
guard let file = event.file, let id = file.id else {
|
||||
return
|
||||
}
|
||||
|
||||
if files[id] != nil {
|
||||
files.removeValueForKey(id)
|
||||
files.removeValue(forKey: id)
|
||||
}
|
||||
fileEventsDelegate?.fileDeleted(file)
|
||||
fileEventsDelegate?.deleted(file, client: self)
|
||||
}
|
||||
|
||||
func fileCommentAdded(event: Event) {
|
||||
guard let file = event.file, id = file.id, comment = event.comment, commentID = comment.id else {
|
||||
func fileCommentAdded(_ event: Event) {
|
||||
guard let file = event.file, let id = file.id, let comment = event.comment, let commentID = comment.id else {
|
||||
return
|
||||
}
|
||||
|
||||
files[id]?.comments[commentID] = comment
|
||||
fileEventsDelegate?.fileCommentAdded(file, comment: comment)
|
||||
fileEventsDelegate?.commentAdded(file, comment: comment, client: self)
|
||||
}
|
||||
|
||||
func fileCommentEdited(event: Event) {
|
||||
guard let file = event.file, id = file.id, comment = event.comment, commentID = comment.id else {
|
||||
func fileCommentEdited(_ event: Event) {
|
||||
guard let file = event.file, let id = file.id, let comment = event.comment, let commentID = comment.id else {
|
||||
return
|
||||
}
|
||||
|
||||
files[id]?.comments[commentID]?.comment = comment.comment
|
||||
fileEventsDelegate?.fileCommentEdited(file, comment: comment)
|
||||
fileEventsDelegate?.commentAdded(file, comment: comment, client: self)
|
||||
}
|
||||
|
||||
func fileCommentDeleted(event: Event) {
|
||||
guard let file = event.file, id = file.id, comment = event.comment, commentID = comment.id else {
|
||||
func fileCommentDeleted(_ event: Event) {
|
||||
guard let file = event.file, let id = file.id, let comment = event.comment, let commentID = comment.id else {
|
||||
return
|
||||
}
|
||||
|
||||
files[id]?.comments.removeValueForKey(commentID)
|
||||
fileEventsDelegate?.fileCommentDeleted(file, comment: comment)
|
||||
_ = files[id]?.comments.removeValue(forKey: commentID)
|
||||
fileEventsDelegate?.commentDeleted(file, comment: comment, client: self)
|
||||
}
|
||||
|
||||
//MARK: - Pins
|
||||
func pinAdded(event: Event) {
|
||||
guard let id = event.channelID, item = event.item else {
|
||||
func pinAdded(_ event: Event) {
|
||||
guard let id = event.channelID, let item = event.item else {
|
||||
return
|
||||
}
|
||||
|
||||
channels[id]?.pinnedItems.append(item)
|
||||
pinEventsDelegate?.itemPinned(item, channel: channels[id])
|
||||
pinEventsDelegate?.pinned(item, channel: channels[id], client: self)
|
||||
}
|
||||
|
||||
func pinRemoved(event: Event) {
|
||||
guard let id = event.channelID, item = event.item else {
|
||||
func pinRemoved(_ event: Event) {
|
||||
guard let id = event.channelID, let item = event.item else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if let pins = channels[id]?.pinnedItems.filter({$0 != item}) {
|
||||
channels[id]?.pinnedItems = pins
|
||||
}
|
||||
pinEventsDelegate?.itemUnpinned(item, channel: channels[id])
|
||||
pinEventsDelegate?.unpinned(item, channel: channels[id], client: self)
|
||||
}
|
||||
|
||||
|
||||
//MARK: - Stars
|
||||
func itemStarred(event: Event, star: Bool) {
|
||||
guard let item = event.item, type = item.type else {
|
||||
func itemStarred(_ event: Event, star: Bool) {
|
||||
guard let item = event.item, let type = item.type else {
|
||||
return
|
||||
}
|
||||
switch type {
|
||||
@@ -286,19 +287,19 @@ internal extension Client {
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
starEventsDelegate?.itemStarred(item, star: star)
|
||||
|
||||
starEventsDelegate?.starred(item, starred: star, self)
|
||||
}
|
||||
|
||||
func starMessage(item: Item, star: Bool) {
|
||||
guard let message = item.message, ts = message.ts, channel = item.channel where channels[channel]?.messages[ts] != nil else {
|
||||
func starMessage(_ item: Item, star: Bool) {
|
||||
guard let message = item.message, let ts = message.ts, let channel = item.channel , channels[channel]?.messages[ts] != nil else {
|
||||
return
|
||||
}
|
||||
channels[channel]?.messages[ts]?.isStarred = star
|
||||
}
|
||||
|
||||
func starFile(item: Item, star: Bool) {
|
||||
guard let file = item.file, id = file.id else {
|
||||
func starFile(_ item: Item, star: Bool) {
|
||||
guard let file = item.file, let id = file.id else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -314,22 +315,22 @@ internal extension Client {
|
||||
}
|
||||
}
|
||||
|
||||
func starComment(item: Item) {
|
||||
guard let file = item.file, id = file.id, comment = item.comment, commentID = comment.id else {
|
||||
func starComment(_ item: Item) {
|
||||
guard let file = item.file, let id = file.id, let comment = item.comment, let commentID = comment.id else {
|
||||
return
|
||||
}
|
||||
files[id]?.comments[commentID] = comment
|
||||
}
|
||||
|
||||
//MARK: - Reactions
|
||||
func addedReaction(event: Event) {
|
||||
guard let item = event.item, type = item.type, reaction = event.reaction, userID = event.user?.id, itemUser = event.itemUser else {
|
||||
func addedReaction(_ event: Event) {
|
||||
guard let item = event.item, let type = item.type, let reaction = event.reaction, let userID = event.user?.id, let itemUser = event.itemUser else {
|
||||
return
|
||||
}
|
||||
|
||||
switch type {
|
||||
case "message":
|
||||
guard let channel = item.channel, ts = item.ts, message = channels[channel]?.messages[ts] else {
|
||||
guard let channel = item.channel, let ts = item.ts, let message = channels[channel]?.messages[ts] else {
|
||||
return
|
||||
}
|
||||
message.reactions.append(Reaction(name: reaction, user: userID))
|
||||
@@ -339,225 +340,224 @@ internal extension Client {
|
||||
}
|
||||
files[id]?.reactions.append(Reaction(name: reaction, user: userID))
|
||||
case "file_comment":
|
||||
guard let id = item.file?.id, commentID = item.fileCommentID else {
|
||||
guard let id = item.file?.id, let commentID = item.fileCommentID else {
|
||||
return
|
||||
}
|
||||
files[id]?.comments[commentID]?.reactions.append(Reaction(name: reaction, user: userID))
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
reactionEventsDelegate?.reactionAdded(reaction, item: item, itemUser: itemUser)
|
||||
|
||||
reactionEventsDelegate?.added(reaction, item: item, itemUser: itemUser, client: self)
|
||||
}
|
||||
|
||||
func removedReaction(event: Event) {
|
||||
guard let item = event.item, type = item.type, key = event.reaction, userID = event.user?.id, itemUser = event.itemUser else {
|
||||
|
||||
func removedReaction(_ event: Event) {
|
||||
guard let item = event.item, let type = item.type, let key = event.reaction, let userID = event.user?.id, let itemUser = event.itemUser else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
switch type {
|
||||
case "message":
|
||||
guard let channel = item.channel, ts = item.ts, message = channels[channel]?.messages[ts] else {
|
||||
guard let channel = item.channel, let ts = item.ts, let message = channels[channel]?.messages[ts] else {
|
||||
return
|
||||
}
|
||||
message.reactions = message.reactions.filter({$0.name != key && $0.user != userID})
|
||||
case "file":
|
||||
guard let itemFile = item.file, id = itemFile.id else {
|
||||
guard let itemFile = item.file, let id = itemFile.id else {
|
||||
return
|
||||
}
|
||||
files[id]?.reactions = files[id]!.reactions.filter({$0.name != key && $0.user != userID})
|
||||
case "file_comment":
|
||||
guard let id = item.file?.id, commentID = item.fileCommentID else {
|
||||
guard let id = item.file?.id, let commentID = item.fileCommentID else {
|
||||
return
|
||||
}
|
||||
files[id]?.comments[commentID]?.reactions = files[id]!.comments[commentID]!.reactions.filter({$0.name != key && $0.user != userID})
|
||||
default:
|
||||
break
|
||||
}
|
||||
|
||||
reactionEventsDelegate?.reactionRemoved(key, item: item, itemUser: itemUser)
|
||||
|
||||
reactionEventsDelegate?.removed(key, item: item, itemUser: itemUser, client: self)
|
||||
}
|
||||
|
||||
|
||||
//MARK: - Preferences
|
||||
func changePreference(event: Event) {
|
||||
func changePreference(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.preferences?[name] = event.value
|
||||
slackEventsDelegate?.preferenceChanged(name, value: event.value)
|
||||
slackEventsDelegate?.preferenceChanged(name, value: event.value, client: self)
|
||||
}
|
||||
|
||||
//Mark: - User Change
|
||||
func userChange(event: Event) {
|
||||
guard let user = event.user, id = user.id else {
|
||||
func userChange(_ event: Event) {
|
||||
guard let user = event.user, let id = user.id else {
|
||||
return
|
||||
}
|
||||
|
||||
let preferences = users[id]?.preferences
|
||||
users[id] = user
|
||||
users[id]?.preferences = preferences
|
||||
slackEventsDelegate?.userChanged(user)
|
||||
slackEventsDelegate?.userChanged(user, client: self)
|
||||
}
|
||||
|
||||
//MARK: - User Presence
|
||||
func presenceChange(event: Event) {
|
||||
guard let user = event.user, id = user.id, presence = event.presence else {
|
||||
func presenceChange(_ event: Event) {
|
||||
guard let user = event.user, let id = user.id, let presence = event.presence else {
|
||||
return
|
||||
}
|
||||
|
||||
users[id]?.presence = event.presence
|
||||
slackEventsDelegate?.presenceChanged(user, presence: presence)
|
||||
slackEventsDelegate?.presenceChanged(user, presence: presence, client: self)
|
||||
}
|
||||
|
||||
//MARK: - Team
|
||||
func teamJoin(event: Event) {
|
||||
guard let user = event.user, id = user.id else {
|
||||
func teamJoin(_ event: Event) {
|
||||
guard let user = event.user, let id = user.id else {
|
||||
return
|
||||
}
|
||||
|
||||
users[id] = user
|
||||
teamEventsDelegate?.teamJoined(user)
|
||||
teamEventsDelegate?.userJoined(user, client: self)
|
||||
}
|
||||
|
||||
func teamPlanChange(event: Event) {
|
||||
func teamPlanChange(_ event: Event) {
|
||||
guard let plan = event.plan else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.plan = plan
|
||||
teamEventsDelegate?.teamPlanChanged(plan)
|
||||
teamEventsDelegate?.planChanged(plan, client: self)
|
||||
}
|
||||
|
||||
func teamPreferenceChange(event: Event) {
|
||||
func teamPreferenceChange(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.prefs?[name] = event.value
|
||||
teamEventsDelegate?.teamPreferencesChanged(name, value: event.value)
|
||||
teamEventsDelegate?.preferencesChanged(name, value: event.value, client: self)
|
||||
}
|
||||
|
||||
func teamNameChange(event: Event) {
|
||||
func teamNameChange(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.name = name
|
||||
teamEventsDelegate?.teamNameChanged(name)
|
||||
teamEventsDelegate?.nameChanged(name, client: self)
|
||||
}
|
||||
|
||||
func teamDomainChange(event: Event) {
|
||||
func teamDomainChange(_ event: Event) {
|
||||
guard let domain = event.domain else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.domain = domain
|
||||
teamEventsDelegate?.teamDomainChanged(domain)
|
||||
teamEventsDelegate?.domainChanged(domain, client: self)
|
||||
}
|
||||
|
||||
func emailDomainChange(event: Event) {
|
||||
func emailDomainChange(_ event: Event) {
|
||||
guard let domain = event.emailDomain else {
|
||||
return
|
||||
}
|
||||
|
||||
team?.emailDomain = domain
|
||||
teamEventsDelegate?.teamEmailDomainChanged(domain)
|
||||
teamEventsDelegate?.emailDomainChanged(domain, client: self)
|
||||
}
|
||||
|
||||
func emojiChanged(event: Event) {
|
||||
teamEventsDelegate?.teamEmojiChanged()
|
||||
func emojiChanged(_ event: Event) {
|
||||
teamEventsDelegate?.emojiChanged(self)
|
||||
}
|
||||
|
||||
//MARK: - Bots
|
||||
func bot(event: Event) {
|
||||
guard let bot = event.bot, id = bot.id else {
|
||||
func bot(_ event: Event) {
|
||||
guard let bot = event.bot, let id = bot.id else {
|
||||
return
|
||||
}
|
||||
|
||||
bots[id] = bot
|
||||
slackEventsDelegate?.botEvent(bot)
|
||||
slackEventsDelegate?.botEvent(bot, client: self)
|
||||
}
|
||||
|
||||
//MARK: - Subteams
|
||||
func subteam(event: Event) {
|
||||
guard let subteam = event.subteam, id = subteam.id else {
|
||||
func subteam(_ event: Event) {
|
||||
guard let subteam = event.subteam, let id = subteam.id else {
|
||||
return
|
||||
}
|
||||
|
||||
userGroups[id] = subteam
|
||||
subteamEventsDelegate?.subteamEvent(subteam)
|
||||
subteamEventsDelegate?.event(subteam, client: self)
|
||||
}
|
||||
|
||||
func subteamAddedSelf(event: Event) {
|
||||
guard let subteamID = event.subteamID, _ = authenticatedUser?.userGroups else {
|
||||
func subteamAddedSelf(_ event: Event) {
|
||||
guard let subteamID = event.subteamID, let _ = authenticatedUser?.userGroups else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.userGroups![subteamID] = subteamID
|
||||
subteamEventsDelegate?.subteamSelfAdded(subteamID)
|
||||
subteamEventsDelegate?.selfAdded(subteamID, client: self)
|
||||
}
|
||||
|
||||
func subteamRemovedSelf(event: Event) {
|
||||
func subteamRemovedSelf(_ event: Event) {
|
||||
guard let subteamID = event.subteamID else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.userGroups?.removeValueForKey(subteamID)
|
||||
subteamEventsDelegate?.subteamSelfRemoved(subteamID)
|
||||
_ = authenticatedUser?.userGroups?.removeValue(forKey: subteamID)
|
||||
subteamEventsDelegate?.selfRemoved(subteamID, client: self)
|
||||
}
|
||||
|
||||
//MARK: - Team Profiles
|
||||
func teamProfileChange(event: Event) {
|
||||
func teamProfileChange(_ event: Event) {
|
||||
guard let profile = event.profile else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
for user in users {
|
||||
for key in profile.fields.keys {
|
||||
users[user.0]?.profile?.customProfile?.fields[key]?.updateProfileField(profile.fields[key])
|
||||
}
|
||||
}
|
||||
|
||||
teamProfileEventsDelegate?.teamProfileChanged(profile)
|
||||
teamProfileEventsDelegate?.changed(profile, client: self)
|
||||
}
|
||||
|
||||
func teamProfileDeleted(event: Event) {
|
||||
func teamProfileDeleted(_ event: Event) {
|
||||
guard let profile = event.profile else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
for user in users {
|
||||
if let id = profile.fields.first?.0 {
|
||||
users[user.0]?.profile?.customProfile?.fields[id] = nil
|
||||
}
|
||||
}
|
||||
|
||||
teamProfileEventsDelegate?.teamProfileDeleted(profile)
|
||||
teamProfileEventsDelegate?.deleted(profile, client: self)
|
||||
}
|
||||
|
||||
func teamProfileReordered(event: Event) {
|
||||
func teamProfileReordered(_ event: Event) {
|
||||
guard let profile = event.profile else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
for user in users {
|
||||
for key in profile.fields.keys {
|
||||
users[user.0]?.profile?.customProfile?.fields[key]?.ordering = profile.fields[key]?.ordering
|
||||
}
|
||||
}
|
||||
|
||||
teamProfileEventsDelegate?.teamProfileReordered(profile)
|
||||
|
||||
teamProfileEventsDelegate?.reordered(profile, client: self)
|
||||
}
|
||||
|
||||
//MARK: - Authenticated User
|
||||
func manualPresenceChange(event: Event) {
|
||||
guard let presence = event.presence, user = authenticatedUser else {
|
||||
func manualPresenceChange(_ event: Event) {
|
||||
guard let presence = event.presence, let user = authenticatedUser else {
|
||||
return
|
||||
}
|
||||
|
||||
authenticatedUser?.presence = presence
|
||||
slackEventsDelegate?.manualPresenceChanged(user, presence: presence)
|
||||
slackEventsDelegate?.manualPresenceChanged(user, presence: presence, client: self)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,45 +21,43 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum ClientError: ErrorType {
|
||||
case ChannelDoesNotExist
|
||||
case UserDoesNotExist
|
||||
public enum ClientError: Error {
|
||||
case channelDoesNotExist
|
||||
case userDoesNotExist
|
||||
}
|
||||
|
||||
public extension Client {
|
||||
public extension SlackClient {
|
||||
|
||||
//MARK: - User & Channel
|
||||
public func getChannelIDByName(name: String) throws -> String {
|
||||
guard let id = channels.filter({$0.1.name == stripString(name)}).first?.0 else {
|
||||
throw ClientError.ChannelDoesNotExist
|
||||
public func getChannelIDWith(name: String) throws -> String {
|
||||
guard let id = channels.filter({$0.1.name == strip(string:name)}).first?.0 else {
|
||||
throw ClientError.channelDoesNotExist
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
public func getUserIDByName(name: String) throws -> String {
|
||||
guard let id = users.filter({$0.1.name == stripString(name)}).first?.0 else {
|
||||
throw ClientError.UserDoesNotExist
|
||||
|
||||
public func getUserIDWith(name: String) throws -> String {
|
||||
guard let id = users.filter({$0.1.name == strip(string:name)}).first?.0 else {
|
||||
throw ClientError.userDoesNotExist
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
||||
public func getImIDForUserWithID(id: String, success: (imID: String?)->Void, failure: (error: SlackError)->Void) {
|
||||
|
||||
public func getImIDForUserWith(id: String, success: @escaping (_ imID: String?)->Void, failure: @escaping (SlackError)->Void) {
|
||||
let ims = channels.filter{$0.1.isIM == true}
|
||||
let channel = ims.filter{$0.1.user == id}.first
|
||||
if let channel = channel {
|
||||
success(imID: channel.0)
|
||||
success(channel.0)
|
||||
} else {
|
||||
webAPI.openIM(id, success: success, failure: failure)
|
||||
webAPI.openIM(userID: id, success: success, failure: failure)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//MARK: - Utilities
|
||||
internal func stripString(string: String) -> String {
|
||||
internal func strip(string: String) -> String {
|
||||
var strippedString = string
|
||||
if string[string.startIndex] == "@" || string[string.startIndex] == "#" {
|
||||
strippedString = string.substringFromIndex(string.startIndex.advancedBy(1))
|
||||
strippedString = string.substring(from: string.characters.index(string.startIndex, offsetBy: 1))
|
||||
}
|
||||
return strippedString
|
||||
}
|
||||
|
||||
+152
-126
@@ -22,11 +22,13 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
import Starscream
|
||||
import Venice
|
||||
import WebSocketClient
|
||||
|
||||
public class Client: WebSocketDelegate {
|
||||
public class SlackClient {
|
||||
|
||||
internal(set) public var connected = false
|
||||
internal(set) public var authenticated = false
|
||||
internal(set) public var authenticatedUser: User?
|
||||
internal(set) public var team: Team?
|
||||
|
||||
@@ -38,6 +40,7 @@ public class Client: WebSocketDelegate {
|
||||
internal(set) public var sentMessages = [String: Message]()
|
||||
|
||||
//MARK: - Delegates
|
||||
public weak var connectionEventsDelegate: ConnectionEventsDelegate?
|
||||
public weak var slackEventsDelegate: SlackEventsDelegate?
|
||||
public weak var messageEventsDelegate: MessageEventsDelegate?
|
||||
public weak var doNotDisturbEventsDelegate: DoNotDisturbEventsDelegate?
|
||||
@@ -51,220 +54,243 @@ public class Client: WebSocketDelegate {
|
||||
public weak var subteamEventsDelegate: SubteamEventsDelegate?
|
||||
public weak var teamProfileEventsDelegate: TeamProfileEventsDelegate?
|
||||
|
||||
public var token = "SLACK_AUTH_TOKEN"
|
||||
internal var token = "SLACK_AUTH_TOKEN"
|
||||
|
||||
public func setAuthToken(token: String) {
|
||||
self.token = token
|
||||
}
|
||||
|
||||
public var webAPI: SlackWebAPI {
|
||||
return SlackWebAPI(client: self)
|
||||
return SlackWebAPI(token: token)
|
||||
}
|
||||
|
||||
internal var webSocket: WebSocket?
|
||||
internal let api = NetworkInterface()
|
||||
|
||||
private let pingPongQueue = dispatch_queue_create("com.launchsoft.SlackKit", DISPATCH_QUEUE_SERIAL)
|
||||
internal var client: WebSocketClient?
|
||||
internal var socket: WebSocket?
|
||||
|
||||
internal var ping: Double?
|
||||
internal var pong: Double?
|
||||
|
||||
internal var pingInterval: NSTimeInterval?
|
||||
internal var timeout: NSTimeInterval?
|
||||
internal var reconnect: Bool?
|
||||
internal var pingInterval: Double = 30
|
||||
internal var timeout: Double = 300
|
||||
internal var reconnect: Bool = false
|
||||
|
||||
required public init(apiToken: String) {
|
||||
self.token = apiToken
|
||||
}
|
||||
|
||||
public func connect(simpleLatest simpleLatest: Bool? = nil, noUnreads: Bool? = nil, mpimAware: Bool? = nil, pingInterval: NSTimeInterval? = nil, timeout: NSTimeInterval? = nil, reconnect: Bool? = nil) {
|
||||
public func connect(simpleLatest: Bool? = nil, noUnreads: Bool? = nil, mpimAware: Bool? = nil, pingInterval: Double = 30, timeout: Double = 300, reconnect: Bool = false) {
|
||||
self.pingInterval = pingInterval
|
||||
self.timeout = timeout
|
||||
self.reconnect = reconnect
|
||||
webAPI.rtmStart(simpleLatest, noUnreads: noUnreads, mpimAware: mpimAware, success: {
|
||||
(response) -> Void in
|
||||
self.initialSetup(response)
|
||||
if let socketURL = response["url"] as? String {
|
||||
let url = NSURL(string: socketURL)
|
||||
self.webSocket = WebSocket(url: url!)
|
||||
self.webSocket?.delegate = self
|
||||
self.webSocket?.connect()
|
||||
webAPI.rtmStart(simpleLatest: simpleLatest, noUnreads: noUnreads, mpimAware: mpimAware, success: { (response) in
|
||||
self.initialSetup(JSON: response)
|
||||
if let socketURL = response["url"] as? String, let url = URL(string: socketURL) {
|
||||
do {
|
||||
self.client = try WebSocketClient(url: url, didConnect: { (socket) in
|
||||
self.setupSocket(socket)
|
||||
})
|
||||
try self.client?.connect()
|
||||
} catch let error {
|
||||
print("WebSocket client could not connect: \(error)")
|
||||
}
|
||||
}
|
||||
}, failure: {(error) -> Void in
|
||||
self.slackEventsDelegate?.clientConnectionFailed(error)
|
||||
})
|
||||
}, failure: {(error) in
|
||||
print("rtm.start failed with error: \(error)")
|
||||
})
|
||||
}
|
||||
|
||||
public func disconnect() {
|
||||
webSocket?.disconnect()
|
||||
_ = try? socket?.close()
|
||||
}
|
||||
|
||||
//MARK: - RTM Message send
|
||||
//MARK: - RTM message send
|
||||
public func sendMessage(message: String, channelID: String) {
|
||||
guard connected else { return }
|
||||
|
||||
if let data = try? formatMessageToSlackJsonString(msg: message, channel: channelID),
|
||||
string = NSString(data: data, encoding: NSUTF8StringEncoding) as? String {
|
||||
webSocket?.writeString(string)
|
||||
if connected {
|
||||
if let data = formatMessageToSlackJsonString(message: message, channel: channelID) {
|
||||
do {
|
||||
try socket?.send(data.base64EncodedString())
|
||||
} catch let error {
|
||||
print("Message failed to send: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func formatMessageToSlackJsonString(message: (msg: String, channel: String)) throws -> NSData {
|
||||
let json: [String: AnyObject] = [
|
||||
"id": NSDate().slackTimestamp(),
|
||||
private func formatMessageToSlackJsonString(message: String, channel: String) -> Data? {
|
||||
let json: [String: Any] = [
|
||||
"id": Date().slackTimestamp,
|
||||
"type": "message",
|
||||
"channel": message.channel,
|
||||
"text": message.msg.slackFormatEscaping()
|
||||
"channel": channel,
|
||||
"text": message.slackFormatEscaping
|
||||
]
|
||||
addSentMessage(json)
|
||||
return try NSJSONSerialization.dataWithJSONObject(json, options: [])
|
||||
|
||||
do {
|
||||
return try JSONSerialization.data(withJSONObject: json, options: [])
|
||||
} catch {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
private func addSentMessage(dictionary: [String: AnyObject]) {
|
||||
private func addSentMessage(_ dictionary: [String: Any]) {
|
||||
var message = dictionary
|
||||
guard let id = message["id"] as? NSNumber else {
|
||||
return
|
||||
}
|
||||
let ts = String(id)
|
||||
message.removeValueForKey("id")
|
||||
let ts = String(describing: id)
|
||||
message.removeValue(forKey: "id")
|
||||
message["ts"] = ts
|
||||
message["user"] = self.authenticatedUser?.id
|
||||
sentMessages[ts] = Message(message: message)
|
||||
}
|
||||
|
||||
//MARK: - RTM Ping
|
||||
private func pingRTMServerAtInterval(interval: NSTimeInterval) {
|
||||
let delay = dispatch_time(DISPATCH_TIME_NOW, Int64(interval * Double(NSEC_PER_SEC)))
|
||||
dispatch_after(delay, pingPongQueue, {
|
||||
guard self.connected && self.timeoutCheck() else {
|
||||
self.disconnect()
|
||||
return
|
||||
}
|
||||
self.sendRTMPing()
|
||||
self.pingRTMServerAtInterval(interval)
|
||||
})
|
||||
}
|
||||
|
||||
private func sendRTMPing() {
|
||||
guard connected else {
|
||||
return
|
||||
}
|
||||
let json: [String: AnyObject] = [
|
||||
"id": NSDate().slackTimestamp(),
|
||||
"type": "ping",
|
||||
]
|
||||
guard let data = try? NSJSONSerialization.dataWithJSONObject(json, options: []) else {
|
||||
return
|
||||
}
|
||||
let string = NSString(data: data, encoding: NSUTF8StringEncoding)
|
||||
if let writePing = string as? String {
|
||||
ping = json["id"] as? Double
|
||||
webSocket?.writeString(writePing)
|
||||
}
|
||||
}
|
||||
|
||||
private func timeoutCheck() -> Bool {
|
||||
if let pong = pong, ping = ping, timeout = timeout {
|
||||
if pong - ping < timeout {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
// Ping-pong or timeout not configured
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
sentMessages[ts] = Message(dictionary: message)
|
||||
}
|
||||
|
||||
//MARK: - Client setup
|
||||
private func initialSetup(json: [String: AnyObject]) {
|
||||
team = Team(team: json["team"] as? [String: AnyObject])
|
||||
authenticatedUser = User(user: json["self"] as? [String: AnyObject])
|
||||
authenticatedUser?.doNotDisturbStatus = DoNotDisturbStatus(status: json["dnd"] as? [String: AnyObject])
|
||||
enumerateObjects(json["users"] as? Array) { (user) in self.addUser(user) }
|
||||
enumerateObjects(json["channels"] as? Array) { (channel) in self.addChannel(channel) }
|
||||
enumerateObjects(json["groups"] as? Array) { (group) in self.addChannel(group) }
|
||||
enumerateObjects(json["mpims"] as? Array) { (mpim) in self.addChannel(mpim) }
|
||||
enumerateObjects(json["ims"] as? Array) { (ims) in self.addChannel(ims) }
|
||||
enumerateObjects(json["bots"] as? Array) { (bots) in self.addBot(bots) }
|
||||
enumerateSubteams(json["subteams"] as? [String: AnyObject])
|
||||
private func initialSetup(JSON: [String: Any]) {
|
||||
team = Team(team: JSON["team"] as? [String: Any])
|
||||
authenticatedUser = User(user: JSON["self"] as? [String: Any])
|
||||
authenticatedUser?.doNotDisturbStatus = DoNotDisturbStatus(status: JSON["dnd"] as? [String: Any])
|
||||
enumerateObjects(JSON["users"] as? Array) { (user) in self.addUser(user) }
|
||||
enumerateObjects(JSON["channels"] as? Array) { (channel) in self.addChannel(channel) }
|
||||
enumerateObjects(JSON["groups"] as? Array) { (group) in self.addChannel(group) }
|
||||
enumerateObjects(JSON["mpims"] as? Array) { (mpim) in self.addChannel(mpim) }
|
||||
enumerateObjects(JSON["ims"] as? Array) { (ims) in self.addChannel(ims) }
|
||||
enumerateObjects(JSON["bots"] as? Array) { (bots) in self.addBot(bots) }
|
||||
enumerateSubteams(JSON["subteams"] as? [String: Any])
|
||||
}
|
||||
|
||||
private func addUser(aUser: [String: AnyObject]) {
|
||||
private func addUser(_ aUser: [String: Any]) {
|
||||
let user = User(user: aUser)
|
||||
if let id = user.id {
|
||||
users[id] = user
|
||||
}
|
||||
}
|
||||
|
||||
private func addChannel(aChannel: [String: AnyObject]) {
|
||||
private func addChannel(_ aChannel: [String: Any]) {
|
||||
let channel = Channel(channel: aChannel)
|
||||
if let id = channel.id {
|
||||
channels[id] = channel
|
||||
}
|
||||
}
|
||||
|
||||
private func addBot(aBot: [String: AnyObject]) {
|
||||
private func addBot(_ aBot: [String: Any]) {
|
||||
let bot = Bot(bot: aBot)
|
||||
if let id = bot.id {
|
||||
bots[id] = bot
|
||||
}
|
||||
}
|
||||
|
||||
private func enumerateSubteams(subteams: [String: AnyObject]?) {
|
||||
private func enumerateSubteams(_ subteams: [String: Any]?) {
|
||||
if let subteams = subteams {
|
||||
if let all = subteams["all"] as? [[String: AnyObject]] {
|
||||
if let all = subteams["all"] as? [[String: Any]] {
|
||||
for item in all {
|
||||
let u = UserGroup(userGroup: item)
|
||||
self.userGroups[u.id!] = u
|
||||
if let id = u.id {
|
||||
self.userGroups[id] = u
|
||||
}
|
||||
}
|
||||
}
|
||||
if let auth = subteams["self"] as? [String] {
|
||||
for item in auth {
|
||||
authenticatedUser?.userGroups = [String: String]()
|
||||
authenticatedUser?.userGroups![item] = item
|
||||
authenticatedUser?.userGroups?[item] = item
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Utilities
|
||||
private func enumerateObjects(array: [AnyObject]?, initalizer: ([String: AnyObject])-> Void) {
|
||||
private func enumerateObjects(_ array: [Any]?, initalizer: ([String: Any])-> Void) {
|
||||
if let array = array {
|
||||
for object in array {
|
||||
if let dictionary = object as? [String: AnyObject] {
|
||||
if let dictionary = object as? [String: Any] {
|
||||
initalizer(dictionary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - WebSocketDelegate
|
||||
public func websocketDidConnect(socket: WebSocket) {
|
||||
if let pingInterval = pingInterval {
|
||||
pingRTMServerAtInterval(pingInterval)
|
||||
//MARK: - RTM Ping
|
||||
internal func pingRTMServer() {
|
||||
co {
|
||||
self.sendRTMPing()
|
||||
nap(for: self.pingInterval.seconds)
|
||||
guard self.connected && self.isConnectionTimedOut else {
|
||||
self.disconnect()
|
||||
return
|
||||
}
|
||||
self.pingRTMServer()
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
|
||||
private func sendRTMPing() {
|
||||
guard connected else {
|
||||
return
|
||||
}
|
||||
let json: [String: Any] = [
|
||||
"id": Date().slackTimestamp,
|
||||
"type": "ping"
|
||||
]
|
||||
guard let data = try? JSONSerialization.data(withJSONObject: json, options: []) else {
|
||||
return
|
||||
}
|
||||
if let string = String(data: data, encoding: String.Encoding.utf8) {
|
||||
ping = json["id"] as? Double
|
||||
do {
|
||||
try socket?.send(string)
|
||||
} catch let error {
|
||||
print("Failed to send ping with error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isConnectionTimedOut: Bool {
|
||||
if let pong = pong, let ping = ping {
|
||||
if pong - ping < timeout {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - WebSocket
|
||||
private func setupSocket(_ socket: WebSocket) {
|
||||
socket.onText {(message) in
|
||||
self.websocketDidReceive(message: message)
|
||||
}
|
||||
socket.onClose{ (code: CloseCode?, reason: String?) in
|
||||
self.websocketDidDisconnect(closeCode: code, error: reason)
|
||||
}
|
||||
socket.onPing { (data) in try socket.pong() }
|
||||
socket.onPong { (data) in try socket.ping() }
|
||||
self.socket = socket
|
||||
}
|
||||
|
||||
private func websocketDidReceive(message: String) {
|
||||
do {
|
||||
guard let message = message.data(using: .utf8) else {
|
||||
print("Failed to decode message")
|
||||
return
|
||||
}
|
||||
let json = try JSONSerialization.jsonObject(with: message, options: [])
|
||||
if let event = json as? [String: Any] {
|
||||
dispatch(event)
|
||||
}
|
||||
}
|
||||
catch let error {
|
||||
print("Failed to dispatch message: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
private func websocketDidDisconnect(closeCode: CloseCode?, error: String?) {
|
||||
connected = false
|
||||
webSocket = nil
|
||||
authenticated = false
|
||||
client = nil
|
||||
socket = nil
|
||||
authenticatedUser = nil
|
||||
slackEventsDelegate?.clientDisconnected()
|
||||
connectionEventsDelegate?.disconnected(self)
|
||||
if reconnect == true {
|
||||
connect(pingInterval: pingInterval, timeout: timeout, reconnect: reconnect)
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
|
||||
guard let data = text.dataUsingEncoding(NSUTF8StringEncoding) else {
|
||||
return
|
||||
}
|
||||
|
||||
if let json = (try? NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.AllowFragments)) as? [String: AnyObject] {
|
||||
dispatch(json)
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidReceiveData(socket: WebSocket, data: NSData) {}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// Comment.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct Comment: Equatable {
|
||||
|
||||
public let id: String?
|
||||
public let user: String?
|
||||
internal(set) public var created: Int?
|
||||
internal(set) public var comment: String?
|
||||
internal(set) public var starred: Bool?
|
||||
internal(set) public var stars: Int?
|
||||
internal(set) public var reactions = [Reaction]()
|
||||
|
||||
internal init(comment:[String: Any]?) {
|
||||
id = comment?["id"] as? String
|
||||
created = comment?["created"] as? Int
|
||||
user = comment?["user"] as? String
|
||||
starred = comment?["is_starred"] as? Bool
|
||||
stars = comment?["num_stars"] as? Int
|
||||
self.comment = comment?["comment"] as? String
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
self.id = id
|
||||
self.user = nil
|
||||
}
|
||||
|
||||
public static func ==(lhs: Comment, rhs: Comment) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
//
|
||||
// CustomProfile.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct CustomProfile {
|
||||
|
||||
internal(set) public var fields = [String: CustomProfileField]()
|
||||
|
||||
internal init(profile: [String: Any]?) {
|
||||
if let eventFields = profile?["fields"] as? [Any] {
|
||||
for field in eventFields {
|
||||
var cpf: CustomProfileField?
|
||||
if let fieldDictionary = field as? [String: Any] {
|
||||
cpf = CustomProfileField(field: fieldDictionary)
|
||||
} else {
|
||||
cpf = CustomProfileField(id: field as? String)
|
||||
}
|
||||
if let id = cpf?.id { fields[id] = cpf }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal init(customFields: [String: Any]?) {
|
||||
if let customFields = customFields {
|
||||
for key in customFields.keys {
|
||||
let cpf = CustomProfileField(field: customFields[key] as? [String: Any])
|
||||
self.fields[key] = cpf
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// CustomProfileField.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct CustomProfileField {
|
||||
|
||||
internal(set) public var id: String?
|
||||
internal(set) public var alt: String?
|
||||
internal(set) public var value: String?
|
||||
internal(set) public var hidden: Bool?
|
||||
internal(set) public var hint: String?
|
||||
internal(set) public var label: String?
|
||||
internal(set) public var options: String?
|
||||
internal(set) public var ordering: Int?
|
||||
internal(set) public var possibleValues: [String]?
|
||||
internal(set) public var type: String?
|
||||
|
||||
internal init(field: [String: Any]?) {
|
||||
id = field?["id"] as? String
|
||||
alt = field?["alt"] as? String
|
||||
value = field?["value"] as? String
|
||||
hidden = field?["is_hidden"] as? Bool
|
||||
hint = field?["hint"] as? String
|
||||
label = field?["label"] as? String
|
||||
options = field?["options"] as? String
|
||||
ordering = field?["ordering"] as? Int
|
||||
possibleValues = field?["possible_values"] as? [String]
|
||||
type = field?["type"] as? String
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
self.id = id
|
||||
}
|
||||
|
||||
internal mutating func updateProfileField(_ profile: CustomProfileField?) {
|
||||
id = profile?.id != nil ? profile?.id : id
|
||||
alt = profile?.alt != nil ? profile?.alt : alt
|
||||
value = profile?.value != nil ? profile?.value : value
|
||||
hidden = profile?.hidden != nil ? profile?.hidden : hidden
|
||||
hint = profile?.hint != nil ? profile?.hint : hint
|
||||
label = profile?.label != nil ? profile?.label : label
|
||||
options = profile?.options != nil ? profile?.options : options
|
||||
ordering = profile?.ordering != nil ? profile?.ordering : ordering
|
||||
possibleValues = profile?.possibleValues != nil ? profile?.possibleValues : possibleValues
|
||||
type = profile?.type != nil ? profile?.type : type
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// DoNotDisturbStatus.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct DoNotDisturbStatus {
|
||||
|
||||
internal(set) public var enabled: Bool?
|
||||
internal(set) public var nextDoNotDisturbStart: Int?
|
||||
internal(set) public var nextDoNotDisturbEnd: Int?
|
||||
internal(set) public var snoozeEnabled: Bool?
|
||||
internal(set) public var snoozeEndtime: Int?
|
||||
|
||||
internal init(status: [String: Any]?) {
|
||||
enabled = status?["dnd_enabled"] as? Bool
|
||||
nextDoNotDisturbStart = status?["next_dnd_start_ts"] as? Int
|
||||
nextDoNotDisturbEnd = status?["next_dnd_end_ts"] as? Int
|
||||
snoozeEnabled = status?["snooze_enabled"] as? Bool
|
||||
snoozeEndtime = status?["snooze_endtime"] as? Int
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// SlackKit.h
|
||||
// Edited.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
//
|
||||
@@ -21,10 +21,13 @@
|
||||
// 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[];
|
||||
public struct Edited {
|
||||
|
||||
public let user: String?
|
||||
public let ts: String?
|
||||
|
||||
internal init(edited:[String: Any]?) {
|
||||
user = edited?["user"] as? String
|
||||
ts = edited?["ts"] as? String
|
||||
}
|
||||
}
|
||||
+116
-121
@@ -22,107 +22,108 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
internal enum EventType: String {
|
||||
case Hello = "hello"
|
||||
case Message = "message"
|
||||
case UserTyping = "user_typing"
|
||||
case ChannelMarked = "channel_marked"
|
||||
case ChannelCreated = "channel_created"
|
||||
case ChannelJoined = "channel_joined"
|
||||
case ChannelLeft = "channel_left"
|
||||
case ChannelDeleted = "channel_deleted"
|
||||
case ChannelRenamed = "channel_rename"
|
||||
case ChannelArchive = "channel_archive"
|
||||
case ChannelUnarchive = "channel_unarchive"
|
||||
case ChannelHistoryChanged = "channel_history_changed"
|
||||
case DNDUpdated = "dnd_updated"
|
||||
case DNDUpatedUser = "dnd_updated_user"
|
||||
case IMCreated = "im_created"
|
||||
case IMOpen = "im_open"
|
||||
case IMClose = "im_close"
|
||||
case IMMarked = "im_marked"
|
||||
case IMHistoryChanged = "im_history_changed"
|
||||
case GroupJoined = "group_joined"
|
||||
case GroupLeft = "group_left"
|
||||
case GroupOpen = "group_open"
|
||||
case GroupClose = "group_close"
|
||||
case GroupArchive = "group_archive"
|
||||
case GroupUnarchive = "group_unarchive"
|
||||
case GroupRename = "group_rename"
|
||||
case GroupMarked = "group_marked"
|
||||
case GroupHistoryChanged = "group_history_changed"
|
||||
case FileCreated = "file_created"
|
||||
case FileShared = "file_shared"
|
||||
case FileUnshared = "file_unshared"
|
||||
case FilePublic = "file_public"
|
||||
case FilePrivate = "file_private"
|
||||
case FileChanged = "file_change"
|
||||
case FileDeleted = "file_deleted"
|
||||
case FileCommentAdded = "file_comment_added"
|
||||
case FileCommentEdited = "file_comment_edited"
|
||||
case FileCommentDeleted = "file_comment_deleted"
|
||||
case PinAdded = "pin_added"
|
||||
case PinRemoved = "pin_removed"
|
||||
case Pong = "pong"
|
||||
case PresenceChange = "presence_change"
|
||||
case ManualPresenceChange = "manual_presence_change"
|
||||
case PrefChange = "pref_change"
|
||||
case UserChange = "user_change"
|
||||
case TeamJoin = "team_join"
|
||||
case StarAdded = "star_added"
|
||||
case StarRemoved = "star_removed"
|
||||
case ReactionAdded = "reaction_added"
|
||||
case ReactionRemoved = "reaction_removed"
|
||||
case EmojiChanged = "emoji_changed"
|
||||
case CommandsChanged = "commands_changed"
|
||||
case TeamPlanChange = "team_plan_change"
|
||||
case TeamPrefChange = "team_pref_change"
|
||||
case TeamRename = "team_rename"
|
||||
case TeamDomainChange = "team_domain_change"
|
||||
case EmailDomainChange = "email_domain_change"
|
||||
case TeamProfileChange = "team_profile_change"
|
||||
case TeamProfileDelete = "team_profile_delete"
|
||||
case TeamProfileReorder = "team_profile_reorder"
|
||||
case BotAdded = "bot_added"
|
||||
case BotChanged = "bot_changed"
|
||||
case AccountsChanged = "accounts_changed"
|
||||
case TeamMigrationStarted = "team_migration_started"
|
||||
case ReconnectURL = "reconnect_url"
|
||||
case SubteamCreated = "subteam_created"
|
||||
case SubteamUpdated = "subteam_updated"
|
||||
case SubteamSelfAdded = "subteam_self_added"
|
||||
case SubteamSelfRemoved = "subteam_self_removed"
|
||||
case Ok = "ok"
|
||||
case Error = "error"
|
||||
|
||||
case hello = "hello"
|
||||
case message = "message"
|
||||
case userTyping = "user_typing"
|
||||
case channelMarked = "channel_marked"
|
||||
case channelCreated = "channel_created"
|
||||
case channelJoined = "channel_joined"
|
||||
case channelLeft = "channel_left"
|
||||
case channelDeleted = "channel_deleted"
|
||||
case channelRenamed = "channel_rename"
|
||||
case channelArchive = "channel_archive"
|
||||
case channelUnarchive = "channel_unarchive"
|
||||
case channelHistoryChanged = "channel_history_changed"
|
||||
case dndUpdated = "dnd_updated"
|
||||
case dndUpatedUser = "dnd_updated_user"
|
||||
case imCreated = "im_created"
|
||||
case imOpen = "im_open"
|
||||
case imClose = "im_close"
|
||||
case imMarked = "im_marked"
|
||||
case imHistoryChanged = "im_history_changed"
|
||||
case groupJoined = "group_joined"
|
||||
case groupLeft = "group_left"
|
||||
case groupOpen = "group_open"
|
||||
case groupClose = "group_close"
|
||||
case groupArchive = "group_archive"
|
||||
case groupUnarchive = "group_unarchive"
|
||||
case groupRename = "group_rename"
|
||||
case groupMarked = "group_marked"
|
||||
case groupHistoryChanged = "group_history_changed"
|
||||
case fileCreated = "file_created"
|
||||
case fileShared = "file_shared"
|
||||
case fileUnshared = "file_unshared"
|
||||
case filePublic = "file_public"
|
||||
case filePrivate = "file_private"
|
||||
case fileChanged = "file_change"
|
||||
case fileDeleted = "file_deleted"
|
||||
case fileCommentAdded = "file_comment_added"
|
||||
case fileCommentEdited = "file_comment_edited"
|
||||
case fileCommentDeleted = "file_comment_deleted"
|
||||
case pinAdded = "pin_added"
|
||||
case pinRemoved = "pin_removed"
|
||||
case pong = "pong"
|
||||
case presenceChange = "presence_change"
|
||||
case manualPresenceChange = "manual_presence_change"
|
||||
case prefChange = "pref_change"
|
||||
case userChange = "user_change"
|
||||
case teamJoin = "team_join"
|
||||
case starAdded = "star_added"
|
||||
case starRemoved = "star_removed"
|
||||
case reactionAdded = "reaction_added"
|
||||
case reactionRemoved = "reaction_removed"
|
||||
case emojiChanged = "emoji_changed"
|
||||
case commandsChanged = "commands_changed"
|
||||
case teamPlanChange = "team_plan_change"
|
||||
case teamPrefChange = "team_pref_change"
|
||||
case teamRename = "team_rename"
|
||||
case teamDomainChange = "team_domain_change"
|
||||
case emailDomainChange = "email_domain_change"
|
||||
case teamProfileChange = "team_profile_change"
|
||||
case teamProfileDelete = "team_profile_delete"
|
||||
case teamProfileReorder = "team_profile_reorder"
|
||||
case botAdded = "bot_added"
|
||||
case botChanged = "bot_changed"
|
||||
case accountsChanged = "accounts_changed"
|
||||
case teamMigrationStarted = "team_migration_started"
|
||||
case reconnectURL = "reconnect_url"
|
||||
case subteamCreated = "subteam_created"
|
||||
case subteamUpdated = "subteam_updated"
|
||||
case subteamSelfAdded = "subteam_self_added"
|
||||
case subteamSelfRemoved = "subteam_self_removed"
|
||||
case ok = "ok"
|
||||
case unknown = "unknown"
|
||||
}
|
||||
|
||||
internal enum MessageSubtype: String {
|
||||
case BotMessage = "bot_message"
|
||||
case MeMessage = "me_message"
|
||||
case MessageChanged = "message_changed"
|
||||
case MessageDeleted = "message_deleted"
|
||||
case ChannelJoin = "channel_join"
|
||||
case ChannelLeave = "channel_leave"
|
||||
case ChannelTopic = "channel_topic"
|
||||
case ChannelPurpose = "channel_purpose"
|
||||
case ChannelName = "channel_name"
|
||||
case ChannelArchive = "channel_archive"
|
||||
case ChannelUnarchive = "channel_unarchive"
|
||||
case GroupJoin = "group_join"
|
||||
case GroupLeave = "group_leave"
|
||||
case GroupTopic = "group_topic"
|
||||
case GroupPurpose = "group_purpose"
|
||||
case GroupName = "group_name"
|
||||
case GroupArchive = "group_archive"
|
||||
case GroupUnarchive = "group_unarchive"
|
||||
case FileShare = "file_share"
|
||||
case FileComment = "file_comment"
|
||||
case FileMention = "file_mention"
|
||||
case PinnedItem = "pinned_item"
|
||||
case UnpinnedItem = "unpinned_item"
|
||||
|
||||
case botMessage = "bot_message"
|
||||
case meMessage = "me_message"
|
||||
case messageChanged = "message_changed"
|
||||
case messageDeleted = "message_deleted"
|
||||
case channelJoin = "channel_join"
|
||||
case channelLeave = "channel_leave"
|
||||
case channelTopic = "channel_topic"
|
||||
case channelPurpose = "channel_purpose"
|
||||
case channelName = "channel_name"
|
||||
case channelArchive = "channel_archive"
|
||||
case channelUnarchive = "channel_unarchive"
|
||||
case groupJoin = "group_join"
|
||||
case groupLeave = "group_leave"
|
||||
case groupTopic = "group_topic"
|
||||
case groupPurpose = "group_purpose"
|
||||
case groupName = "group_name"
|
||||
case groupArchive = "group_archive"
|
||||
case groupUnarchive = "group_unarchive"
|
||||
case fileShare = "file_share"
|
||||
case fileComment = "file_comment"
|
||||
case fileMention = "file_mention"
|
||||
case pinnedItem = "pinned_item"
|
||||
case unpinnedItem = "unpinned_item"
|
||||
}
|
||||
|
||||
internal struct Event {
|
||||
|
||||
internal class Event {
|
||||
let type: EventType?
|
||||
let ts: String?
|
||||
let subtype: String?
|
||||
@@ -137,14 +138,14 @@ internal struct Event {
|
||||
let fileID: String?
|
||||
let presence: String?
|
||||
let name: String?
|
||||
let value: AnyObject?
|
||||
let value: Any?
|
||||
let plan: String?
|
||||
let url: String?
|
||||
let domain: String?
|
||||
let emailDomain: String?
|
||||
let reaction: String?
|
||||
let replyTo: Double?
|
||||
let reactions: [[String: AnyObject]]?
|
||||
let reactions: [[String: Any]]?
|
||||
let edited: Edited?
|
||||
let bot: Bot?
|
||||
let channel: Channel?
|
||||
@@ -160,12 +161,8 @@ internal struct Event {
|
||||
let subteamID: String?
|
||||
var profile: CustomProfile?
|
||||
|
||||
init(event:[String: AnyObject]) {
|
||||
if let eventType = event["type"] as? String {
|
||||
type = EventType(rawValue:eventType)
|
||||
} else {
|
||||
type = EventType(rawValue: "ok")
|
||||
}
|
||||
init(_ event:[String: Any]) {
|
||||
type = EventType(rawValue: event["type"] as? String ?? "ok")
|
||||
ts = event["ts"] as? String
|
||||
subtype = event["subtype"] as? String
|
||||
channelID = event["channel_id"] as? String
|
||||
@@ -186,38 +183,36 @@ 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: AnyObject]]
|
||||
bot = Bot(bot: event["bot"] as? [String: AnyObject])
|
||||
edited = Edited(edited:event["edited"] as? [String: AnyObject])
|
||||
dndStatus = DoNotDisturbStatus(status: event["dnd_status"] as? [String: AnyObject])
|
||||
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])
|
||||
itemUser = event["item_user"] as? String
|
||||
item = Item(item: event["item"] as? [String: AnyObject])
|
||||
subteam = UserGroup(userGroup: event["subteam"] as? [String: AnyObject])
|
||||
item = Item(item: event["item"] as? [String: Any])
|
||||
subteam = UserGroup(userGroup: event["subteam"] as? [String: Any])
|
||||
subteamID = event["subteam_id"] as? String
|
||||
message = Message(message: event)
|
||||
nestedMessage = Message(message: event["message"] as? [String: AnyObject])
|
||||
profile = CustomProfile(profile: event["profile"] as? [String: AnyObject])
|
||||
message = Message(dictionary: event)
|
||||
nestedMessage = Message(dictionary: event["message"] as? [String: Any])
|
||||
profile = CustomProfile(profile: event["profile"] as? [String: Any])
|
||||
file = File(id: event["file"] as? String)
|
||||
|
||||
|
||||
// Comment, Channel, and User can come across as Strings or Dictionaries
|
||||
if let commentDictionary = event["comment"] as? [String: AnyObject] {
|
||||
if let commentDictionary = event["comment"] as? [String: Any] {
|
||||
comment = Comment(comment: commentDictionary)
|
||||
} else {
|
||||
comment = Comment(id: event["comment"] as? String)
|
||||
}
|
||||
|
||||
if let userDictionary = event["user"] as? [String: AnyObject] {
|
||||
|
||||
if let userDictionary = event["user"] as? [String: Any] {
|
||||
user = User(user: userDictionary)
|
||||
} else {
|
||||
user = User(id: event["user"] as? String)
|
||||
}
|
||||
|
||||
if let channelDictionary = event["channel"] as? [String: AnyObject] {
|
||||
|
||||
if let channelDictionary = event["channel"] as? [String: Any] {
|
||||
channel = Channel(channel: channelDictionary)
|
||||
} else {
|
||||
channel = Channel(id: event["channel"] as? String)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,88 +21,89 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
public protocol SlackEventsDelegate: class {
|
||||
func clientConnectionFailed(error: SlackError)
|
||||
func clientConnected()
|
||||
func clientDisconnected()
|
||||
func preferenceChanged(preference: String, value: AnyObject?)
|
||||
func userChanged(user: User)
|
||||
func presenceChanged(user: User, presence: String)
|
||||
func manualPresenceChanged(user: User, presence: String)
|
||||
func botEvent(bot: Bot)
|
||||
public protocol ConnectionEventsDelegate: class {
|
||||
func connected(_ client: SlackClient)
|
||||
func disconnected(_ client: SlackClient)
|
||||
func connectionFailed(_ client: SlackClient, error: SlackError)
|
||||
}
|
||||
|
||||
public protocol MessageEventsDelegate: class {
|
||||
func messageSent(message: Message)
|
||||
func messageReceived(message: Message)
|
||||
func messageChanged(message: Message)
|
||||
func messageDeleted(message: Message?)
|
||||
func sent(_ message: Message, client: SlackClient)
|
||||
func received(_ message: Message, client: SlackClient)
|
||||
func changed(_ message: Message, client: SlackClient)
|
||||
func deleted(_ message: Message?, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol ChannelEventsDelegate: class {
|
||||
func userTyping(channel: Channel, user: User)
|
||||
func channelMarked(channel: Channel, timestamp: String)
|
||||
func channelCreated(channel: Channel)
|
||||
func channelDeleted(channel: Channel)
|
||||
func channelRenamed(channel: Channel)
|
||||
func channelArchived(channel: Channel)
|
||||
func channelHistoryChanged(channel: Channel)
|
||||
func channelJoined(channel: Channel)
|
||||
func channelLeft(channel: Channel)
|
||||
func userTypingIn(_ channel: Channel, user: User, client: SlackClient)
|
||||
func marked(_ channel: Channel, timestamp: String, client: SlackClient)
|
||||
func created(_ channel: Channel, client: SlackClient)
|
||||
func deleted(_ channel: Channel, client: SlackClient)
|
||||
func renamed(_ channel: Channel, client: SlackClient)
|
||||
func archived(_ channel: Channel, client: SlackClient)
|
||||
func historyChanged(_ channel: Channel, client: SlackClient)
|
||||
func joined(_ channel: Channel, client: SlackClient)
|
||||
func left(_ channel: Channel, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol DoNotDisturbEventsDelegate: class {
|
||||
func doNotDisturbUpdated(dndStatus: DoNotDisturbStatus)
|
||||
func doNotDisturbUserUpdated(dndStatus: DoNotDisturbStatus, user: User)
|
||||
func updated(_ status: DoNotDisturbStatus, client: SlackClient)
|
||||
func userUpdated(_ status: DoNotDisturbStatus, user: User, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol GroupEventsDelegate: class {
|
||||
func groupOpened(group: Channel)
|
||||
func opened(_ group: Channel, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol FileEventsDelegate: class {
|
||||
func fileProcessed(file: File)
|
||||
func fileMadePrivate(file: File)
|
||||
func fileDeleted(file: File)
|
||||
func fileCommentAdded(file: File, comment: Comment)
|
||||
func fileCommentEdited(file: File, comment: Comment)
|
||||
func fileCommentDeleted(file: File, comment: Comment)
|
||||
func processed(_ file: File, client: SlackClient)
|
||||
func madePrivate(_ file: File, client: SlackClient)
|
||||
func deleted(_ file: File, client: SlackClient)
|
||||
func commentAdded(_ file: File, comment: Comment, client: SlackClient)
|
||||
func commentEdited(_ file: File, comment: Comment, client: SlackClient)
|
||||
func commentDeleted(_ file: File, comment: Comment, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol PinEventsDelegate: class {
|
||||
func itemPinned(item: Item, channel: Channel?)
|
||||
func itemUnpinned(item: Item, channel: Channel?)
|
||||
func pinned(_ item: Item, channel: Channel?, client: SlackClient)
|
||||
func unpinned(_ item: Item, channel: Channel?, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol StarEventsDelegate: class {
|
||||
func itemStarred(item: Item, star: Bool)
|
||||
func starred(_ item: Item, starred: Bool, _ client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol ReactionEventsDelegate: class {
|
||||
func reactionAdded(reaction: String, item: Item, itemUser: String)
|
||||
func reactionRemoved(reaction: String, item: Item, itemUser: String)
|
||||
func added(_ reaction: String, item: Item, itemUser: String, client: SlackClient)
|
||||
func removed(_ reaction: String, item: Item, itemUser: String, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol SlackEventsDelegate: class {
|
||||
func preferenceChanged(_ preference: String, value: Any?, client: SlackClient)
|
||||
func userChanged(_ user: User, client: SlackClient)
|
||||
func presenceChanged(_ user: User, presence: String, client: SlackClient)
|
||||
func manualPresenceChanged(_ user: User, presence: String, client: SlackClient)
|
||||
func botEvent(_ bot: Bot, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol TeamEventsDelegate: class {
|
||||
func teamJoined(user: User)
|
||||
func teamPlanChanged(plan: String)
|
||||
func teamPreferencesChanged(preference: String, value: AnyObject?)
|
||||
func teamNameChanged(name: String)
|
||||
func teamDomainChanged(domain: String)
|
||||
func teamEmailDomainChanged(domain: String)
|
||||
func teamEmojiChanged()
|
||||
func userJoined(_ user: User, client: SlackClient)
|
||||
func planChanged(_ plan: String, client: SlackClient)
|
||||
func preferencesChanged(_ preference: String, value: Any?, client: SlackClient)
|
||||
func nameChanged(_ name: String, client: SlackClient)
|
||||
func domainChanged(_ domain: String, client: SlackClient)
|
||||
func emailDomainChanged(_ domain: String, client: SlackClient)
|
||||
func emojiChanged(_ client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol SubteamEventsDelegate: class {
|
||||
func subteamEvent(userGroup: UserGroup)
|
||||
func subteamSelfAdded(subteamID: String)
|
||||
func subteamSelfRemoved(subteamID: String)
|
||||
func event(_ userGroup: UserGroup, client: SlackClient)
|
||||
func selfAdded(_ subteamID: String, client: SlackClient)
|
||||
func selfRemoved(_ subteamID: String, client: SlackClient)
|
||||
}
|
||||
|
||||
public protocol TeamProfileEventsDelegate: class {
|
||||
func teamProfileChanged(profile: CustomProfile)
|
||||
func teamProfileDeleted(profile: CustomProfile)
|
||||
func teamProfileReordered(profile: CustomProfile)
|
||||
func changed(_ profile: CustomProfile, client: SlackClient)
|
||||
func deleted(_ profile: CustomProfile, client: SlackClient)
|
||||
func reordered(_ profile: CustomProfile, client: SlackClient)
|
||||
}
|
||||
|
||||
@@ -23,21 +23,34 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension NSDate {
|
||||
|
||||
func slackTimestamp() -> Double {
|
||||
return NSNumber(double: timeIntervalSince1970).doubleValue
|
||||
}
|
||||
public extension Date {
|
||||
|
||||
var slackTimestamp: Double {
|
||||
return NSNumber(value: timeIntervalSince1970).doubleValue
|
||||
}
|
||||
}
|
||||
|
||||
internal extension String {
|
||||
|
||||
func slackFormatEscaping() -> String {
|
||||
var escapedString = stringByReplacingOccurrencesOfString("&", withString: "&")
|
||||
escapedString = stringByReplacingOccurrencesOfString("<", withString: "<")
|
||||
escapedString = stringByReplacingOccurrencesOfString(">", withString: ">")
|
||||
var slackFormatEscaping: String {
|
||||
var escapedString = replacingOccurrences(of: "&", with: "&")
|
||||
escapedString = replacingOccurrences(of: "<", with: "<")
|
||||
escapedString = replacingOccurrences(of: ">", with: ">")
|
||||
return escapedString
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal extension Dictionary where Key: ExpressibleByStringLiteral, Value: Any {
|
||||
|
||||
var requestStringFromParameters: String {
|
||||
var requestString = ""
|
||||
for key in self.keys {
|
||||
if let value = self[key] as? String, let encodedValue = value.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) {
|
||||
requestString += "&\(key)=\(encodedValue)"
|
||||
} else if let value = self[key] {
|
||||
requestString += "&\(key)=\(value)"
|
||||
}
|
||||
}
|
||||
return requestString
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
public struct File {
|
||||
|
||||
public struct File: Equatable {
|
||||
|
||||
public let id: String?
|
||||
public let created: Int?
|
||||
public let name: String?
|
||||
@@ -78,7 +78,7 @@ public struct File {
|
||||
internal(set) public var comments = [String: Comment]()
|
||||
internal(set) public var reactions = [Reaction]()
|
||||
|
||||
public init(file:[String: AnyObject]?) {
|
||||
public init(file:[String: Any]?) {
|
||||
id = file?["id"] as? String
|
||||
created = file?["created"] as? Int
|
||||
name = file?["name"] as? String
|
||||
@@ -127,11 +127,11 @@ public struct File {
|
||||
channels = file?["channels"] as? [String]
|
||||
groups = file?["groups"] as? [String]
|
||||
ims = file?["ims"] as? [String]
|
||||
initialComment = Comment(comment: file?["initial_comment"] as? [String: AnyObject])
|
||||
initialComment = Comment(comment: file?["initial_comment"] as? [String: Any])
|
||||
stars = file?["num_stars"] as? Int
|
||||
isStarred = file?["is_starred"] as? Bool
|
||||
pinnedTo = file?["pinned_to"] as? [String]
|
||||
reactions = Reaction.reactionsFromArray(file?["reactions"] as? [[String: AnyObject]])
|
||||
reactions = Reaction.reactionsFromArray(file?["reactions"] as? [[String: Any]])
|
||||
}
|
||||
|
||||
internal init(id:String?) {
|
||||
@@ -179,11 +179,8 @@ public struct File {
|
||||
linesMore = nil
|
||||
initialComment = nil
|
||||
}
|
||||
|
||||
public static func ==(lhs: File, rhs: File) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
|
||||
extension File: Equatable {}
|
||||
|
||||
public func ==(lhs: File, rhs: File) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// History.swift
|
||||
//
|
||||
// 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
|
||||
|
||||
public struct History {
|
||||
|
||||
internal(set) public var latest: Date?
|
||||
internal(set) public var messages = [Message]()
|
||||
public let hasMore: Bool?
|
||||
|
||||
internal init(history: [String: Any]?) {
|
||||
if let latestStr = history?["latest"] as? String, let latestDouble = Double(latestStr) {
|
||||
latest = Date(timeIntervalSince1970: TimeInterval(latestDouble))
|
||||
}
|
||||
if let msgs = history?["messages"] as? [[String: Any]] {
|
||||
for message in msgs {
|
||||
messages.append(Message(dictionary: message))
|
||||
}
|
||||
}
|
||||
hasMore = history?["has_more"] as? Bool
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
//
|
||||
// Item.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct Item: Equatable {
|
||||
|
||||
public let type: String?
|
||||
public let ts: String?
|
||||
public let channel: String?
|
||||
public let message: Message?
|
||||
public let file: File?
|
||||
public let comment: Comment?
|
||||
public let fileCommentID: String?
|
||||
|
||||
internal init(item:[String: Any]?) {
|
||||
type = item?["type"] as? String
|
||||
ts = item?["ts"] as? String
|
||||
channel = item?["channel"] as? String
|
||||
message = Message(dictionary: item?["message"] as? [String: Any])
|
||||
|
||||
// Comment and File can come across as Strings or Dictionaries
|
||||
if let commentDictionary = item?["comment"] as? [String: Any] {
|
||||
comment = Comment(comment: commentDictionary)
|
||||
} else {
|
||||
comment = Comment(id: item?["comment"] as? String)
|
||||
}
|
||||
|
||||
if let fileDictionary = item?["file"] as? [String: Any] {
|
||||
file = File(file: fileDictionary)
|
||||
} else {
|
||||
file = File(id: item?["file"] as? String)
|
||||
}
|
||||
|
||||
fileCommentID = item?["file_comment"] as? String
|
||||
}
|
||||
|
||||
public static func ==(lhs: Item, rhs: Item) -> Bool {
|
||||
return lhs.type == rhs.type && lhs.channel == rhs.channel && lhs.file == rhs.file && lhs.comment == rhs.comment && lhs.message == rhs.message
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
public class Message {
|
||||
public final class Message: Equatable {
|
||||
|
||||
public let type = "message"
|
||||
public let subtype: String?
|
||||
@@ -32,7 +32,7 @@ public class Message {
|
||||
internal(set) public var text: String?
|
||||
public let botID: String?
|
||||
public let username: String?
|
||||
public let icons: [String: AnyObject]?
|
||||
public let icons: [String: Any]?
|
||||
public let deletedTs: String?
|
||||
internal(set) var purpose: String?
|
||||
internal(set) var topic: String?
|
||||
@@ -47,33 +47,37 @@ public class Message {
|
||||
public let file: File?
|
||||
internal(set) public var reactions = [Reaction]()
|
||||
internal(set) public var attachments: [Attachment]?
|
||||
internal(set) public var responseType: ResponseType?
|
||||
internal(set) public var replaceOriginal: Bool?
|
||||
internal(set) public var deleteOriginal: Bool?
|
||||
|
||||
public init(message: [String: AnyObject]?) {
|
||||
subtype = message?["subtype"] as? String
|
||||
ts = message?["ts"] as? String
|
||||
user = message?["user"] as? String
|
||||
channel = message?["channel"] as? String
|
||||
hidden = message?["hidden"] as? Bool
|
||||
text = message?["text"] as? String
|
||||
botID = message?["bot_id"] as? String
|
||||
username = message?["username"] as? String
|
||||
icons = message?["icons"] as? [String: AnyObject]
|
||||
deletedTs = message?["deleted_ts"] as? String
|
||||
purpose = message?["purpose"] as? String
|
||||
topic = message?["topic"] as? String
|
||||
name = message?["name"] as? String
|
||||
members = message?["members"] as? [String]
|
||||
oldName = message?["old_name"] as? String
|
||||
upload = message?["upload"] as? Bool
|
||||
itemType = message?["item_type"] as? String
|
||||
isStarred = message?["is_starred"] as? Bool
|
||||
pinnedTo = message?["pinned_to"] as? [String]
|
||||
comment = Comment(comment: message?["comment"] as? [String: AnyObject])
|
||||
file = File(file: message?["file"] as? [String: AnyObject])
|
||||
reactions = Reaction.reactionsFromArray(message?["reactions"] as? [[String: AnyObject]])
|
||||
attachments = (message?["attachments"] as? [[String: AnyObject]])?.map({(attachment) -> Attachment in
|
||||
return Attachment(attachment: attachment)
|
||||
})
|
||||
public init(dictionary: [String: Any]?) {
|
||||
subtype = dictionary?["subtype"] as? String
|
||||
ts = dictionary?["ts"] as? String
|
||||
user = dictionary?["user"] as? String
|
||||
channel = dictionary?["channel"] as? String
|
||||
hidden = dictionary?["hidden"] as? Bool
|
||||
text = dictionary?["text"] as? String
|
||||
botID = dictionary?["bot_id"] as? String
|
||||
username = dictionary?["username"] as? String
|
||||
icons = dictionary?["icons"] as? [String: Any]
|
||||
deletedTs = dictionary?["deleted_ts"] as? String
|
||||
purpose = dictionary?["purpose"] as? String
|
||||
topic = dictionary?["topic"] as? String
|
||||
name = dictionary?["name"] as? String
|
||||
members = dictionary?["members"] as? [String]
|
||||
oldName = dictionary?["old_name"] as? String
|
||||
upload = dictionary?["upload"] as? Bool
|
||||
itemType = dictionary?["item_type"] as? String
|
||||
isStarred = dictionary?["is_starred"] as? Bool
|
||||
pinnedTo = dictionary?["pinned_to"] as? [String]
|
||||
comment = Comment(comment: dictionary?["comment"] as? [String: Any])
|
||||
file = File(file: dictionary?["file"] as? [String: Any])
|
||||
reactions = Reaction.reactionsFromArray(dictionary?["reactions"] as? [[String: Any]])
|
||||
attachments = (dictionary?["attachments"] as? [[String: Any]])?.map{Attachment(attachment: $0)}
|
||||
responseType = ResponseType(rawValue: dictionary?["response_type"] as? String ?? "")
|
||||
replaceOriginal = dictionary?["replace_original"] as? Bool
|
||||
deleteOriginal = dictionary?["delete_original"] as? Bool
|
||||
}
|
||||
|
||||
internal init(ts:String?) {
|
||||
@@ -90,11 +94,8 @@ public class Message {
|
||||
comment = nil
|
||||
file = nil
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Message: Equatable {}
|
||||
|
||||
public func ==(lhs: Message, rhs: Message) -> Bool {
|
||||
return lhs.ts == rhs.ts && lhs.user == rhs.user && lhs.text == rhs.text
|
||||
|
||||
public static func ==(lhs: Message, rhs: Message) -> Bool {
|
||||
return lhs.ts == rhs.ts && lhs.user == rhs.user && lhs.text == rhs.text
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,121 +22,113 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
import HTTPClient
|
||||
import WebSocketClient
|
||||
|
||||
internal struct NetworkInterface {
|
||||
|
||||
private let apiUrl = "https://slack.com/api/"
|
||||
private let client: HTTPClient.Client?
|
||||
|
||||
internal func request(endpoint: SlackAPIEndpoint, token: String, parameters: [String: AnyObject]?, successClosure: ([String: AnyObject])->Void, errorClosure: (SlackError)->Void) {
|
||||
init() {
|
||||
do {
|
||||
self.client = try Client(url: URL(string: "https://slack.com")!)
|
||||
} catch {
|
||||
self.client = nil
|
||||
}
|
||||
}
|
||||
|
||||
internal func request(_ endpoint: Endpoint, token: String, parameters: [String: Any]?, successClosure: ([String: Any])->Void, errorClosure: (SlackError)->Void) {
|
||||
var requestString = "\(apiUrl)\(endpoint.rawValue)?token=\(token)"
|
||||
if let params = parameters {
|
||||
requestString += requestStringFromParameters(params)
|
||||
requestString += params.requestStringFromParameters
|
||||
}
|
||||
guard let url = NSURL(string: requestString) else {
|
||||
errorClosure(SlackError.ClientNetworkError)
|
||||
return
|
||||
}
|
||||
let request = NSURLRequest(URL:url)
|
||||
NSURLSession.sharedSession().dataTaskWithRequest(request) {
|
||||
(data, response, internalError) -> Void in
|
||||
self.handleResponse(data, response: response, internalError: internalError, successClosure: {(json) in
|
||||
successClosure(json)
|
||||
}, errorClosure: {(error) in
|
||||
errorClosure(error)
|
||||
})
|
||||
}.resume()
|
||||
}
|
||||
|
||||
internal func uploadRequest(token: String, data: NSData, parameters: [String: AnyObject]?, successClosure: ([String: AnyObject])->Void, errorClosure: (SlackError)->Void) {
|
||||
var requestString = "\(apiUrl)\(SlackAPIEndpoint.FilesUpload.rawValue)?token=\(token)"
|
||||
if let params = parameters {
|
||||
requestString = requestString + requestStringFromParameters(params)
|
||||
}
|
||||
guard let url = NSURL(string: requestString) else {
|
||||
errorClosure(SlackError.ClientNetworkError)
|
||||
return
|
||||
}
|
||||
let request = NSMutableURLRequest(URL:url)
|
||||
request.HTTPMethod = "POST"
|
||||
let boundaryConstant = randomBoundary()
|
||||
let contentType = "multipart/form-data; boundary=" + boundaryConstant
|
||||
let boundaryStart = "--\(boundaryConstant)\r\n"
|
||||
let boundaryEnd = "--\(boundaryConstant)--\r\n"
|
||||
let contentDispositionString = "Content-Disposition: form-data; name=\"file\"; filename=\"\(parameters!["filename"])\"\r\n"
|
||||
let contentTypeString = "Content-Type: \(parameters!["filetype"])\r\n\r\n"
|
||||
|
||||
let requestBodyData : NSMutableData = NSMutableData()
|
||||
requestBodyData.appendData(boundaryStart.dataUsingEncoding(NSUTF8StringEncoding)!)
|
||||
requestBodyData.appendData(contentDispositionString.dataUsingEncoding(NSUTF8StringEncoding)!)
|
||||
requestBodyData.appendData(contentTypeString.dataUsingEncoding(NSUTF8StringEncoding)!)
|
||||
requestBodyData.appendData(data)
|
||||
requestBodyData.appendData("\r\n".dataUsingEncoding(NSUTF8StringEncoding)!)
|
||||
requestBodyData.appendData(boundaryEnd.dataUsingEncoding(NSUTF8StringEncoding)!)
|
||||
|
||||
request.setValue(contentType, forHTTPHeaderField: "Content-Type")
|
||||
request.HTTPBody = requestBodyData
|
||||
|
||||
NSURLSession.sharedSession().dataTaskWithRequest(request) {
|
||||
(data, response, internalError) -> Void in
|
||||
self.handleResponse(data, response: response, internalError: internalError, successClosure: {(json) in
|
||||
successClosure(json)
|
||||
}, errorClosure: {(error) in
|
||||
errorClosure(error)
|
||||
})
|
||||
}.resume()
|
||||
}
|
||||
|
||||
private func handleResponse(data: NSData?, response:NSURLResponse?, internalError:NSError?, successClosure: ([String: AnyObject])->Void, errorClosure: (SlackError)->Void) {
|
||||
guard let data = data, response = response as? NSHTTPURLResponse else {
|
||||
errorClosure(SlackError.ClientNetworkError)
|
||||
return
|
||||
}
|
||||
do {
|
||||
guard let json = try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String: AnyObject] else {
|
||||
errorClosure(SlackError.ClientJSONError)
|
||||
return
|
||||
}
|
||||
|
||||
switch response.statusCode {
|
||||
case 200:
|
||||
if (json["ok"] as! Bool == true) {
|
||||
successClosure(json)
|
||||
} else {
|
||||
if let errorString = json["error"] as? String {
|
||||
throw ErrorDispatcher.dispatch(errorString)
|
||||
let contentNegotiation = ContentNegotiationMiddleware(mediaTypes: [.json, .urlEncodedForm], mode: .client)
|
||||
var response = try client?.get(requestString, middleware: [contentNegotiation])
|
||||
if let buffer = try response?.body.becomeBuffer(deadline: 3.seconds.fromNow()) {
|
||||
let data = Data(bytes: buffer.bytes)
|
||||
let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
|
||||
if let result = json as? [String: Any] {
|
||||
if (result["ok"] as? Bool == true) {
|
||||
successClosure(result)
|
||||
} else {
|
||||
throw SlackError.UnknownError
|
||||
if let errorString = result["error"] as? String {
|
||||
throw SlackError(rawValue: errorString) ?? SlackError.unknownError
|
||||
} else {
|
||||
throw SlackError.unknownError
|
||||
}
|
||||
}
|
||||
}
|
||||
case 429:
|
||||
throw SlackError.TooManyRequests
|
||||
default:
|
||||
throw SlackError.ClientNetworkError
|
||||
}
|
||||
} catch let error {
|
||||
if let slackError = error as? SlackError {
|
||||
errorClosure(slackError)
|
||||
} else {
|
||||
errorClosure(SlackError.UnknownError)
|
||||
errorClosure(SlackError.unknownError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal func uploadRequest(token: String, data: Data, parameters: [String: Any]?, successClosure: ([String: Any])->Void, errorClosure: (SlackError)->Void) {
|
||||
var requestString = "\(apiUrl)\(Endpoint.filesUpload.rawValue)?token=\(token)"
|
||||
if let params = parameters {
|
||||
requestString = requestString + params.requestStringFromParameters
|
||||
}
|
||||
|
||||
let boundaryConstant = randomBoundary()
|
||||
let boundaryStart = "--\(boundaryConstant)\r\n"
|
||||
let boundaryEnd = "\r\n--\(boundaryConstant)--\r\n"
|
||||
let contentDispositionString = "Content-Disposition: form-data; name=\"file\"; filename=\"\(parameters!["filename"])\"\r\n"
|
||||
let contentTypeString = "Content-Type: \(parameters!["filetype"])\r\n\r\n"
|
||||
|
||||
guard let boundaryStartData = boundaryStart.data(using: .utf8), let dispositionData = contentDispositionString.data(using: .utf8), let contentTypeData = contentTypeString.data(using: .utf8), let boundaryEndData = boundaryEnd.data(using: .utf8) else {
|
||||
errorClosure(SlackError.clientNetworkError)
|
||||
return
|
||||
}
|
||||
var requestBodyData = Data()
|
||||
requestBodyData.append(contentsOf: boundaryStartData)
|
||||
requestBodyData.append(contentsOf: dispositionData)
|
||||
requestBodyData.append(contentsOf: contentTypeData)
|
||||
requestBodyData.append(contentsOf: data)
|
||||
requestBodyData.append(contentsOf: boundaryEndData)
|
||||
|
||||
let header: Headers = ["Content-Type":"multipart/form-data; boundary=\(boundaryConstant)"]
|
||||
|
||||
do {
|
||||
let body = Buffer([UInt8](requestBodyData))
|
||||
var response = try client?.post(requestString, headers: header, body: body)
|
||||
if let buffer = try response?.body.becomeBuffer(deadline: 3.seconds.fromNow()) {
|
||||
let data = Data(bytes: buffer.bytes)
|
||||
let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
|
||||
if let result = json as? [String: Any] {
|
||||
if (result["ok"] as? Bool == true) {
|
||||
successClosure(result)
|
||||
} else {
|
||||
if let errorString = result["error"] as? String {
|
||||
throw SlackError(rawValue: errorString) ?? SlackError.unknownError
|
||||
} else {
|
||||
throw SlackError.unknownError
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch let error {
|
||||
if let slackError = error as? SlackError {
|
||||
errorClosure(slackError)
|
||||
} else {
|
||||
errorClosure(SlackError.unknownError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func randomBoundary() -> String {
|
||||
return String(format: "slackkit.boundary.%08x%08x", arc4random(), arc4random())
|
||||
#if os(Linux)
|
||||
return "slackkit.boundary.\(Int(random()))\(Int(random()))"
|
||||
#else
|
||||
return "slackkit.boundary.\(arc4random())\(arc4random())"
|
||||
#endif
|
||||
}
|
||||
|
||||
private func requestStringFromParameters(parameters: [String: AnyObject]) -> String {
|
||||
var requestString = ""
|
||||
for key in parameters.keys {
|
||||
if let value = parameters[key] as? String, encodedValue = value.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLHostAllowedCharacterSet()) {
|
||||
requestString += "&\(key)=\(encodedValue)"
|
||||
} else if let value = parameters[key] as? Int {
|
||||
requestString += "&\(key)=\(value)"
|
||||
}
|
||||
}
|
||||
|
||||
return requestString
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// Reaction.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct Reaction: Equatable {
|
||||
|
||||
public let name: String?
|
||||
internal(set) public var user: String?
|
||||
|
||||
internal init(reaction:[String: Any]?) {
|
||||
name = reaction?["name"] as? String
|
||||
}
|
||||
|
||||
internal init(name: String, user: String) {
|
||||
self.name = name
|
||||
self.user = user
|
||||
}
|
||||
|
||||
static func reactionsFromArray(_ array: [[String: Any]]?) -> [Reaction] {
|
||||
var reactions = [Reaction]()
|
||||
if let array = array {
|
||||
for reaction in array {
|
||||
if let users = reaction["users"] as? [String], let name = reaction["name"] as? String {
|
||||
for user in users {
|
||||
reactions.append(Reaction(name: name, user: user))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reactions
|
||||
}
|
||||
|
||||
public static func ==(lhs: Reaction, rhs: Reaction) -> Bool {
|
||||
return lhs.name == rhs.name
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// SlackError.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public enum SlackError: String, Error {
|
||||
case accountInactive = "account_inactive"
|
||||
case alreadyArchived = "already_archived"
|
||||
case alreadyInChannel = "already_in_channel"
|
||||
case alreadyPinned = "already_pinned"
|
||||
case alreadyReacted = "already_reacted"
|
||||
case alreadyStarred = "already_starred"
|
||||
case badClientSecret = "bad_client_secret"
|
||||
case badRedirectURI = "bad_redirect_uri"
|
||||
case badTimeStamp = "bad_timestamp"
|
||||
case cantArchiveGeneral = "cant_archive_general"
|
||||
case cantDelete = "cant_delete"
|
||||
case cantDeleteFile = "cant_delete_file"
|
||||
case cantDeleteMessage = "cant_delete_message"
|
||||
case cantInvite = "cant_invite"
|
||||
case cantInviteSelf = "cant_invite_self"
|
||||
case cantKickFromGeneral = "cant_kick_from_general"
|
||||
case cantKickFromLastChannel = "cant_kick_from_last_channel"
|
||||
case cantKickSelf = "cant_kick_self"
|
||||
case cantLeaveGeneral = "cant_leave_general"
|
||||
case cantLeaveLastChannel = "cant_leave_last_channel"
|
||||
case cantUpdateMessage = "cant_update_message"
|
||||
case channelNotFound = "channel_not_found"
|
||||
case complianceExportsPreventDeletion = "compliance_exports_prevent_deletion"
|
||||
case editWindowClosed = "edit_window_closed"
|
||||
case fileCommentNotFound = "file_comment_not_found"
|
||||
case fileDeleted = "file_deleted"
|
||||
case fileNotFound = "file_not_found"
|
||||
case fileNotShared = "file_not_shared"
|
||||
case groupContainsOthers = "group_contains_others"
|
||||
case invalidArgName = "invalid_arg_name"
|
||||
case invalidArrayArg = "invalid_array_arg"
|
||||
case invalidAuth = "invalid_auth"
|
||||
case invalidChannel = "invalid_channel"
|
||||
case invalidCharSet = "invalid_charset"
|
||||
case invalidClientID = "invalid_client_id"
|
||||
case invalidCode = "invalid_code"
|
||||
case invalidFormData = "invalid_form_data"
|
||||
case invalidName = "invalid_name"
|
||||
case invalidPostType = "invalid_post_type"
|
||||
case invalidPresence = "invalid_presence"
|
||||
case invalidTS = "invalid_timestamp"
|
||||
case invalidTSLatest = "invalid_ts_latest"
|
||||
case invalidTSOldest = "invalid_ts_oldest"
|
||||
case isArchived = "is_archived"
|
||||
case lastMember = "last_member"
|
||||
case lastRAChannel = "last_ra_channel"
|
||||
case messageNotFound = "message_not_found"
|
||||
case messageTooLong = "msg_too_long"
|
||||
case migrationInProgress = "migration_in_progress"
|
||||
case missingDuration = "missing_duration"
|
||||
case missingPostType = "missing_post_type"
|
||||
case missingScope = "missing_scope"
|
||||
case nameTaken = "name_taken"
|
||||
case noChannel = "no_channel"
|
||||
case noComment = "no_comment"
|
||||
case noItemSpecified = "no_item_specified"
|
||||
case noReaction = "no_reaction"
|
||||
case noText = "no_text"
|
||||
case notArchived = "not_archived"
|
||||
case notAuthed = "not_authed"
|
||||
case notEnoughUsers = "not_enough_users"
|
||||
case notInChannel = "not_in_channel"
|
||||
case notInGroup = "not_in_group"
|
||||
case notPinned = "not_pinned"
|
||||
case notStarred = "not_starred"
|
||||
case overPaginationLimit = "over_pagination_limit"
|
||||
case paidOnly = "paid_only"
|
||||
case permissionDenied = "perimssion_denied"
|
||||
case postingToGeneralChannelDenied = "posting_to_general_channel_denied"
|
||||
case rateLimited = "rate_limited"
|
||||
case requestTimeout = "request_timeout"
|
||||
case restrictedAction = "restricted_action"
|
||||
case snoozeEndFailed = "snooze_end_failed"
|
||||
case snoozeFailed = "snooze_failed"
|
||||
case snoozeNotActive = "snooze_not_active"
|
||||
case tooLong = "too_long"
|
||||
case tooManyEmoji = "too_many_emoji"
|
||||
case tooManyReactions = "too_many_reactions"
|
||||
case tooManyUsers = "too_many_users"
|
||||
case unknownError
|
||||
case unknownType = "unknown_type"
|
||||
case userDisabled = "user_disabled"
|
||||
case userDoesNotOwnChannel = "user_does_not_own_channel"
|
||||
case userIsBot = "user_is_bot"
|
||||
case userIsRestricted = "user_is_restricted"
|
||||
case userIsUltraRestricted = "user_is_ultra_restricted"
|
||||
case userListNotSupplied = "user_list_not_supplied"
|
||||
case userNotFound = "user_not_found"
|
||||
case userNotVisible = "user_not_visible"
|
||||
// Client
|
||||
case clientNetworkError
|
||||
case clientJSONError
|
||||
case clientOAuthError
|
||||
// HTTP
|
||||
case tooManyRequests
|
||||
case unknownHTTPError
|
||||
}
|
||||
+429
-483
File diff suppressed because it is too large
Load Diff
@@ -1,296 +0,0 @@
|
||||
//
|
||||
// SlackWebAPIErrorDispatcher.swift
|
||||
//
|
||||
// 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
|
||||
|
||||
public enum SlackError: ErrorType {
|
||||
case AccountInactive
|
||||
case AlreadyArchived
|
||||
case AlreadyInChannel
|
||||
case AlreadyPinned
|
||||
case AlreadyReacted
|
||||
case AlreadyStarred
|
||||
case BadClientSecret
|
||||
case BadRedirectURI
|
||||
case BadTimeStamp
|
||||
case CantArchiveGeneral
|
||||
case CantDelete
|
||||
case CantDeleteFile
|
||||
case CantDeleteMessage
|
||||
case CantInvite
|
||||
case CantInviteSelf
|
||||
case CantKickFromGeneral
|
||||
case CantKickFromLastChannel
|
||||
case CantKickSelf
|
||||
case CantLeaveGeneral
|
||||
case CantLeaveLastChannel
|
||||
case CantUpdateMessage
|
||||
case ChannelNotFound
|
||||
case ComplianceExportsPreventDeletion
|
||||
case EditWindowClosed
|
||||
case FileCommentNotFound
|
||||
case FileDeleted
|
||||
case FileNotFound
|
||||
case FileNotShared
|
||||
case GroupContainsOthers
|
||||
case InvalidArrayArg
|
||||
case InvalidAuth
|
||||
case InvalidChannel
|
||||
case InvalidCharSet
|
||||
case InvalidClientID
|
||||
case InvalidCode
|
||||
case InvalidFormData
|
||||
case InvalidName
|
||||
case InvalidPostType
|
||||
case InvalidPresence
|
||||
case InvalidTS
|
||||
case InvalidTSLatest
|
||||
case InvalidTSOldest
|
||||
case IsArchived
|
||||
case LastMember
|
||||
case LastRAChannel
|
||||
case MessageNotFound
|
||||
case MessageTooLong
|
||||
case MigrationInProgress
|
||||
case MissingDuration
|
||||
case MissingPostType
|
||||
case NameTaken
|
||||
case NoChannel
|
||||
case NoComment
|
||||
case NoItemSpecified
|
||||
case NoReaction
|
||||
case NoText
|
||||
case NotArchived
|
||||
case NotAuthed
|
||||
case NotEnoughUsers
|
||||
case NotInChannel
|
||||
case NotInGroup
|
||||
case NotPinned
|
||||
case NotStarred
|
||||
case OverPaginationLimit
|
||||
case PaidOnly
|
||||
case PermissionDenied
|
||||
case PostingToGeneralChannelDenied
|
||||
case RateLimited
|
||||
case RequestTimeout
|
||||
case RestrictedAction
|
||||
case SnoozeEndFailed
|
||||
case SnoozeFailed
|
||||
case SnoozeNotActive
|
||||
case TooLong
|
||||
case TooManyEmoji
|
||||
case TooManyReactions
|
||||
case TooManyUsers
|
||||
case UnknownError
|
||||
case UnknownType
|
||||
case UserDisabled
|
||||
case UserDoesNotOwnChannel
|
||||
case UserIsBot
|
||||
case UserIsRestricted
|
||||
case UserIsUltraRestricted
|
||||
case UserListNotSupplied
|
||||
case UserNotFound
|
||||
case UserNotVisible
|
||||
// Client
|
||||
case ClientNetworkError
|
||||
case ClientJSONError
|
||||
// HTTP
|
||||
case TooManyRequests
|
||||
case UnknownHTTPError
|
||||
}
|
||||
|
||||
internal struct ErrorDispatcher {
|
||||
|
||||
static func dispatch(error: String) -> SlackError {
|
||||
switch error {
|
||||
case "account_inactive":
|
||||
return .AccountInactive
|
||||
case "already_in_channel":
|
||||
return .AlreadyInChannel
|
||||
case "already_pinned":
|
||||
return .AlreadyPinned
|
||||
case "already_reacted":
|
||||
return .AlreadyReacted
|
||||
case "already_starred":
|
||||
return .AlreadyStarred
|
||||
case "bad_client_secret":
|
||||
return .BadClientSecret
|
||||
case "bad_redirect_uri":
|
||||
return .BadRedirectURI
|
||||
case "bad_timestamp":
|
||||
return .BadTimeStamp
|
||||
case "cant_delete":
|
||||
return .CantDelete
|
||||
case "cant_delete_file":
|
||||
return .CantDeleteFile
|
||||
case "cant_delete_message":
|
||||
return .CantDeleteMessage
|
||||
case "cant_invite":
|
||||
return .CantInvite
|
||||
case "cant_invite_self":
|
||||
return .CantInviteSelf
|
||||
case "cant_kick_from_general":
|
||||
return .CantKickFromGeneral
|
||||
case "cant_kick_from_last_channel":
|
||||
return .CantKickFromLastChannel
|
||||
case "cant_kick_self":
|
||||
return .CantKickSelf
|
||||
case "cant_leave_general":
|
||||
return .CantLeaveGeneral
|
||||
case "cant_leave_last_channel":
|
||||
return .CantLeaveLastChannel
|
||||
case "cant_update_message":
|
||||
return .CantUpdateMessage
|
||||
case "compliance_exports_prevent_deletion":
|
||||
return .ComplianceExportsPreventDeletion
|
||||
case "channel_not_found":
|
||||
return .ChannelNotFound
|
||||
case "edit_window_closed":
|
||||
return .EditWindowClosed
|
||||
case "file_comment_not_found":
|
||||
return .FileCommentNotFound
|
||||
case "file_deleted":
|
||||
return .FileDeleted
|
||||
case "file_not_found":
|
||||
return .FileNotFound
|
||||
case "file_not_shared":
|
||||
return .FileNotShared
|
||||
case "group_contains_others":
|
||||
return .GroupContainsOthers
|
||||
case "invalid_array_arg":
|
||||
return .InvalidArrayArg
|
||||
case "invalid_auth":
|
||||
return .InvalidAuth
|
||||
case "invalid_channel":
|
||||
return .InvalidChannel
|
||||
case "invalid_charset":
|
||||
return .InvalidCharSet
|
||||
case "invalid_client_id":
|
||||
return .InvalidClientID
|
||||
case "invalid_code":
|
||||
return .InvalidCode
|
||||
case "invalid_form_data":
|
||||
return .InvalidFormData
|
||||
case "invalid_name":
|
||||
return .InvalidName
|
||||
case "invalid_post_type":
|
||||
return .InvalidPostType
|
||||
case "invalid_presence":
|
||||
return .InvalidPresence
|
||||
case "invalid_timestamp":
|
||||
return .InvalidTS
|
||||
case "invalid_ts_latest":
|
||||
return .InvalidTSLatest
|
||||
case "invalid_ts_oldest":
|
||||
return .InvalidTSOldest
|
||||
case "is_archived":
|
||||
return .IsArchived
|
||||
case "last_member":
|
||||
return .LastMember
|
||||
case "last_ra_channel":
|
||||
return .LastRAChannel
|
||||
case "message_not_found":
|
||||
return .MessageNotFound
|
||||
case "msg_too_long":
|
||||
return .MessageTooLong
|
||||
case "migration_in_progress":
|
||||
return .MigrationInProgress
|
||||
case "missing_duration":
|
||||
return .MissingDuration
|
||||
case "missing_post_type":
|
||||
return .MissingPostType
|
||||
case "name_taken":
|
||||
return .NameTaken
|
||||
case "no_channel":
|
||||
return .NoChannel
|
||||
case "no_comment":
|
||||
return .NoComment
|
||||
case "no_reaction":
|
||||
return .NoReaction
|
||||
case "no_item_specified":
|
||||
return .NoItemSpecified
|
||||
case "no_text":
|
||||
return .NoText
|
||||
case "not_archived":
|
||||
return .NotArchived
|
||||
case "not_authed":
|
||||
return .NotAuthed
|
||||
case "not_enough_users":
|
||||
return .NotEnoughUsers
|
||||
case "not_in_channel":
|
||||
return .NotInChannel
|
||||
case "not_in_group":
|
||||
return .NotInGroup
|
||||
case "not_pinned":
|
||||
return .NotPinned
|
||||
case "not_starred":
|
||||
return .NotStarred
|
||||
case "over_pagination_limit":
|
||||
return .OverPaginationLimit
|
||||
case "paid_only":
|
||||
return .PaidOnly
|
||||
case "perimssion_denied":
|
||||
return .PermissionDenied
|
||||
case "posting_to_general_channel_denied":
|
||||
return .PostingToGeneralChannelDenied
|
||||
case "rate_limited":
|
||||
return .RateLimited
|
||||
case "request_timeout":
|
||||
return .RequestTimeout
|
||||
case "snooze_end_failed":
|
||||
return .SnoozeEndFailed
|
||||
case "snooze_failed":
|
||||
return .SnoozeFailed
|
||||
case "snooze_not_active":
|
||||
return .SnoozeNotActive
|
||||
case "too_long":
|
||||
return .TooLong
|
||||
case "too_many_emoji":
|
||||
return .TooManyEmoji
|
||||
case "too_many_reactions":
|
||||
return .TooManyReactions
|
||||
case "too_many_users":
|
||||
return .TooManyUsers
|
||||
case "unknown_type":
|
||||
return .UnknownType
|
||||
case "user_disabled":
|
||||
return .UserDisabled
|
||||
case "user_does_not_own_channel":
|
||||
return .UserDoesNotOwnChannel
|
||||
case "user_is_bot":
|
||||
return .UserIsBot
|
||||
case "user_is_restricted":
|
||||
return .UserIsRestricted
|
||||
case "user_is_ultra_restricted":
|
||||
return .UserIsUltraRestricted
|
||||
case "user_list_not_supplied":
|
||||
return .UserListNotSupplied
|
||||
case "user_not_found":
|
||||
return .UserNotFound
|
||||
case "user_not_visible":
|
||||
return .UserNotVisible
|
||||
default:
|
||||
return .UnknownError
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,48 +23,25 @@
|
||||
|
||||
public struct Team {
|
||||
|
||||
public let id: String
|
||||
public let id: String?
|
||||
internal(set) public var name: String?
|
||||
internal(set) public var domain: String?
|
||||
internal(set) public var emailDomain: String?
|
||||
internal(set) public var messageEditWindowMinutes: Int?
|
||||
internal(set) public var overStorageLimit: Bool?
|
||||
internal(set) public var prefs: [String: AnyObject]?
|
||||
internal(set) public var prefs: [String: Any]?
|
||||
internal(set) public var plan: String?
|
||||
internal(set) public var icon: TeamIcon?
|
||||
|
||||
internal init(team: [String: AnyObject]?) {
|
||||
id = team?["id"] as! String
|
||||
internal init(team: [String: Any]?) {
|
||||
id = team?["id"] as? String
|
||||
name = team?["name"] as? String
|
||||
domain = team?["domain"] as? String
|
||||
emailDomain = team?["email_domain"] as? String
|
||||
messageEditWindowMinutes = team?["msg_edit_window_mins"] as? Int
|
||||
overStorageLimit = team?["over_storage_limit"] as? Bool
|
||||
prefs = team?["prefs"] as? [String: AnyObject]
|
||||
prefs = team?["prefs"] as? [String: Any]
|
||||
plan = team?["plan"] as? String
|
||||
icon = TeamIcon(icon: team?["icon"] as? [String: AnyObject])
|
||||
icon = TeamIcon(icon: team?["icon"] as? [String: Any])
|
||||
}
|
||||
}
|
||||
|
||||
public struct TeamIcon {
|
||||
internal(set) public var image34: String?
|
||||
internal(set) public var image44: String?
|
||||
internal(set) public var image68: String?
|
||||
internal(set) public var image88: String?
|
||||
internal(set) public var image102: String?
|
||||
internal(set) public var image132: String?
|
||||
internal(set) public var imageOriginal: String?
|
||||
internal(set) public var imageDefault: Bool?
|
||||
|
||||
internal init(icon: [String: AnyObject]?) {
|
||||
image34 = icon?["image_34"] as? String
|
||||
image44 = icon?["image_44"] as? String
|
||||
image68 = icon?["image_68"] as? String
|
||||
image88 = icon?["image_88"] as? String
|
||||
image102 = icon?["image_102"] as? String
|
||||
image132 = icon?["image_132"] as? String
|
||||
imageOriginal = icon?["image_original"] as? String
|
||||
imageDefault = icon?["image_default"] as? Bool
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// TeamIcon.swift
|
||||
//
|
||||
// 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.
|
||||
|
||||
public struct TeamIcon {
|
||||
|
||||
internal(set) public var image34: String?
|
||||
internal(set) public var image44: String?
|
||||
internal(set) public var image68: String?
|
||||
internal(set) public var image88: String?
|
||||
internal(set) public var image102: String?
|
||||
internal(set) public var image132: String?
|
||||
internal(set) public var imageOriginal: String?
|
||||
internal(set) public var imageDefault: Bool?
|
||||
|
||||
internal init(icon: [String: Any]?) {
|
||||
image34 = icon?["image_34"] as? String
|
||||
image44 = icon?["image_44"] as? String
|
||||
image68 = icon?["image_68"] as? String
|
||||
image88 = icon?["image_88"] as? String
|
||||
image102 = icon?["image_102"] as? String
|
||||
image132 = icon?["image_132"] as? String
|
||||
imageOriginal = icon?["image_original"] as? String
|
||||
imageDefault = icon?["image_default"] as? Bool
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
//
|
||||
// AppDelegate.swift
|
||||
// OSX-Sample
|
||||
// Topic.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
//
|
||||
@@ -22,23 +21,15 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Cocoa
|
||||
import SlackKit
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
@IBOutlet weak var window: NSWindow!
|
||||
|
||||
let leaderboard = Leaderboard(token: "SLACK_AUTH_TOKEN")
|
||||
public struct Topic {
|
||||
|
||||
func applicationDidFinishLaunching(aNotification: NSNotification) {
|
||||
leaderboard.client.connect()
|
||||
public let value: String?
|
||||
public let creator: String?
|
||||
public let lastSet: Int?
|
||||
|
||||
internal init(topic: [String: Any]?) {
|
||||
value = topic?["value"] as? String
|
||||
creator = topic?["creator"] as? String
|
||||
lastSet = topic?["last_set"] as? Int
|
||||
}
|
||||
|
||||
func applicationWillTerminate(aNotification: NSNotification) {
|
||||
// Insert code here to tear down your application
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,264 +0,0 @@
|
||||
//
|
||||
// Types.swift
|
||||
//
|
||||
// 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
|
||||
|
||||
// MARK: - Edited
|
||||
public struct Edited {
|
||||
public let user: String?
|
||||
public let ts: String?
|
||||
|
||||
internal init(edited:[String: AnyObject]?) {
|
||||
user = edited?["user"] as? String
|
||||
ts = edited?["ts"] as? String
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - History
|
||||
public struct History {
|
||||
internal(set) public var latest: NSDate?
|
||||
internal(set) public var messages = [Message]()
|
||||
public let hasMore: Bool?
|
||||
|
||||
internal init(history: [String: AnyObject]?) {
|
||||
if let latestStr = history?["latest"] as? String, latestDouble = Double(latestStr) {
|
||||
latest = NSDate(timeIntervalSince1970: NSTimeInterval(latestDouble))
|
||||
}
|
||||
if let msgs = history?["messages"] as? [[String: AnyObject]] {
|
||||
for message in msgs {
|
||||
messages.append(Message(message: message))
|
||||
}
|
||||
}
|
||||
hasMore = history?["has_more"] as? Bool
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Reaction
|
||||
public struct Reaction {
|
||||
public let name: String?
|
||||
internal(set) public var user: String?
|
||||
|
||||
internal init(reaction:[String: AnyObject]?) {
|
||||
name = reaction?["name"] as? String
|
||||
}
|
||||
|
||||
internal init(name: String, user: String) {
|
||||
self.name = name
|
||||
self.user = user
|
||||
}
|
||||
|
||||
static func reactionsFromArray(array: [[String: AnyObject]]?) -> [Reaction] {
|
||||
var reactions = [Reaction]()
|
||||
if let array = array {
|
||||
for reaction in array {
|
||||
if let users = reaction["users"] as? [String], name = reaction["name"] as? String {
|
||||
for user in users {
|
||||
reactions.append(Reaction(name: name, user: user))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reactions
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension Reaction: Equatable {}
|
||||
|
||||
public func ==(lhs: Reaction, rhs: Reaction) -> Bool {
|
||||
return lhs.name == rhs.name
|
||||
}
|
||||
|
||||
// MARK: - Comment
|
||||
public struct Comment {
|
||||
public let id: String?
|
||||
public let user: String?
|
||||
internal(set) public var created: Int?
|
||||
internal(set) public var comment: String?
|
||||
internal(set) public var starred: Bool?
|
||||
internal(set) public var stars: Int?
|
||||
internal(set) public var reactions = [Reaction]()
|
||||
|
||||
internal init(comment:[String: AnyObject]?) {
|
||||
id = comment?["id"] as? String
|
||||
created = comment?["created"] as? Int
|
||||
user = comment?["user"] as? String
|
||||
starred = comment?["is_starred"] as? Bool
|
||||
stars = comment?["num_stars"] as? Int
|
||||
self.comment = comment?["comment"] as? String
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
self.id = id
|
||||
self.user = nil
|
||||
}
|
||||
}
|
||||
|
||||
extension Comment: Equatable {}
|
||||
|
||||
public func ==(lhs: Comment, rhs: Comment) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
|
||||
// MARK: - Item
|
||||
public struct Item {
|
||||
public let type: String?
|
||||
public let ts: String?
|
||||
public let channel: String?
|
||||
public let message: Message?
|
||||
public let file: File?
|
||||
public let comment: Comment?
|
||||
public let fileCommentID: String?
|
||||
|
||||
internal init(item:[String: AnyObject]?) {
|
||||
type = item?["type"] as? String
|
||||
ts = item?["ts"] as? String
|
||||
channel = item?["channel"] as? String
|
||||
|
||||
message = Message(message: item?["message"] as? [String: AnyObject])
|
||||
|
||||
// Comment and File can come across as Strings or Dictionaries
|
||||
if let commentDictionary = item?["comment"] as? [String: AnyObject] {
|
||||
comment = Comment(comment: commentDictionary)
|
||||
} else {
|
||||
comment = Comment(id: item?["comment"] as? String)
|
||||
}
|
||||
|
||||
if let fileDictionary = item?["file"] as? [String: AnyObject] {
|
||||
file = File(file: fileDictionary)
|
||||
} else {
|
||||
file = File(id: item?["file"] as? String)
|
||||
}
|
||||
|
||||
fileCommentID = item?["file_comment"] as? String
|
||||
}
|
||||
}
|
||||
|
||||
extension Item: Equatable {}
|
||||
|
||||
public func ==(lhs: Item, rhs: Item) -> Bool {
|
||||
return lhs.type == rhs.type && lhs.channel == rhs.channel && lhs.file == rhs.file && lhs.comment == rhs.comment && lhs.message == rhs.message
|
||||
}
|
||||
|
||||
// MARK: - Topic
|
||||
public struct Topic {
|
||||
public let value: String?
|
||||
public let creator: String?
|
||||
public let lastSet: Int?
|
||||
|
||||
internal init(topic: [String: AnyObject]?) {
|
||||
value = topic?["value"] as? String
|
||||
creator = topic?["creator"] as? String
|
||||
lastSet = topic?["last_set"] as? Int
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Do Not Disturb Status
|
||||
public struct DoNotDisturbStatus {
|
||||
internal(set) public var enabled: Bool?
|
||||
internal(set) public var nextDoNotDisturbStart: Int?
|
||||
internal(set) public var nextDoNotDisturbEnd: Int?
|
||||
internal(set) public var snoozeEnabled: Bool?
|
||||
internal(set) public var snoozeEndtime: Int?
|
||||
|
||||
internal init(status: [String: AnyObject]?) {
|
||||
enabled = status?["dnd_enabled"] as? Bool
|
||||
nextDoNotDisturbStart = status?["next_dnd_start_ts"] as? Int
|
||||
nextDoNotDisturbEnd = status?["next_dnd_end_ts"] as? Int
|
||||
snoozeEnabled = status?["snooze_enabled"] as? Bool
|
||||
snoozeEndtime = status?["snooze_endtime"] as? Int
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK - Custom Team Profile
|
||||
public struct CustomProfile {
|
||||
internal(set) public var fields = [String: CustomProfileField]()
|
||||
|
||||
internal init(profile: [String: AnyObject]?) {
|
||||
if let eventFields = profile?["fields"] as? [AnyObject] {
|
||||
for field in eventFields {
|
||||
var cpf: CustomProfileField?
|
||||
if let fieldDictionary = field as? [String: AnyObject] {
|
||||
cpf = CustomProfileField(field: fieldDictionary)
|
||||
} else {
|
||||
cpf = CustomProfileField(id: field as? String)
|
||||
}
|
||||
if let id = cpf?.id { fields[id] = cpf }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal init(customFields: [String: AnyObject]?) {
|
||||
if let customFields = customFields {
|
||||
for key in customFields.keys {
|
||||
let cpf = CustomProfileField(field: customFields[key] as? [String: AnyObject])
|
||||
self.fields[key] = cpf
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct CustomProfileField {
|
||||
internal(set) public var id: String?
|
||||
internal(set) public var alt: String?
|
||||
internal(set) public var value: String?
|
||||
internal(set) public var hidden: Bool?
|
||||
internal(set) public var hint: String?
|
||||
internal(set) public var label: String?
|
||||
internal(set) public var options: String?
|
||||
internal(set) public var ordering: Int?
|
||||
internal(set) public var possibleValues: [String]?
|
||||
internal(set) public var type: String?
|
||||
|
||||
internal init(field: [String: AnyObject]?) {
|
||||
id = field?["id"] as? String
|
||||
alt = field?["alt"] as? String
|
||||
value = field?["value"] as? String
|
||||
hidden = field?["is_hidden"] as? Bool
|
||||
hint = field?["hint"] as? String
|
||||
label = field?["label"] as? String
|
||||
options = field?["options"] as? String
|
||||
ordering = field?["ordering"] as? Int
|
||||
possibleValues = field?["possible_values"] as? [String]
|
||||
type = field?["type"] as? String
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
self.id = id
|
||||
}
|
||||
|
||||
internal mutating func updateProfileField(profile: CustomProfileField?) {
|
||||
id = profile?.id != nil ? profile?.id : id
|
||||
alt = profile?.alt != nil ? profile?.alt : alt
|
||||
value = profile?.value != nil ? profile?.value : value
|
||||
hidden = profile?.hidden != nil ? profile?.hidden : hidden
|
||||
hint = profile?.hint != nil ? profile?.hint : hint
|
||||
label = profile?.label != nil ? profile?.label : label
|
||||
options = profile?.options != nil ? profile?.options : options
|
||||
ordering = profile?.ordering != nil ? profile?.ordering : ordering
|
||||
possibleValues = profile?.possibleValues != nil ? profile?.possibleValues : possibleValues
|
||||
type = profile?.type != nil ? profile?.type : type
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
public struct User {
|
||||
|
||||
public struct Profile {
|
||||
|
||||
internal(set) public var firstName: String?
|
||||
internal(set) public var lastName: String?
|
||||
internal(set) public var realName: String?
|
||||
@@ -37,7 +38,7 @@ public struct User {
|
||||
internal(set) public var image192: String?
|
||||
internal(set) public var customProfile: CustomProfile?
|
||||
|
||||
internal init(profile: [String: AnyObject]?) {
|
||||
internal init(profile: [String: Any]?) {
|
||||
firstName = profile?["first_name"] as? String
|
||||
lastName = profile?["last_name"] as? String
|
||||
realName = profile?["real_name"] as? String
|
||||
@@ -49,11 +50,10 @@ public struct User {
|
||||
image48 = profile?["image_48"] as? String
|
||||
image72 = profile?["image_72"] as? String
|
||||
image192 = profile?["image_192"] as? String
|
||||
customProfile = CustomProfile(customFields: profile?["fields"] as? [String: AnyObject])
|
||||
customProfile = CustomProfile(customFields: profile?["fields"] as? [String: Any])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public let id: String?
|
||||
internal(set) public var name: String?
|
||||
internal(set) public var deleted: Bool?
|
||||
@@ -73,15 +73,15 @@ public struct User {
|
||||
internal(set) public var timeZone: String?
|
||||
internal(set) public var timeZoneLabel: String?
|
||||
internal(set) public var timeZoneOffSet: Int?
|
||||
internal(set) public var preferences: [String: AnyObject]?
|
||||
internal(set) public var preferences: [String: Any]?
|
||||
// Client properties
|
||||
internal(set) public var userGroups: [String: String]?
|
||||
|
||||
internal init(user: [String: AnyObject]?) {
|
||||
internal init(user: [String: Any]?) {
|
||||
id = user?["id"] as? String
|
||||
name = user?["name"] as? String
|
||||
deleted = user?["deleted"] as? Bool
|
||||
profile = Profile(profile: user?["profile"] as? [String: AnyObject])
|
||||
profile = Profile(profile: user?["profile"] as? [String: Any])
|
||||
color = user?["color"] as? String
|
||||
isAdmin = user?["is_admin"] as? Bool
|
||||
isOwner = user?["is_owner"] as? Bool
|
||||
@@ -96,11 +96,11 @@ public struct User {
|
||||
timeZone = user?["tz"] as? String
|
||||
timeZoneLabel = user?["tz_label"] as? String
|
||||
timeZoneOffSet = user?["tz_offset"] as? Int
|
||||
preferences = user?["prefs"] as? [String: AnyObject]
|
||||
preferences = user?["prefs"] as? [String: Any]
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
self.id = id
|
||||
self.isBot = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,11 +21,9 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
|
||||
public struct UserGroup {
|
||||
|
||||
public let id: String?
|
||||
|
||||
internal(set) public var teamID: String?
|
||||
public let isUserGroup: Bool?
|
||||
internal(set) public var name: String?
|
||||
@@ -39,11 +37,11 @@ public struct UserGroup {
|
||||
public let createdBy: String?
|
||||
internal(set) public var updatedBy: String?
|
||||
internal(set) public var deletedBy: String?
|
||||
internal(set) public var preferences: [String: AnyObject]?
|
||||
internal(set) public var preferences: [String: Any]?
|
||||
internal(set) public var users: [String]?
|
||||
internal(set) public var userCount: Int?
|
||||
|
||||
internal init(userGroup: [String: AnyObject]?) {
|
||||
internal init(userGroup: [String: Any]?) {
|
||||
id = userGroup?["id"] as? String
|
||||
teamID = userGroup?["team_id"] as? String
|
||||
isUserGroup = userGroup?["is_usergroup"] as? Bool
|
||||
@@ -58,11 +56,10 @@ public struct UserGroup {
|
||||
createdBy = userGroup?["created_by"] as? String
|
||||
updatedBy = userGroup?["updated_by"] as? String
|
||||
deletedBy = userGroup?["deleted_by"] as? String
|
||||
preferences = userGroup?["prefs"] as? [String: AnyObject]
|
||||
preferences = userGroup?["prefs"] as? [String: Any]
|
||||
users = userGroup?["users"] as? [String]
|
||||
if let count = userGroup?["user_count"] as? String {
|
||||
userCount = Int(count)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.1.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2016 Peter Zignego. All rights reserved.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,28 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.1.1</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2016 Peter Zignego. All rights reserved.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
Reference in New Issue
Block a user