Compare commits
170 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6385afb34a | |||
| b880356dde | |||
| fdd2a5aa36 | |||
| 93f8da2f69 | |||
| a165f3e57f | |||
| d7f2221d77 | |||
| 02bda676a9 | |||
| e4bd44e939 | |||
| d83fbb1d7e | |||
| c2734a66c3 | |||
| 721f8964cf | |||
| 37ca701ae0 | |||
| c1a89eedda | |||
| 8aeb88cea3 | |||
| b776ef02a7 | |||
| 0befabb620 | |||
| 0edc193314 | |||
| 806a72efec | |||
| ea02b850f5 | |||
| ec83087712 | |||
| 798397b21c | |||
| 5677a13372 | |||
| 581f1b94bd | |||
| dbd403739b | |||
| e0af108b85 | |||
| efa95e34df | |||
| 5232879f77 | |||
| 7716a304c9 | |||
| 7ca9bfbd0b | |||
| f4afca3cab | |||
| bcd33ab9e7 | |||
| 96cb9e09e3 | |||
| 9ac93890f4 | |||
| ca232f8e8f | |||
| 9b859f0c99 | |||
| 07e5b8636f | |||
| 37b7b74914 | |||
| 78c07974bf | |||
| d44e04cd07 | |||
| d8fffe738d | |||
| 239eb94093 | |||
| c2f3731a69 | |||
| 48f80cc13d | |||
| 0396d9c6d5 | |||
| 3514b637c8 | |||
| 78ce839cc1 | |||
| 831bb20ff7 | |||
| 43dda4a2f0 | |||
| 2f0978ccc4 | |||
| 71c5eda4a1 | |||
| 4b241374ea | |||
| dd07b545c7 | |||
| af4ba6623c | |||
| 435607d170 | |||
| 8094bd2c6c | |||
| d8d22f6083 | |||
| 6fcfe2fda4 | |||
| 6ccce1875b | |||
| 433fc1a8ff | |||
| 4f64c952b8 | |||
| 139b25a7f0 | |||
| 3ee4e0fd1d | |||
| f013840cae | |||
| 79457aa13d | |||
| ac2657b7e1 | |||
| 82130f2e67 | |||
| b9573c4e8b | |||
| 6481620e7a | |||
| 35e7ead8d1 | |||
| 0f896fdaee | |||
| 8a4fceaa00 | |||
| 6007f790db | |||
| 05e7f2baa3 | |||
| 39871172e9 | |||
| 491f80741b | |||
| 0eb9ea31e1 | |||
| 8865376c3c | |||
| d86d0108ff | |||
| b45b7085ce | |||
| 91193c6b2e | |||
| 9720b1c05c | |||
| 9766a5ad6c | |||
| 1e181e7580 | |||
| f6d6c779ae | |||
| 11bb50f8d2 | |||
| d721e0ba1a | |||
| ba6066875c | |||
| 0f1a1a9de5 | |||
| a81cebf5c8 | |||
| 007ec7ab69 | |||
| b93d411f63 | |||
| 741a23809d | |||
| a92fd36c17 | |||
| e122610c04 | |||
| 0539e0bac2 | |||
| 3416161818 | |||
| 32a4aa13ea | |||
| cf188ffb6a | |||
| f1a1963ac8 | |||
| 645797b72e | |||
| b9f808f70e | |||
| 74ef3979f5 | |||
| 992879f54f | |||
| ccdf9d5d3c | |||
| 0336b5a9b6 | |||
| aefbeafd28 | |||
| bc6c07f045 | |||
| db24e66d33 | |||
| ef70f935c1 | |||
| afbf8ab6fe | |||
| d39296f496 | |||
| eafceb4645 | |||
| 83cf85a27a | |||
| 06e250a954 | |||
| 5b6622a961 | |||
| a58e291d2e | |||
| a0e1f9844e | |||
| 7d524ddeac | |||
| 94c9f7fe5a | |||
| be8a5879f3 | |||
| c657919704 | |||
| abeef21d7a | |||
| 79e3b14593 | |||
| d9a4cda9b0 | |||
| 12b316da0b | |||
| 13cade5c00 | |||
| 051e8dd6c8 | |||
| 1adea1c54e | |||
| aa51cfb2fd | |||
| 6b8885bd29 | |||
| e0fbf1ab4e | |||
| 366c6e7b77 | |||
| 378c116d9b | |||
| 58bade8ec9 | |||
| 7d7f5c40d6 | |||
| c9fd54d106 | |||
| 2f1ce799ad | |||
| 7f02f4cf99 | |||
| a9066c0d0a | |||
| 29739dba74 | |||
| d60a7094a4 | |||
| 7edd4210f6 | |||
| 2abaecbd14 | |||
| 346499e03b | |||
| bc72a52bf5 | |||
| 0ebd3cb0e7 | |||
| 5d7064ee13 | |||
| d02768ddad | |||
| dbc7b361c8 | |||
| a0de46e3c7 | |||
| 2d6e19baee | |||
| 21ec3cb2a1 | |||
| cb542da068 | |||
| 788b4e4f7a | |||
| 24b2292cba | |||
| 72866262d2 | |||
| acabbb6c03 | |||
| fff0f0befc | |||
| cf0675dac2 | |||
| 1cffa0ba74 | |||
| 9ebd8182a6 | |||
| 63a8ae7f08 | |||
| 992f94e870 | |||
| 1c476c77ad | |||
| 28bd612ca0 | |||
| 45cf2a7ac0 | |||
| f7c986c65c | |||
| ca43df4475 | |||
| ef71b6abf0 | |||
| 3ff922a2c0 |
@@ -36,3 +36,5 @@ SlackKit.xcworkspace
|
||||
# Add this line if you want to avoid checking in source code from Carthage dependencies.
|
||||
Carthage/Checkouts
|
||||
Carthage/Build
|
||||
|
||||
*.resolved
|
||||
+1
-1
@@ -1 +1 @@
|
||||
3.0
|
||||
4.2
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
disabled_rules:
|
||||
- identifier_name
|
||||
- function_parameter_count
|
||||
line_length: 140
|
||||
excluded: # paths to ignore during linting. Takes precedence over `included`.
|
||||
- Carthage
|
||||
- Pods
|
||||
@@ -1,2 +1,2 @@
|
||||
git "https://github.com/daltoniam/Starscream"
|
||||
git "https://github.com/pvzig/swifter.git"
|
||||
github "daltoniam/Starscream" == 3.0.6
|
||||
github "httpswift/swifter" == 1.4.5
|
||||
@@ -1,2 +0,0 @@
|
||||
git "https://github.com/daltoniam/Starscream" "2.0.0"
|
||||
git "https://github.com/pvzig/swifter.git" "3.0.2"
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
// swift-tools-version:4.2
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Leaderboard",
|
||||
products: [
|
||||
.executable(name: "Leaderboard", targets: ["Leaderboard"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/SlackKit/SlackKit", .upToNextMajor(from: "4.0.0"))
|
||||
],
|
||||
targets: [
|
||||
.target(name: "Leaderboard",
|
||||
dependencies: ["SlackKit"],
|
||||
path: "Sources")
|
||||
]
|
||||
)
|
||||
Executable
+191
@@ -0,0 +1,191 @@
|
||||
//
|
||||
// Leaderboard.swift
|
||||
//
|
||||
// Copyright © 2017 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
|
||||
import SlackKit
|
||||
|
||||
class Leaderbot {
|
||||
|
||||
struct Leaderboard {
|
||||
let teamID: String
|
||||
var scores = [String: Int]()
|
||||
|
||||
init(teamID: String) {
|
||||
self.teamID = teamID
|
||||
}
|
||||
}
|
||||
|
||||
enum Command: String {
|
||||
case leaderboard = "leaderboard"
|
||||
}
|
||||
|
||||
enum Trigger: String {
|
||||
case plusPlus = "++"
|
||||
case minusMinus = "--"
|
||||
}
|
||||
|
||||
let slackkit = SlackKit()
|
||||
|
||||
var leaderboards = [String: Leaderboard]()
|
||||
let atSet = CharacterSet(charactersIn: "@")
|
||||
|
||||
init(apiToken: String) {
|
||||
slackkit.addWebAPIAccessWithToken(apiToken)
|
||||
slackkit.addRTMBotWithAPIToken(apiToken)
|
||||
slackkit.notificationForEvent(.message) { [weak self] (event, client) in
|
||||
self?.listen(client?.client, message: event.message)
|
||||
}
|
||||
}
|
||||
|
||||
init(clientID: String, clientSecret: String) {
|
||||
let oauthConfig = OAuthConfig(clientID: clientID, clientSecret: clientSecret)
|
||||
slackkit.addServer(oauth: oauthConfig)
|
||||
slackkit.notificationForEvent(.message) { [weak self] (event, client) in
|
||||
self?.listen(client?.client, message: event.message)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Leaderboard Internal Logic
|
||||
private func listen(_ client: Client?, message: Message?) {
|
||||
guard let message = message, let text = message.text, let client = client else {
|
||||
return
|
||||
}
|
||||
switch text {
|
||||
case let text where text.lowercased().contains(Command.leaderboard.rawValue) && text.optionalContains(client.authenticatedUser?.id):
|
||||
handleCommand(.leaderboard, channel: message.channel, client: client)
|
||||
case let text where text.contains(Trigger.plusPlus.rawValue):
|
||||
handleMessageWithTrigger(.plusPlus, message: message, client: client)
|
||||
case let text where text.contains(Trigger.minusMinus.rawValue):
|
||||
handleMessageWithTrigger(.minusMinus, message: message, client: client)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
private func handleMessageWithTrigger(_ trigger: Trigger, message: Message, client: Client) {
|
||||
guard
|
||||
let text = message.text,
|
||||
let teamID = client.team?.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
if leaderboards[teamID] == nil { leaderboards[teamID] = Leaderboard(teamID: teamID) }
|
||||
//Nonusers
|
||||
searchTextWithExpression("([a-z0-9_\\-\\.]+)[\\+\\-]{2}", text: text, trigger: trigger, teamID: teamID)
|
||||
//Users
|
||||
searchTextWithExpression("<@([A-Z0-9_\\-\\.]+)>[\\+\\-]{2}", text: text, trigger: trigger, teamID: teamID)
|
||||
}
|
||||
|
||||
func searchTextWithExpression(_ expression: String, text: String, trigger: Trigger, teamID: String) {
|
||||
let thingRegex = try? NSRegularExpression(pattern: expression, options: [])
|
||||
let things = thingRegex?.matches(in: text, options: [], range: NSMakeRange(0, text.utf16.count)) ?? []
|
||||
for match in things {
|
||||
let value = text.substring(with: text.range(from: match.range(at: 1))!)
|
||||
if leaderboards[teamID]?.scores[value] == nil { leaderboards[teamID]?.scores[value] = 0 }
|
||||
switch trigger {
|
||||
case .plusPlus:
|
||||
leaderboards[teamID]?.scores[value]?+=1
|
||||
case .minusMinus:
|
||||
leaderboards[teamID]?.scores[value]?-=1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleCommand(_ command: Command, channel:String?, client: Client) {
|
||||
switch command {
|
||||
case .leaderboard:
|
||||
if let id = channel {
|
||||
slackkit.webAPI?.sendMessage(channel: id,
|
||||
text: "Here's the leaderboard:",
|
||||
linkNames: true,
|
||||
attachments: [constructLeaderboardAttachment(client)],
|
||||
success: nil,
|
||||
failure: { (error) in
|
||||
print("Leaderboard failed to post due to error:\(error)")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Leaderboard Interface
|
||||
private func constructLeaderboardAttachment(_ client: Client) -> Attachment? {
|
||||
guard let teamID = client.team?.id, let leaderboard = leaderboards[teamID] else {
|
||||
return nil
|
||||
}
|
||||
let top = AttachmentField(title: ":100:", value: swapIDsForNames(client, string: topItems(leaderboard)), short: true)
|
||||
let bottom = AttachmentField(title: ":poop:", value: swapIDsForNames(client, string: bottomItems(leaderboard)), short: true)
|
||||
return Attachment(fallback: "Leaderboard", title: "Leaderboard", colorHex: AttachmentColor.good.rawValue, text: "", fields: [top, bottom])
|
||||
}
|
||||
|
||||
private func topItems(_ leaderboard: Leaderboard) -> String {
|
||||
let sortedKeys = Array(leaderboard.scores.keys).sorted(by: {leaderboard.scores[$0]! > leaderboard.scores[$1]!}).filter({leaderboard.scores[$0]! > 0})
|
||||
let sortedValues = Array(leaderboard.scores.values).sorted(by: {$0 > $1}).filter({$0 > 0})
|
||||
return leaderboardString(sortedKeys, values: sortedValues)
|
||||
}
|
||||
|
||||
private func bottomItems(_ leaderboard: Leaderboard) -> String {
|
||||
let sortedKeys = Array(leaderboard.scores.keys).sorted(by: {leaderboard.scores[$0]! < leaderboard.scores[$1]!}).filter({leaderboard.scores[$0]! < 0})
|
||||
let sortedValues = Array(leaderboard.scores.values).sorted(by: {$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(_ client: Client, string: String) -> String {
|
||||
var returnString = string
|
||||
for key in client.users.keys {
|
||||
if let name = client.users[key]?.name {
|
||||
returnString = returnString.replacingOccurrences(of: key, with: "@"+name, options: NSString.CompareOptions.literal, range: returnString.startIndex..<returnString.endIndex)
|
||||
}
|
||||
}
|
||||
return returnString
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
func optionalContains(_ string: String?) -> Bool {
|
||||
guard let str = string else {
|
||||
return false
|
||||
}
|
||||
return self.contains(str)
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
func range(from nsRange: NSRange) -> Range<String.Index>? {
|
||||
guard
|
||||
let from16 = utf16.index(utf16.startIndex, offsetBy: nsRange.location, limitedBy: utf16.endIndex),
|
||||
let to16 = utf16.index(from16, offsetBy: nsRange.length, limitedBy: utf16.endIndex),
|
||||
let from = from16.samePosition(in: self),
|
||||
let to = to16.samePosition(in: self)
|
||||
else { return nil }
|
||||
return from ..< to
|
||||
}
|
||||
}
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
import Foundation
|
||||
|
||||
//With OAuth
|
||||
//let bot = Leaderbot(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET")
|
||||
|
||||
//With API token
|
||||
let bot = Leaderbot(apiToken: "xoxb-SLACK_BOT_TOKEN")
|
||||
RunLoop.main.run()
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
// swift-tools-version:4.2
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Robot or Not Bot",
|
||||
products: [
|
||||
.executable(name: "Robot or Not Bot", targets: ["Robot or Not Bot"]),
|
||||
],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/SlackKit/SlackKit", .upToNextMajor(from: "4.0.0"))
|
||||
],
|
||||
targets: [
|
||||
.target(name: "Robot or Not Bot",
|
||||
dependencies: ["SlackKit"],
|
||||
path: "Sources")
|
||||
]
|
||||
)
|
||||
Executable
+135
@@ -0,0 +1,135 @@
|
||||
import Foundation
|
||||
import SlackKit
|
||||
|
||||
class RobotOrNotBot {
|
||||
|
||||
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 bot: SlackKit
|
||||
|
||||
init(token: String) {
|
||||
bot = SlackKit()
|
||||
bot.addRTMBotWithAPIToken(token)
|
||||
bot.addWebAPIAccessWithToken(token)
|
||||
bot.notificationForEvent(.message) { [weak self] (event, connection) in
|
||||
guard
|
||||
let message = event.message,
|
||||
let id = connection?.client?.authenticatedUser?.id,
|
||||
message.text?.contains(id) == true
|
||||
else {
|
||||
return
|
||||
}
|
||||
self?.handleMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
init(clientID: String, clientSecret: String) {
|
||||
bot = SlackKit()
|
||||
let oauthConfig = OAuthConfig(clientID: clientID, clientSecret: clientSecret)
|
||||
bot.addServer(oauth: oauthConfig)
|
||||
bot.notificationForEvent(.message) { [weak self] (event, connection) in
|
||||
guard
|
||||
let message = event.message,
|
||||
let id = connection?.client?.authenticatedUser?.id,
|
||||
message.text?.contains(id) == true
|
||||
else {
|
||||
return
|
||||
}
|
||||
self?.handleMessage(message)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Bot logic
|
||||
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) {
|
||||
let reaction = verdict ? "robot_face" : "no_entry_sign"
|
||||
bot.webAPI?.addReactionToMessage(name: reaction, channel: channel, timestamp: message.ts!, success: nil, failure: nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
// Not found
|
||||
bot.webAPI?.addReactionToMessage(name: "question", channel: channel, timestamp: message.ts!, success: nil, failure: nil)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// With API token
|
||||
let slackbot = RobotOrNotBot(token: "xoxb-SLACK_API_TOKEN")
|
||||
// With OAuth
|
||||
// let slackbot = RobotOrNotBot(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET")
|
||||
RunLoop.main.run()
|
||||
@@ -0,0 +1,204 @@
|
||||
// Generated by Apple Swift version 4.2.1 effective-4.1.50 (swiftlang-1000.11.42 clang-1000.11.45.1)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgcc-compat"
|
||||
|
||||
#if !defined(__has_include)
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
#if !defined(__has_attribute)
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
#if !defined(__has_feature)
|
||||
# define __has_feature(x) 0
|
||||
#endif
|
||||
#if !defined(__has_warning)
|
||||
# define __has_warning(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<swift/objc-prologue.h>)
|
||||
# include <swift/objc-prologue.h>
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wauto-import"
|
||||
#include <objc/NSObject.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if !defined(SWIFT_TYPEDEFS)
|
||||
# define SWIFT_TYPEDEFS 1
|
||||
# if __has_include(<uchar.h>)
|
||||
# include <uchar.h>
|
||||
# elif !defined(__cplusplus)
|
||||
typedef uint_least16_t char16_t;
|
||||
typedef uint_least32_t char32_t;
|
||||
# endif
|
||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PASTE)
|
||||
# define SWIFT_PASTE_HELPER(x, y) x##y
|
||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
|
||||
#endif
|
||||
#if !defined(SWIFT_METATYPE)
|
||||
# define SWIFT_METATYPE(X) Class
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_PROPERTY)
|
||||
# if __has_feature(objc_class_property)
|
||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
|
||||
# else
|
||||
# define SWIFT_CLASS_PROPERTY(...)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __has_attribute(objc_runtime_name)
|
||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
|
||||
#else
|
||||
# define SWIFT_RUNTIME_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(swift_name)
|
||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
|
||||
#else
|
||||
# define SWIFT_COMPILE_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(objc_method_family)
|
||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
|
||||
#else
|
||||
# define SWIFT_METHOD_FAMILY(X)
|
||||
#endif
|
||||
#if __has_attribute(noescape)
|
||||
# define SWIFT_NOESCAPE __attribute__((noescape))
|
||||
#else
|
||||
# define SWIFT_NOESCAPE
|
||||
#endif
|
||||
#if __has_attribute(warn_unused_result)
|
||||
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
# define SWIFT_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
#if __has_attribute(noreturn)
|
||||
# define SWIFT_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
# define SWIFT_NORETURN
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_EXTRA)
|
||||
# define SWIFT_CLASS_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_PROTOCOL_EXTRA)
|
||||
# define SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_EXTRA)
|
||||
# define SWIFT_ENUM_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS)
|
||||
# if __has_attribute(objc_subclassing_restricted)
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# else
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PROTOCOL)
|
||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_EXTENSION)
|
||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
|
||||
#endif
|
||||
|
||||
#if !defined(OBJC_DESIGNATED_INITIALIZER)
|
||||
# if __has_attribute(objc_designated_initializer)
|
||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
||||
# else
|
||||
# define OBJC_DESIGNATED_INITIALIZER
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_ATTR)
|
||||
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
|
||||
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
|
||||
# else
|
||||
# define SWIFT_ENUM_ATTR(_extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM)
|
||||
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# if __has_feature(generalized_swift_name)
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# else
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
|
||||
#endif
|
||||
#if !defined(SWIFT_AVAILABILITY)
|
||||
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
# define SWIFT_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
|
||||
#endif
|
||||
#if __has_feature(attribute_diagnose_if_objc)
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
|
||||
#else
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
|
||||
#endif
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
@import ObjectiveC;
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
|
||||
#if __has_warning("-Wpragma-clang-attribute")
|
||||
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
|
||||
#endif
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma push_macro("any")
|
||||
# undef any
|
||||
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="Starscream",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
|
||||
# pragma pop_macro("any")
|
||||
#endif
|
||||
|
||||
@class NSStream;
|
||||
|
||||
SWIFT_CLASS("_TtC10Starscream16FoundationStream")
|
||||
@interface FoundationStream : NSObject <NSStreamDelegate>
|
||||
/// Delegate for the stream methods. Processes incoming bytes
|
||||
- (void)stream:(NSStream * _Nonnull)aStream handleEvent:(NSStreamEvent)eventCode;
|
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
|
||||
SWIFT_CLASS("_TtC10Starscream9WebSocket")
|
||||
@interface WebSocket : NSObject <NSStreamDelegate>
|
||||
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
|
||||
+ (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable");
|
||||
@end
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Starscream.h
|
||||
// Starscream
|
||||
//
|
||||
// Created by Austin Cherry on 9/25/14.
|
||||
// Copyright (c) 2014 Vluxe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for Starscream.
|
||||
FOUNDATION_EXPORT double StarscreamVersionNumber;
|
||||
|
||||
//! Project version string for Starscream.
|
||||
FOUNDATION_EXPORT const unsigned char StarscreamVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <Starscream/PublicHeader.h>
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
framework module Starscream {
|
||||
umbrella header "Starscream.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
|
||||
module Starscream.Swift {
|
||||
header "Starscream-Swift.h"
|
||||
requires objc
|
||||
}
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,191 @@
|
||||
// Generated by Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgcc-compat"
|
||||
|
||||
#if !defined(__has_include)
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
#if !defined(__has_attribute)
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
#if !defined(__has_feature)
|
||||
# define __has_feature(x) 0
|
||||
#endif
|
||||
#if !defined(__has_warning)
|
||||
# define __has_warning(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<swift/objc-prologue.h>)
|
||||
# include <swift/objc-prologue.h>
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wauto-import"
|
||||
#include <objc/NSObject.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if !defined(SWIFT_TYPEDEFS)
|
||||
# define SWIFT_TYPEDEFS 1
|
||||
# if __has_include(<uchar.h>)
|
||||
# include <uchar.h>
|
||||
# elif !defined(__cplusplus)
|
||||
typedef uint_least16_t char16_t;
|
||||
typedef uint_least32_t char32_t;
|
||||
# endif
|
||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PASTE)
|
||||
# define SWIFT_PASTE_HELPER(x, y) x##y
|
||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
|
||||
#endif
|
||||
#if !defined(SWIFT_METATYPE)
|
||||
# define SWIFT_METATYPE(X) Class
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_PROPERTY)
|
||||
# if __has_feature(objc_class_property)
|
||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
|
||||
# else
|
||||
# define SWIFT_CLASS_PROPERTY(...)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __has_attribute(objc_runtime_name)
|
||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
|
||||
#else
|
||||
# define SWIFT_RUNTIME_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(swift_name)
|
||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
|
||||
#else
|
||||
# define SWIFT_COMPILE_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(objc_method_family)
|
||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
|
||||
#else
|
||||
# define SWIFT_METHOD_FAMILY(X)
|
||||
#endif
|
||||
#if __has_attribute(noescape)
|
||||
# define SWIFT_NOESCAPE __attribute__((noescape))
|
||||
#else
|
||||
# define SWIFT_NOESCAPE
|
||||
#endif
|
||||
#if __has_attribute(warn_unused_result)
|
||||
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
# define SWIFT_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
#if __has_attribute(noreturn)
|
||||
# define SWIFT_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
# define SWIFT_NORETURN
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_EXTRA)
|
||||
# define SWIFT_CLASS_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_PROTOCOL_EXTRA)
|
||||
# define SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_EXTRA)
|
||||
# define SWIFT_ENUM_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS)
|
||||
# if __has_attribute(objc_subclassing_restricted)
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# else
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PROTOCOL)
|
||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_EXTENSION)
|
||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
|
||||
#endif
|
||||
|
||||
#if !defined(OBJC_DESIGNATED_INITIALIZER)
|
||||
# if __has_attribute(objc_designated_initializer)
|
||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
||||
# else
|
||||
# define OBJC_DESIGNATED_INITIALIZER
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_ATTR)
|
||||
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
|
||||
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
|
||||
# else
|
||||
# define SWIFT_ENUM_ATTR(_extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM)
|
||||
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# if __has_feature(generalized_swift_name)
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# else
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
|
||||
#endif
|
||||
#if !defined(SWIFT_AVAILABILITY)
|
||||
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
# define SWIFT_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
|
||||
#endif
|
||||
#if __has_feature(attribute_diagnose_if_objc)
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
|
||||
#else
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
|
||||
#endif
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
|
||||
#if __has_warning("-Wpragma-clang-attribute")
|
||||
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
|
||||
#endif
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma push_macro("any")
|
||||
# undef any
|
||||
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="Swifter",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
|
||||
# pragma pop_macro("any")
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SwifteriOS.h
|
||||
// SwifteriOS
|
||||
//
|
||||
// Created by Romain Pouclet on 2015-11-24.
|
||||
// Copyright © 2015 Damian Kołakowski. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for SwifteriOS.
|
||||
FOUNDATION_EXPORT double SwifteriOSVersionNumber;
|
||||
|
||||
//! Project version string for SwifteriOS.
|
||||
FOUNDATION_EXPORT const unsigned char SwifteriOSVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <SwifteriOS/PublicHeader.h>
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
framework module Swifter {
|
||||
header "Swifter-Swift.h"
|
||||
requires objc
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Modules
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Resources
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Starscream
|
||||
@@ -0,0 +1,204 @@
|
||||
// Generated by Apple Swift version 4.2.1 effective-4.1.50 (swiftlang-1000.11.42 clang-1000.11.45.1)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgcc-compat"
|
||||
|
||||
#if !defined(__has_include)
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
#if !defined(__has_attribute)
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
#if !defined(__has_feature)
|
||||
# define __has_feature(x) 0
|
||||
#endif
|
||||
#if !defined(__has_warning)
|
||||
# define __has_warning(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<swift/objc-prologue.h>)
|
||||
# include <swift/objc-prologue.h>
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wauto-import"
|
||||
#include <objc/NSObject.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if !defined(SWIFT_TYPEDEFS)
|
||||
# define SWIFT_TYPEDEFS 1
|
||||
# if __has_include(<uchar.h>)
|
||||
# include <uchar.h>
|
||||
# elif !defined(__cplusplus)
|
||||
typedef uint_least16_t char16_t;
|
||||
typedef uint_least32_t char32_t;
|
||||
# endif
|
||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PASTE)
|
||||
# define SWIFT_PASTE_HELPER(x, y) x##y
|
||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
|
||||
#endif
|
||||
#if !defined(SWIFT_METATYPE)
|
||||
# define SWIFT_METATYPE(X) Class
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_PROPERTY)
|
||||
# if __has_feature(objc_class_property)
|
||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
|
||||
# else
|
||||
# define SWIFT_CLASS_PROPERTY(...)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __has_attribute(objc_runtime_name)
|
||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
|
||||
#else
|
||||
# define SWIFT_RUNTIME_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(swift_name)
|
||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
|
||||
#else
|
||||
# define SWIFT_COMPILE_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(objc_method_family)
|
||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
|
||||
#else
|
||||
# define SWIFT_METHOD_FAMILY(X)
|
||||
#endif
|
||||
#if __has_attribute(noescape)
|
||||
# define SWIFT_NOESCAPE __attribute__((noescape))
|
||||
#else
|
||||
# define SWIFT_NOESCAPE
|
||||
#endif
|
||||
#if __has_attribute(warn_unused_result)
|
||||
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
# define SWIFT_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
#if __has_attribute(noreturn)
|
||||
# define SWIFT_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
# define SWIFT_NORETURN
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_EXTRA)
|
||||
# define SWIFT_CLASS_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_PROTOCOL_EXTRA)
|
||||
# define SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_EXTRA)
|
||||
# define SWIFT_ENUM_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS)
|
||||
# if __has_attribute(objc_subclassing_restricted)
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# else
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PROTOCOL)
|
||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_EXTENSION)
|
||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
|
||||
#endif
|
||||
|
||||
#if !defined(OBJC_DESIGNATED_INITIALIZER)
|
||||
# if __has_attribute(objc_designated_initializer)
|
||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
||||
# else
|
||||
# define OBJC_DESIGNATED_INITIALIZER
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_ATTR)
|
||||
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
|
||||
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
|
||||
# else
|
||||
# define SWIFT_ENUM_ATTR(_extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM)
|
||||
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# if __has_feature(generalized_swift_name)
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# else
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
|
||||
#endif
|
||||
#if !defined(SWIFT_AVAILABILITY)
|
||||
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
# define SWIFT_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
|
||||
#endif
|
||||
#if __has_feature(attribute_diagnose_if_objc)
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
|
||||
#else
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
|
||||
#endif
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
@import ObjectiveC;
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
|
||||
#if __has_warning("-Wpragma-clang-attribute")
|
||||
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
|
||||
#endif
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma push_macro("any")
|
||||
# undef any
|
||||
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="Starscream",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
|
||||
# pragma pop_macro("any")
|
||||
#endif
|
||||
|
||||
@class NSStream;
|
||||
|
||||
SWIFT_CLASS("_TtC10Starscream16FoundationStream")
|
||||
@interface FoundationStream : NSObject <NSStreamDelegate>
|
||||
/// Delegate for the stream methods. Processes incoming bytes
|
||||
- (void)stream:(NSStream * _Nonnull)aStream handleEvent:(NSStreamEvent)eventCode;
|
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
|
||||
SWIFT_CLASS("_TtC10Starscream9WebSocket")
|
||||
@interface WebSocket : NSObject <NSStreamDelegate>
|
||||
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
|
||||
+ (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable");
|
||||
@end
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Starscream.h
|
||||
// Starscream
|
||||
//
|
||||
// Created by Austin Cherry on 9/25/14.
|
||||
// Copyright (c) 2014 Vluxe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for Starscream.
|
||||
FOUNDATION_EXPORT double StarscreamVersionNumber;
|
||||
|
||||
//! Project version string for Starscream.
|
||||
FOUNDATION_EXPORT const unsigned char StarscreamVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <Starscream/PublicHeader.h>
|
||||
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
framework module Starscream {
|
||||
umbrella header "Starscream.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
|
||||
module Starscream.Swift {
|
||||
header "Starscream-Swift.h"
|
||||
requires objc
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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>BuildMachineOSBuild</key>
|
||||
<string>18C54</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Starscream</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.vluxe.Starscream</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Starscream</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>3.0.5</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>10B61</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>18B71</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.14</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1010</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>10B61</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
<integer>3</integer>
|
||||
<integer>4</integer>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
A
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Headers
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Modules
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Resources
|
||||
@@ -0,0 +1 @@
|
||||
Versions/Current/Swifter
|
||||
@@ -0,0 +1,191 @@
|
||||
// Generated by Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgcc-compat"
|
||||
|
||||
#if !defined(__has_include)
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
#if !defined(__has_attribute)
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
#if !defined(__has_feature)
|
||||
# define __has_feature(x) 0
|
||||
#endif
|
||||
#if !defined(__has_warning)
|
||||
# define __has_warning(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<swift/objc-prologue.h>)
|
||||
# include <swift/objc-prologue.h>
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wauto-import"
|
||||
#include <objc/NSObject.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if !defined(SWIFT_TYPEDEFS)
|
||||
# define SWIFT_TYPEDEFS 1
|
||||
# if __has_include(<uchar.h>)
|
||||
# include <uchar.h>
|
||||
# elif !defined(__cplusplus)
|
||||
typedef uint_least16_t char16_t;
|
||||
typedef uint_least32_t char32_t;
|
||||
# endif
|
||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PASTE)
|
||||
# define SWIFT_PASTE_HELPER(x, y) x##y
|
||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
|
||||
#endif
|
||||
#if !defined(SWIFT_METATYPE)
|
||||
# define SWIFT_METATYPE(X) Class
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_PROPERTY)
|
||||
# if __has_feature(objc_class_property)
|
||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
|
||||
# else
|
||||
# define SWIFT_CLASS_PROPERTY(...)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __has_attribute(objc_runtime_name)
|
||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
|
||||
#else
|
||||
# define SWIFT_RUNTIME_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(swift_name)
|
||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
|
||||
#else
|
||||
# define SWIFT_COMPILE_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(objc_method_family)
|
||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
|
||||
#else
|
||||
# define SWIFT_METHOD_FAMILY(X)
|
||||
#endif
|
||||
#if __has_attribute(noescape)
|
||||
# define SWIFT_NOESCAPE __attribute__((noescape))
|
||||
#else
|
||||
# define SWIFT_NOESCAPE
|
||||
#endif
|
||||
#if __has_attribute(warn_unused_result)
|
||||
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
# define SWIFT_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
#if __has_attribute(noreturn)
|
||||
# define SWIFT_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
# define SWIFT_NORETURN
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_EXTRA)
|
||||
# define SWIFT_CLASS_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_PROTOCOL_EXTRA)
|
||||
# define SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_EXTRA)
|
||||
# define SWIFT_ENUM_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS)
|
||||
# if __has_attribute(objc_subclassing_restricted)
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# else
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PROTOCOL)
|
||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_EXTENSION)
|
||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
|
||||
#endif
|
||||
|
||||
#if !defined(OBJC_DESIGNATED_INITIALIZER)
|
||||
# if __has_attribute(objc_designated_initializer)
|
||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
||||
# else
|
||||
# define OBJC_DESIGNATED_INITIALIZER
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_ATTR)
|
||||
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
|
||||
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
|
||||
# else
|
||||
# define SWIFT_ENUM_ATTR(_extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM)
|
||||
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# if __has_feature(generalized_swift_name)
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# else
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
|
||||
#endif
|
||||
#if !defined(SWIFT_AVAILABILITY)
|
||||
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
# define SWIFT_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
|
||||
#endif
|
||||
#if __has_feature(attribute_diagnose_if_objc)
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
|
||||
#else
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
|
||||
#endif
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
|
||||
#if __has_warning("-Wpragma-clang-attribute")
|
||||
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
|
||||
#endif
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma push_macro("any")
|
||||
# undef any
|
||||
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="Swifter",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
|
||||
# pragma pop_macro("any")
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SwifterMac.h
|
||||
// SwifterMac
|
||||
//
|
||||
// Created by Romain Pouclet on 2015-11-24.
|
||||
// Copyright © 2015 Damian Kołakowski. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
//! Project version number for SwifterMac.
|
||||
FOUNDATION_EXPORT double SwifterMacVersionNumber;
|
||||
|
||||
//! Project version string for SwifterMac.
|
||||
FOUNDATION_EXPORT const unsigned char SwifterMacVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <SwifterMac/PublicHeader.h>
|
||||
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
framework module Swifter {
|
||||
header "Swifter-Swift.h"
|
||||
requires objc
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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>BuildMachineOSBuild</key>
|
||||
<string>18C54</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Swifter</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>pl.kolakowski.SwifterMac</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>Swifter</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.4.5</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleSupportedPlatforms</key>
|
||||
<array>
|
||||
<string>MacOSX</string>
|
||||
</array>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.4.3</string>
|
||||
<key>DTCompiler</key>
|
||||
<string>com.apple.compilers.llvm.clang.1_0</string>
|
||||
<key>DTPlatformBuild</key>
|
||||
<string>10B61</string>
|
||||
<key>DTPlatformVersion</key>
|
||||
<string>GM</string>
|
||||
<key>DTSDKBuild</key>
|
||||
<string>18B71</string>
|
||||
<key>DTSDKName</key>
|
||||
<string>macosx10.14</string>
|
||||
<key>DTXcode</key>
|
||||
<string>1010</string>
|
||||
<key>DTXcodeBuild</key>
|
||||
<string>10B61</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright © 2015 Damian Kołakowski. All rights reserved.</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
Binary file not shown.
@@ -0,0 +1 @@
|
||||
A
|
||||
@@ -0,0 +1,204 @@
|
||||
// Generated by Apple Swift version 4.2.1 effective-4.1.50 (swiftlang-1000.11.42 clang-1000.11.45.1)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgcc-compat"
|
||||
|
||||
#if !defined(__has_include)
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
#if !defined(__has_attribute)
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
#if !defined(__has_feature)
|
||||
# define __has_feature(x) 0
|
||||
#endif
|
||||
#if !defined(__has_warning)
|
||||
# define __has_warning(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<swift/objc-prologue.h>)
|
||||
# include <swift/objc-prologue.h>
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wauto-import"
|
||||
#include <objc/NSObject.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if !defined(SWIFT_TYPEDEFS)
|
||||
# define SWIFT_TYPEDEFS 1
|
||||
# if __has_include(<uchar.h>)
|
||||
# include <uchar.h>
|
||||
# elif !defined(__cplusplus)
|
||||
typedef uint_least16_t char16_t;
|
||||
typedef uint_least32_t char32_t;
|
||||
# endif
|
||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PASTE)
|
||||
# define SWIFT_PASTE_HELPER(x, y) x##y
|
||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
|
||||
#endif
|
||||
#if !defined(SWIFT_METATYPE)
|
||||
# define SWIFT_METATYPE(X) Class
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_PROPERTY)
|
||||
# if __has_feature(objc_class_property)
|
||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
|
||||
# else
|
||||
# define SWIFT_CLASS_PROPERTY(...)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __has_attribute(objc_runtime_name)
|
||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
|
||||
#else
|
||||
# define SWIFT_RUNTIME_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(swift_name)
|
||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
|
||||
#else
|
||||
# define SWIFT_COMPILE_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(objc_method_family)
|
||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
|
||||
#else
|
||||
# define SWIFT_METHOD_FAMILY(X)
|
||||
#endif
|
||||
#if __has_attribute(noescape)
|
||||
# define SWIFT_NOESCAPE __attribute__((noescape))
|
||||
#else
|
||||
# define SWIFT_NOESCAPE
|
||||
#endif
|
||||
#if __has_attribute(warn_unused_result)
|
||||
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
# define SWIFT_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
#if __has_attribute(noreturn)
|
||||
# define SWIFT_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
# define SWIFT_NORETURN
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_EXTRA)
|
||||
# define SWIFT_CLASS_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_PROTOCOL_EXTRA)
|
||||
# define SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_EXTRA)
|
||||
# define SWIFT_ENUM_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS)
|
||||
# if __has_attribute(objc_subclassing_restricted)
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# else
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PROTOCOL)
|
||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_EXTENSION)
|
||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
|
||||
#endif
|
||||
|
||||
#if !defined(OBJC_DESIGNATED_INITIALIZER)
|
||||
# if __has_attribute(objc_designated_initializer)
|
||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
||||
# else
|
||||
# define OBJC_DESIGNATED_INITIALIZER
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_ATTR)
|
||||
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
|
||||
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
|
||||
# else
|
||||
# define SWIFT_ENUM_ATTR(_extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM)
|
||||
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# if __has_feature(generalized_swift_name)
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# else
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
|
||||
#endif
|
||||
#if !defined(SWIFT_AVAILABILITY)
|
||||
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
# define SWIFT_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
|
||||
#endif
|
||||
#if __has_feature(attribute_diagnose_if_objc)
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
|
||||
#else
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
|
||||
#endif
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
@import ObjectiveC;
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
|
||||
#if __has_warning("-Wpragma-clang-attribute")
|
||||
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
|
||||
#endif
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma push_macro("any")
|
||||
# undef any
|
||||
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="Starscream",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
|
||||
# pragma pop_macro("any")
|
||||
#endif
|
||||
|
||||
@class NSStream;
|
||||
|
||||
SWIFT_CLASS("_TtC10Starscream16FoundationStream")
|
||||
@interface FoundationStream : NSObject <NSStreamDelegate>
|
||||
/// Delegate for the stream methods. Processes incoming bytes
|
||||
- (void)stream:(NSStream * _Nonnull)aStream handleEvent:(NSStreamEvent)eventCode;
|
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
|
||||
SWIFT_CLASS("_TtC10Starscream9WebSocket")
|
||||
@interface WebSocket : NSObject <NSStreamDelegate>
|
||||
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
|
||||
+ (nonnull instancetype)new SWIFT_DEPRECATED_MSG("-init is unavailable");
|
||||
@end
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// Starscream.h
|
||||
// Starscream
|
||||
//
|
||||
// Created by Austin Cherry on 9/25/14.
|
||||
// Copyright (c) 2014 Vluxe. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for Starscream.
|
||||
FOUNDATION_EXPORT double StarscreamVersionNumber;
|
||||
|
||||
//! Project version string for Starscream.
|
||||
FOUNDATION_EXPORT const unsigned char StarscreamVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <Starscream/PublicHeader.h>
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
framework module Starscream {
|
||||
umbrella header "Starscream.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
|
||||
module Starscream.Swift {
|
||||
header "Starscream-Swift.h"
|
||||
requires objc
|
||||
}
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,191 @@
|
||||
// Generated by Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgcc-compat"
|
||||
|
||||
#if !defined(__has_include)
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
#if !defined(__has_attribute)
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
#if !defined(__has_feature)
|
||||
# define __has_feature(x) 0
|
||||
#endif
|
||||
#if !defined(__has_warning)
|
||||
# define __has_warning(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<swift/objc-prologue.h>)
|
||||
# include <swift/objc-prologue.h>
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wauto-import"
|
||||
#include <objc/NSObject.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#if !defined(SWIFT_TYPEDEFS)
|
||||
# define SWIFT_TYPEDEFS 1
|
||||
# if __has_include(<uchar.h>)
|
||||
# include <uchar.h>
|
||||
# elif !defined(__cplusplus)
|
||||
typedef uint_least16_t char16_t;
|
||||
typedef uint_least32_t char32_t;
|
||||
# endif
|
||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PASTE)
|
||||
# define SWIFT_PASTE_HELPER(x, y) x##y
|
||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
|
||||
#endif
|
||||
#if !defined(SWIFT_METATYPE)
|
||||
# define SWIFT_METATYPE(X) Class
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_PROPERTY)
|
||||
# if __has_feature(objc_class_property)
|
||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
|
||||
# else
|
||||
# define SWIFT_CLASS_PROPERTY(...)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if __has_attribute(objc_runtime_name)
|
||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
|
||||
#else
|
||||
# define SWIFT_RUNTIME_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(swift_name)
|
||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
|
||||
#else
|
||||
# define SWIFT_COMPILE_NAME(X)
|
||||
#endif
|
||||
#if __has_attribute(objc_method_family)
|
||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
|
||||
#else
|
||||
# define SWIFT_METHOD_FAMILY(X)
|
||||
#endif
|
||||
#if __has_attribute(noescape)
|
||||
# define SWIFT_NOESCAPE __attribute__((noescape))
|
||||
#else
|
||||
# define SWIFT_NOESCAPE
|
||||
#endif
|
||||
#if __has_attribute(warn_unused_result)
|
||||
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
# define SWIFT_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
#if __has_attribute(noreturn)
|
||||
# define SWIFT_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
# define SWIFT_NORETURN
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_EXTRA)
|
||||
# define SWIFT_CLASS_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_PROTOCOL_EXTRA)
|
||||
# define SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_EXTRA)
|
||||
# define SWIFT_ENUM_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS)
|
||||
# if __has_attribute(objc_subclassing_restricted)
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# else
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PROTOCOL)
|
||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_EXTENSION)
|
||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
|
||||
#endif
|
||||
|
||||
#if !defined(OBJC_DESIGNATED_INITIALIZER)
|
||||
# if __has_attribute(objc_designated_initializer)
|
||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
||||
# else
|
||||
# define OBJC_DESIGNATED_INITIALIZER
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_ATTR)
|
||||
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
|
||||
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
|
||||
# else
|
||||
# define SWIFT_ENUM_ATTR(_extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM)
|
||||
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# if __has_feature(generalized_swift_name)
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# else
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
|
||||
#endif
|
||||
#if !defined(SWIFT_AVAILABILITY)
|
||||
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
# define SWIFT_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
|
||||
#endif
|
||||
#if __has_feature(attribute_diagnose_if_objc)
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
|
||||
#else
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
|
||||
#endif
|
||||
#if __has_feature(modules)
|
||||
@import Foundation;
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
|
||||
#if __has_warning("-Wpragma-clang-attribute")
|
||||
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
|
||||
#endif
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma push_macro("any")
|
||||
# undef any
|
||||
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="Swifter",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
|
||||
# pragma pop_macro("any")
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SwiftertvOS.h
|
||||
// SwiftertvOS
|
||||
//
|
||||
// Created by Romain Pouclet on 2015-11-24.
|
||||
// Copyright © 2015 Damian Kołakowski. All rights reserved.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for SwiftertvOS.
|
||||
FOUNDATION_EXPORT double SwiftertvOSVersionNumber;
|
||||
|
||||
//! Project version string for SwifteriOS.
|
||||
FOUNDATION_EXPORT const unsigned char SwiftertvOSVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <SwifteriOS/PublicHeader.h>
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
framework module Swifter {
|
||||
header "Swifter-Swift.h"
|
||||
requires objc
|
||||
}
|
||||
Executable
BIN
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 Peter Zignego
|
||||
Copyright (c) 2017 Peter Zignego
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
+77
-5
@@ -1,11 +1,83 @@
|
||||
// swift-tools-version:4.2
|
||||
|
||||
import PackageDescription
|
||||
|
||||
// MARK: Targets
|
||||
|
||||
let SlackKit: Target = .target(name: "SlackKit",
|
||||
dependencies: ["SKCore", "SKClient", "SKRTMAPI", "SKServer"],
|
||||
path: "SlackKit/Sources")
|
||||
|
||||
let SKClient: Target = .target(name: "SKClient",
|
||||
dependencies: ["SKCore"],
|
||||
path: "SKClient/Sources")
|
||||
|
||||
let SKCore: Target = .target(name: "SKCore",
|
||||
path: "SKCore/Sources")
|
||||
|
||||
let SKRTMAPI: Target = .target(name: "SKRTMAPI",
|
||||
path: "SKRTMAPI/Sources")
|
||||
|
||||
#if os(macOS)
|
||||
SKRTMAPI.dependencies = [
|
||||
"SKCore",
|
||||
"SKWebAPI",
|
||||
"Starscream",
|
||||
"WebSocket"
|
||||
]
|
||||
#elseif os(Linux)
|
||||
SKRTMAPI.dependencies = [
|
||||
"SKCore",
|
||||
"SKWebAPI",
|
||||
"WebSocket"
|
||||
]
|
||||
#elseif os(iOS) || os(tvOS)
|
||||
SKRTMAPI.dependencies = [
|
||||
"SKCore",
|
||||
"SKWebAPI",
|
||||
"Starscream",
|
||||
]
|
||||
#endif
|
||||
|
||||
let SKServer: Target = .target(name: "SKServer",
|
||||
dependencies: ["SKCore", "SKWebAPI", "Swifter"],
|
||||
path: "SKServer/Sources")
|
||||
|
||||
let SKWebAPI: Target = .target(name: "SKWebAPI",
|
||||
dependencies: ["SKCore"],
|
||||
path: "SKWebAPI/Sources")
|
||||
|
||||
// MARK: Package
|
||||
|
||||
let package = Package(
|
||||
name: "SlackKit",
|
||||
targets: [],
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/swifter.git",
|
||||
majorVersion: 3, minor: 0),
|
||||
.Package(url: "https://github.com/daltoniam/Starscream", majorVersion: 2, minor: 0)
|
||||
products: [
|
||||
.library(name: "SlackKit", targets: ["SlackKit"]),
|
||||
.library(name: "SKClient", targets: ["SKClient"]),
|
||||
.library(name: "SKCore", targets: ["SKCore"]),
|
||||
.library(name: "SKRMTAPI", targets: ["SKRTMAPI"]),
|
||||
.library(name: "SKServer", targets: ["SKServer"]),
|
||||
.library(name: "SKWebAPI", targets: ["SKWebAPI"])
|
||||
],
|
||||
targets: [
|
||||
SlackKit, SKClient, SKCore, SKRTMAPI, SKServer, SKWebAPI
|
||||
]
|
||||
)
|
||||
|
||||
#if os(macOS)
|
||||
package.dependencies = [
|
||||
.package(url: "https://github.com/httpswift/swifter.git", .upToNextMinor(from: "1.4.5")),
|
||||
.package(url: "https://github.com/vapor/websocket", .upToNextMinor(from: "1.1.1")),
|
||||
.package(url: "https://github.com/daltoniam/Starscream", .upToNextMinor(from: "3.0.6"))
|
||||
]
|
||||
#elseif os(Linux)
|
||||
package.dependencies = [
|
||||
.package(url: "https://github.com/httpswift/swifter.git", .upToNextMinor(from: "1.4.5")),
|
||||
.package(url: "https://github.com/vapor/websocket", .upToNextMinor(from: "1.1.1"))
|
||||
]
|
||||
#elseif os(iOS) || os(tvOS)
|
||||
package.dependencies = [
|
||||
.package(url: "https://github.com/httpswift/swifter.git", .upToNextMinor(from: "1.4.5")),
|
||||
.package(url: "https://github.com/daltoniam/Starscream", .upToNextMinor(from: "3.0.6"))
|
||||
]
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
use_frameworks!
|
||||
|
||||
target 'SlackKit macOS' do
|
||||
platform :osx, '10.11'
|
||||
pod 'SKCore', '~> 4.1.0'
|
||||
pod 'SKClient', '~> 4.1.0'
|
||||
pod 'SKWebAPI', '~> 4.1.0'
|
||||
pod 'SKRTMAPI', '~> 4.1.0'
|
||||
pod 'SKServer', '~> 4.1.0'
|
||||
end
|
||||
|
||||
target 'SlackKit iOS' do
|
||||
platform :ios, '9.0'
|
||||
pod 'SKCore', '~> 4.1.0'
|
||||
pod 'SKClient', '~> 4.1.0'
|
||||
pod 'SKWebAPI', '~> 4.1.0'
|
||||
pod 'SKRTMAPI', '~> 4.1.0'
|
||||
pod 'SKServer', '~> 4.1.0'
|
||||
end
|
||||
|
||||
target 'SlackKit tvOS' do
|
||||
platform :tvos, '9.0'
|
||||
pod 'SKCore', '~> 4.1.0'
|
||||
pod 'SKClient', '~> 4.1.0'
|
||||
pod 'SKWebAPI', '~> 4.1.0'
|
||||
pod 'SKRTMAPI', '~> 4.1.0'
|
||||
pod 'SKServer', '~> 4.1.0'
|
||||
end
|
||||
@@ -1,309 +1,207 @@
|
||||

|
||||
<p align="center"><img src="https://cloud.githubusercontent.com/assets/8311605/24083714/e921a0d4-0cb2-11e7-8384-d42113ef5056.png" alt="SlackKit" width="500"/></p>
|
||||
|
||||
   [](https://github.com/apple/swift-package-manager) [](https://github.com/Carthage/Carthage)
|
||||
## SlackKit: A Swift Slack Client Library
|
||||

|
||||

|
||||

|
||||
[](https://github.com/apple/swift-package-manager)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](https://cocoapods.org)
|
||||
|
||||
## SlackKit: Slack Apps in Swift
|
||||
### 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 to [bot users](https://api.slack.com/bot-users). SlackKit also supports Slack’s [OAuth 2.0](https://api.slack.com/docs/oauth) flow including the [Add to Slack](https://api.slack.com/docs/slack-button) and [Sign in with Slack](https://api.slack.com/docs/sign-in-with-slack) buttons, [incoming webhooks](https://api.slack.com/incoming-webhooks), [slash commands](https://api.slack.com/slash-commands), and [message buttons](https://api.slack.com/docs/message-buttons).
|
||||
SlackKit makes it easy to build Slack apps in Swift.
|
||||
|
||||
This is the **Swift 3** branch of SlackKit. SlackKit also has support for [Swift 2.3](https://github.com/pvzig/SlackKit/tree/swift2.3) and [Linux](https://github.com/pvzig/SlackKit/tree/linux).
|
||||
|
||||
#### 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:
|
||||
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 to [bot users](https://api.slack.com/bot-users). SlackKit also supports Slack’s [OAuth 2.0](https://api.slack.com/docs/oauth) flow including the [Add to Slack](https://api.slack.com/docs/slack-button) and [Sign in with Slack](https://api.slack.com/docs/sign-in-with-slack) buttons, [incoming webhooks](https://api.slack.com/incoming-webhooks), [slash commands](https://api.slack.com/slash-commands), and [message buttons](https://api.slack.com/docs/message-buttons).
|
||||
|
||||
### Installation
|
||||
|
||||
#### Carthage
|
||||
|
||||
Add SlackKit to your Cartfile:
|
||||
```
|
||||
github "https://github.com/pvzig/slackkit.git"
|
||||
```
|
||||
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
|
||||
Add `SlackKit` to your `Package.swift`
|
||||
|
||||
```swift
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/pvzig/SlackKit.git", majorVersion: 3)
|
||||
.package(url: "https://github.com/SlackKit/SlackKit.git", .upToNextMinor(from: "4.2.0"))
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Run `swift build` on your application’s main directory.
|
||||
|
||||
#### ~~CocoaPods~~
|
||||
SlackKit doesn’t currently build correctly using CocoaPods with Swift 3. I’m hoping to restore support soon.
|
||||
#### Carthage
|
||||
|
||||
Add `SlackKit` to your `Cartfile`:
|
||||
|
||||
To use the library in your project import it:
|
||||
```
|
||||
import SlackKit
|
||||
github "pvzig/SlackKit"
|
||||
```
|
||||
|
||||
#### CocoaPods
|
||||
Add `SlackKit` to your `Podfile`:
|
||||
|
||||
```
|
||||
pod 'SlackKit'
|
||||
```
|
||||
|
||||
### Usage
|
||||
#### The Basics
|
||||
Create a bot user with an API token:
|
||||
|
||||
```swift
|
||||
import SlackKit
|
||||
|
||||
let bot = SlackKit()
|
||||
bot.addRTMBotWithAPIToken("xoxb-SLACK-BOT-TOKEN")
|
||||
// Register for event notifications
|
||||
bot.notificationForEvent(.message) { (event, _) in
|
||||
// Your bot logic here
|
||||
print(event.message)
|
||||
}
|
||||
```
|
||||
|
||||
or create a ready-to-launch Slack app with your [application’s `Client ID` and `Client Secret`](https://api.slack.com/apps):
|
||||
|
||||
```swift
|
||||
import SlackKit
|
||||
|
||||
let bot = SlackKit()
|
||||
let oauthConfig = OAuthConfig(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET")
|
||||
bot.addServer(oauth: oauthConfig)
|
||||
```
|
||||
|
||||
or just make calls to the Slack Web API:
|
||||
|
||||
```swift
|
||||
import SlackKit
|
||||
|
||||
let bot = SlackKit()
|
||||
bot.addWebAPIAccessWithToken("xoxb-SLACK-BOT-TOKEN")
|
||||
bot.webAPI?.authenticationTest(success: { (success) in
|
||||
print(success)
|
||||
}, failure: nil)
|
||||
|
||||
```
|
||||
|
||||
#### Slash Commands
|
||||
After [configuring your slash command in Slack](https://my.slack.com/services/new/slash-commands) (you can also provide slash commands as part of a [Slack App](https://api.slack.com/slack-apps)), create a route, response middleware for that route, and add it to a responder:
|
||||
|
||||
```swift
|
||||
let slackkit = SlackKit()
|
||||
let middleware = ResponseMiddleware(token: "SLASH_COMMAND_TOKEN", response: SKResponse(text: "👋"))
|
||||
let route = RequestRoute(path: "/hello", middleware: middleware)
|
||||
let responder = SlackKitResponder(routes: [route])
|
||||
slackkit.addServer(responder: responder)
|
||||
```
|
||||
When a user enters that slash command, it will hit your configured route and return the response you specified.
|
||||
|
||||
#### Message Buttons
|
||||
Add [message buttons](https://api.slack.com/docs/message-buttons) to your responses for additional interactivity.
|
||||
|
||||
To send messages with actions, add them to an attachment and send them using the Web API:
|
||||
|
||||
```swift
|
||||
let helloAction = Action(name: "hello", text: "🌎")
|
||||
let attachment = Attachment(fallback: "Hello World", title: "Welcome to SlackKit", callbackID: "hello_world", actions: [helloAction])
|
||||
slackkit.webAPI?.sendMessage(channel: "CXXXXXX", text: "", attachments: [attachment], success: nil, failure: nil)
|
||||
```
|
||||
|
||||
To respond to message actions, add a `RequestRoute` with `MessageActionMiddleware` using your app’s verification token to your `SlackKitResponder`:
|
||||
|
||||
```swift
|
||||
let response = ResponseMiddleware(token: "SLACK_APP_VERIFICATION_TOKEN", response: SKResponse(text: "Hello, world!"))
|
||||
let actionRoute = MessageActionRoute(action: helloAction, middleware: response)
|
||||
let actionMiddleware = MessageActionMiddleware(token: "SLACK_APP_VERIFICATION_TOKEN", routes:[actionRoute])
|
||||
let actions = RequestRoute(path: "/actions", middleware: actionMiddleware)
|
||||
let responder = SlackKitResponder(routes: [actions])
|
||||
slackkit.addServer(responder: responder)
|
||||
```
|
||||
|
||||
#### OAuth
|
||||
Slack has [many different oauth scopes](https://api.slack.com/docs/oauth-scopes) that can be combined in different ways. If your application does not request the proper OAuth scopes, your API calls will fail.
|
||||
|
||||
If you authenticate using OAuth and the Add to Slack or Sign in with Slack buttons this is handled for you.
|
||||
|
||||
If you wish to make OAuth requests yourself, you can generate them using the `authorizeRequest` function on `SlackKit`’s `oauth` property:
|
||||
```swift
|
||||
func authorizeRequest(scope:[Scope], redirectURI: String, state: String = "slackkit", team: String? = nil)
|
||||
```
|
||||
|
||||
For local development of things like OAuth, slash commands, and message buttons that require connecting over `https`, you may want to use a tool like [ngrok](https://ngrok.com) or [localtunnel](http://localtunnel.me).
|
||||
|
||||
#### Incoming Webhooks
|
||||
After [configuring your incoming webhook in Slack](https://my.slack.com/services/new/incoming-webhook/), initialize IncomingWebhook with the provided URL and use `postMessage` to send messages.
|
||||
```swift
|
||||
let incoming = IncomingWebhook(url: "https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX")
|
||||
let message = Response(text: "Hello, World!")
|
||||
incoming.postMessage(message)
|
||||
```
|
||||
|
||||
#### Slash Commands
|
||||
After [configuring your slash command in Slack](https://my.slack.com/services/new/slash-commands) (you can also provide slash commands as part of a [Slack App](https://api.slack.com/slack-apps)), initialize a webhook server with the token for the slash command, a configured route, and a response.
|
||||
```swift
|
||||
let response = Response(text: "Hello, World!", responseType: .InChannel)
|
||||
let webhook = WebhookServer(token: "SLASH-COMMAND-TOKEN", route: "hello_world", response: response)
|
||||
webhook.start()
|
||||
```
|
||||
When a user enters that slash command, it will hit your configured route and return the response you specified.
|
||||
|
||||
To add additional routes and responses, you can use WebhookServer’s addRoute function:
|
||||
```swift
|
||||
func addRoute(route: String, response: Response)
|
||||
```
|
||||
|
||||
#### Message Buttons
|
||||
If you are developing a Slack App and are authorizing using OAuth, you can use [message buttons](https://api.slack.com/docs/message-buttons).
|
||||
|
||||
To send messages with actions, add them to an attachment:
|
||||
```swift
|
||||
let helloAction = Action(name: "hello_world", text: "Hello, World!")
|
||||
let attachment = Attachment(fallback: "Hello World Attachment", title: "Attachment with an Action Button", callbackID: "helloworld", actions: [helloAction])
|
||||
```
|
||||
|
||||
To act on message actions, initialize an instance of the `MessageActionServer` using your app’s verification token, your specified interactive messages request URL route, and a `MessageActionResponder`:
|
||||
```swift
|
||||
let action = Action(name: "hello_world", text: "Hello, World!")
|
||||
let response = Response(text: "Hello, 🌎!", responseType: .InChannel)
|
||||
let responder = MessageActionResponder(responses: [(action, response)])
|
||||
let server = MessageActionServer(token: "SLACK-APP-VERIFICATION-TOKEN", route: "actions", responder: responder)
|
||||
server.start()
|
||||
```
|
||||
|
||||
#### Bot Users
|
||||
To deploy a bot user using 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).
|
||||
|
||||
Initialize a SlackKit instance using your [application’s Client ID and Client Secret](https://api.slack.com/apps) to set up SlackKit for OAuth authorization:
|
||||
```swift
|
||||
let bot = SlackKit(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET")
|
||||
```
|
||||
|
||||
or use a manually acquired token:
|
||||
```swift
|
||||
let bot = SlackKit(withAPIToken: "xoxp-YOUR-SLACK-API-TOKEN")
|
||||
```
|
||||
|
||||
#### Client Connection Options
|
||||
You can also set options for a ping/pong interval, timeout interval, and automatic reconnection:
|
||||
```swift
|
||||
let options = ClientOptions(pingInterval: 2, timeout: 10, reconnect: false)
|
||||
let bot = SlackKit(clientID: "CLIENT_ID", clientSecret: "CLIENT_SECRET", clientOptions: options)
|
||||
```
|
||||
|
||||
Once connected, the client will begin to consume any messages sent by the Slack RTM API.
|
||||
For local development of things like OAuth, slash commands, and message buttons, you may want to use a tool like [ngrok](https://ngrok.com).
|
||||
|
||||
#### Web API Methods
|
||||
SlackKit currently supports the a subset of the Slack Web APIs that are available to bot users:
|
||||
|
||||
- api.test
|
||||
- auth.revoke
|
||||
- auth.test
|
||||
- channels.history
|
||||
- channels.info
|
||||
- channels.list
|
||||
- channels.mark
|
||||
- channels.setPurpose
|
||||
- channels.setTopic
|
||||
- chat.delete
|
||||
- chat.postMessage
|
||||
- chat.update
|
||||
- emoji.list
|
||||
- files.comments.add
|
||||
- files.comments.edit
|
||||
- files.comments.delete
|
||||
- files.delete
|
||||
- files.info
|
||||
- files.upload
|
||||
- groups.close
|
||||
- groups.history
|
||||
- groups.info
|
||||
- groups.list
|
||||
- groups.mark
|
||||
- groups.open
|
||||
- groups.setPurpose
|
||||
- groups.setTopic
|
||||
- im.close
|
||||
- im.history
|
||||
- im.list
|
||||
- im.mark
|
||||
- im.open
|
||||
- mpim.close
|
||||
- mpim.history
|
||||
- mpim.list
|
||||
- mpim.mark
|
||||
- mpim.open
|
||||
- oauth.access
|
||||
- pins.add
|
||||
- pins.list
|
||||
- pins.remove
|
||||
- reactions.add
|
||||
- reactions.get
|
||||
- reactions.list
|
||||
- reactions.remove
|
||||
- rtm.start
|
||||
- stars.add
|
||||
- stars.remove
|
||||
- team.info
|
||||
- users.getPresence
|
||||
- users.info
|
||||
- users.list
|
||||
- users.setActive
|
||||
- users.setPresence
|
||||
| Web APIs |
|
||||
| ------------- |
|
||||
| `api.test`|
|
||||
| `api.revoke`|
|
||||
| `auth.test`|
|
||||
| `channels.history`|
|
||||
| `channels.info`|
|
||||
| `channels.list`|
|
||||
| `channels.mark`|
|
||||
| `channels.setPurpose`|
|
||||
| `channels.setTopic`|
|
||||
| `chat.delete`|
|
||||
| `chat.meMessage`|
|
||||
| `chat.postMessage`|
|
||||
| `chat.update`|
|
||||
| `emoji.list`|
|
||||
| `files.comments.add`|
|
||||
| `files.comments.edit`|
|
||||
| `files.comments.delete`|
|
||||
| `files.delete`|
|
||||
| `files.info`|
|
||||
| `files.upload`|
|
||||
| `groups.close`|
|
||||
| `groups.history`|
|
||||
| `groups.info`|
|
||||
| `groups.list`|
|
||||
| `groups.mark`|
|
||||
| `groups.open`|
|
||||
| `groups.setPurpose`|
|
||||
| `groups.setTopic`|
|
||||
| `im.close`|
|
||||
| `im.history`|
|
||||
| `im.list`|
|
||||
| `im.mark`|
|
||||
| `im.open`|
|
||||
| `mpim.close`|
|
||||
| `mpim.history`|
|
||||
| `mpim.list`|
|
||||
| `mpim.mark`|
|
||||
| `mpim.open`|
|
||||
| `oauth.access`|
|
||||
| `pins.add`|
|
||||
| `pins.list`|
|
||||
| `pins.remove`|
|
||||
| `reactions.add`|
|
||||
| `reactions.get`|
|
||||
| `reactions.list`|
|
||||
| `reactions.remove`|
|
||||
| `rtm.start`|
|
||||
| `stars.add`|
|
||||
| `stars.remove`|
|
||||
| `team.info`|
|
||||
| `users.getPresence`|
|
||||
| `users.info`|
|
||||
| `users.list`|
|
||||
| `users.setActive`|
|
||||
| `users.setPresence`|
|
||||
|
||||
They can be accessed through a Client object’s `webAPI` property:
|
||||
```swift
|
||||
client.webAPI.authenticationTest({(auth) in
|
||||
print(auth)
|
||||
}, failure: {(error) in
|
||||
print(error)
|
||||
})
|
||||
```
|
||||
Don’t need the whole banana? Want more control over the low-level implementation details? Use the extensible modules SlackKit is built on:
|
||||
|
||||
#### Delegate methods
|
||||
|
||||
To receive delegate callbacks for events, register an object as the delegate for those events using the `onClientInitalization` block:
|
||||
```swift
|
||||
let bot = SlackKit(clientID: clientID, clientSecret: clientSecret)
|
||||
bot.onClientInitalization = { (client: Client) in
|
||||
DispatchQueue.main.async(execute: {
|
||||
client.messageEventsDelegate = self
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
Delegate callbacks contain a reference to the Client where the event occurred.
|
||||
|
||||
There are a number of delegates that you can set to receive callbacks for certain events.
|
||||
|
||||
##### ConnectionEventsDelegate
|
||||
```swift
|
||||
connected(_ client: Client)
|
||||
disconnected(_ client: Client)
|
||||
connectionFailed(_ client: Client, error: SlackError)
|
||||
```
|
||||
##### MessageEventsDelegate
|
||||
```swift
|
||||
sent(_ message: Message, client: Client)
|
||||
received(_ message: Message, client: Client)
|
||||
changed(_ message: Message, client: Client)
|
||||
deleted(_ message: Message?, client: Client)
|
||||
```
|
||||
##### ChannelEventsDelegate
|
||||
```swift
|
||||
userTypingIn(_ channel: Channel, user: User, client: Client)
|
||||
marked(_ channel: Channel, timestamp: String, client: Client)
|
||||
created(_ channel: Channel, client: Client)
|
||||
deleted(_ channel: Channel, client: Client)
|
||||
renamed(_ channel: Channel, client: Client)
|
||||
archived(_ channel: Channel, client: Client)
|
||||
historyChanged(_ channel: Channel, client: Client)
|
||||
joined(_ channel: Channel, client: Client)
|
||||
left(_ channel: Channel, client: Client)
|
||||
```
|
||||
##### DoNotDisturbEventsDelegate
|
||||
```swift
|
||||
updated(_ status: DoNotDisturbStatus, client: Client)
|
||||
userUpdated(_ status: DoNotDisturbStatus, user: User, client: Client)
|
||||
```
|
||||
##### GroupEventsDelegate
|
||||
```swift
|
||||
opened(_ group: Channel, client: Client)
|
||||
```
|
||||
##### FileEventsDelegate
|
||||
```swift
|
||||
processed(_ file: File, client: Client)
|
||||
madePrivate(_ file: File, client: Client)
|
||||
deleted(_ file: File, client: Client)
|
||||
commentAdded(_ file: File, comment: Comment, client: Client)
|
||||
commentEdited(_ file: File, comment: Comment, client: Client)
|
||||
commentDeleted(_ file: File, comment: Comment, client: Client)
|
||||
```
|
||||
##### PinEventsDelegate
|
||||
```swift
|
||||
pinned(_ item: Item, channel: Channel?, client: Client)
|
||||
unpinned(_ item: Item, channel: Channel?, client: Client)
|
||||
```
|
||||
##### StarEventsDelegate
|
||||
```swift
|
||||
starred(_ item: Item, starred: Bool, _ client: Client)
|
||||
```
|
||||
##### ReactionEventsDelegate
|
||||
```swift
|
||||
added(_ reaction: String, item: Item, itemUser: String, client: Client)
|
||||
removed(_ reaction: String, item: Item, itemUser: String, client: Client)
|
||||
```
|
||||
##### SlackEventsDelegate
|
||||
```swift
|
||||
preferenceChanged(_ preference: String, value: Any?, client: Client)
|
||||
userChanged(_ user: User, client: Client)
|
||||
presenceChanged(_ user: User, presence: String, client: Client)
|
||||
manualPresenceChanged(_ user: User, presence: String, client: Client)
|
||||
botEvent(_ bot: Bot, client: Client)
|
||||
```
|
||||
##### TeamEventsDelegate
|
||||
```swift
|
||||
userJoined(_ user: User, client: Client)
|
||||
planChanged(_ plan: String, client: Client)
|
||||
preferencesChanged(_ preference: String, value: Any?, client: Client)
|
||||
nameChanged(_ name: String, client: Client)
|
||||
domainChanged(_ domain: String, client: Client)
|
||||
emailDomainChanged(_ domain: String, client: Client)
|
||||
emojiChanged(_ client: Client)
|
||||
```
|
||||
##### SubteamEventsDelegate
|
||||
```swift
|
||||
event(_ userGroup: UserGroup, client: Client)
|
||||
selfAdded(_ subteamID: String, client: Client)
|
||||
selfRemoved(_ subteamID: String, client: Client)
|
||||
```
|
||||
##### TeamProfileEventsDelegate
|
||||
```swift
|
||||
changed(_ profile: CustomProfile, client: Client)
|
||||
deleted(_ profile: CustomProfile, client: Client)
|
||||
reordered(_ profile: CustomProfile, client: Client)
|
||||
```
|
||||
| Module | Slack Service |
|
||||
| ------------- |------------- |
|
||||
| **[SKClient](https://github.com/pvzig/SlackKit/tree/master/SKClient)** | Write your own client implementation|
|
||||
| **[SKRTMAPI](https://github.com/pvzig/SlackKit/tree/master/SKRTMAPI)** | Connect to the Slack RTM API|
|
||||
| **[SKServer](https://github.com/pvzig/SlackKit/tree/master/SKServer)** | Spin up a server|
|
||||
| **[SKWebAPI](https://github.com/pvzig/SlackKit/tree/master/SKWebAPI)** | Access the Slack Web API|
|
||||
|
||||
### Examples
|
||||
[Check out example applications here.](https://github.com/pvzig/SlackKit-examples)
|
||||
You can find the source code for several example applications [here](https://github.com/pvzig/SlackKit/tree/master/Examples).
|
||||
|
||||
### Tutorials
|
||||
- [Build a Slack Bot and Deploy to Heroku](https://medium.com/@pvzig/building-slack-bots-in-swift-b99e243e444c)
|
||||
|
||||
### Get In Touch
|
||||
[@pvzig](https://twitter.com/pvzig)
|
||||
Twitter: [@pvzig](https://twitter.com/pvzig)
|
||||
|
||||
<peter@launchsoft.co>
|
||||
Email: <peter@launchsoft.co>
|
||||
|
||||
Executable
+86
@@ -0,0 +1,86 @@
|
||||
# SKClient: SlackKit Client Module
|
||||

|
||||

|
||||

|
||||
[](https://github.com/apple/swift-package-manager)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](https://cocoapods.org)
|
||||
|
||||
Create a custom SlackKit client.
|
||||
|
||||
## Installation
|
||||
|
||||
### CocoaPods
|
||||
|
||||
Add SKClient to your pod file:
|
||||
|
||||
```
|
||||
use_frameworks!
|
||||
pod 'SKClient'
|
||||
```
|
||||
and run
|
||||
|
||||
```
|
||||
# Use CocoaPods version >= 1.4.0
|
||||
pod install
|
||||
```
|
||||
|
||||
### Carthage
|
||||
|
||||
Add SKClient to your Cartfile:
|
||||
|
||||
```
|
||||
github "SlackKit/SKClient"
|
||||
```
|
||||
and run
|
||||
|
||||
```
|
||||
carthage bootstrap
|
||||
```
|
||||
|
||||
Drag the built `SKClient.framework` into your Xcode project.
|
||||
|
||||
### Swift Package Manager
|
||||
|
||||
Add SKClient to your Package.swift
|
||||
|
||||
```swift
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/SlackKit/SKClient.git", .upToNextMinor(from: "4.1.0"))
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Run `swift build` on your application’s main directory.
|
||||
|
||||
To use the library in your project import it:
|
||||
|
||||
```
|
||||
import SKClient
|
||||
```
|
||||
|
||||
## Usage
|
||||
Subclass `Client` to create a custom SlackKit client.
|
||||
|
||||
```
|
||||
class MyClient: Client {
|
||||
|
||||
override func notificationForEvent(_ event: Event, type: EventType) {
|
||||
…
|
||||
}
|
||||
|
||||
override func initialSetup(JSON: [String: Any]) {
|
||||
…
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Pass your custom client to [`SlackKit`](https://www.github.com/SlackKit/SlackKit) when adding an RTM bot:
|
||||
|
||||
```
|
||||
let bot = SlackKit()
|
||||
bot.addRTMBotWithAPIToken(“xoxb-SLACK_AUTH_TOKEN”, client: MyClient())
|
||||
```
|
||||
Executable
+879
@@ -0,0 +1,879 @@
|
||||
//
|
||||
// Client.swift
|
||||
//
|
||||
// Copyright © 2017 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.
|
||||
|
||||
#if os(Linux)
|
||||
import Dispatch
|
||||
#endif
|
||||
import Foundation
|
||||
#if !COCOAPODS
|
||||
@_exported import SKCore
|
||||
#endif
|
||||
|
||||
open class Client {
|
||||
internal(set) public var authenticatedUser: User?
|
||||
internal(set) public var team: Team?
|
||||
internal(set) public var channels = [String: Channel]()
|
||||
internal(set) public var users = [String: User]()
|
||||
internal(set) public var userGroups = [String: UserGroup]()
|
||||
internal(set) public var bots = [String: Bot]()
|
||||
internal(set) public var files = [String: File]()
|
||||
internal(set) public var sentMessages = [String: Message]()
|
||||
|
||||
public init(){}
|
||||
|
||||
open func notificationForEvent(_ event: Event, type: EventType) {
|
||||
switch type {
|
||||
case .hello:
|
||||
// Connection event
|
||||
break
|
||||
case .ok:
|
||||
messageSent(event)
|
||||
case .message:
|
||||
if event.subtype != nil {
|
||||
messageDispatcher(event)
|
||||
} else {
|
||||
messageReceived(event)
|
||||
}
|
||||
case .userTyping:
|
||||
userTyping(event)
|
||||
case .channelMarked, .imMarked, .groupMarked:
|
||||
channelMarked(event)
|
||||
case .channelCreated, .imCreated:
|
||||
channelCreated(event)
|
||||
case .channelJoined, .groupJoined:
|
||||
channelJoined(event)
|
||||
case .channelLeft, .groupLeft:
|
||||
channelLeft(event)
|
||||
case .channelDeleted:
|
||||
channelDeleted(event)
|
||||
case .channelRenamed, .groupRename:
|
||||
channelRenamed(event)
|
||||
case .channelArchive, .groupArchive:
|
||||
channelArchived(event, archived: true)
|
||||
case .channelUnarchive, .groupUnarchive:
|
||||
channelArchived(event, archived: false)
|
||||
case .channelHistoryChanged, .imHistoryChanged, .groupHistoryChanged:
|
||||
channelHistoryChanged(event)
|
||||
case .dndUpdated:
|
||||
doNotDisturbUpdated(event)
|
||||
case .dndUpatedUser:
|
||||
doNotDisturbUserUpdated(event)
|
||||
case .imOpen, .groupOpen:
|
||||
open(event, open: true)
|
||||
case .imClose, .groupClose:
|
||||
open(event, open: false)
|
||||
case .fileCreated:
|
||||
processFile(event)
|
||||
case .fileShared:
|
||||
processFile(event)
|
||||
case .fileUnshared:
|
||||
processFile(event)
|
||||
case .filePublic:
|
||||
processFile(event)
|
||||
case .filePrivate:
|
||||
filePrivate(event)
|
||||
case .fileChanged:
|
||||
processFile(event)
|
||||
case .fileDeleted:
|
||||
deleteFile(event)
|
||||
case .fileCommentAdded:
|
||||
fileCommentAdded(event)
|
||||
case .fileCommentEdited:
|
||||
fileCommentEdited(event)
|
||||
case .fileCommentDeleted:
|
||||
fileCommentDeleted(event)
|
||||
case .pinAdded:
|
||||
pinAdded(event)
|
||||
case .pinRemoved:
|
||||
pinRemoved(event)
|
||||
case .pong:
|
||||
// Pong event
|
||||
break
|
||||
case .presenceChange:
|
||||
presenceChange(event)
|
||||
case .manualPresenceChange:
|
||||
manualPresenceChange(event)
|
||||
case .prefChange:
|
||||
changePreference(event)
|
||||
case .userChange:
|
||||
userChange(event)
|
||||
case .teamJoin:
|
||||
teamJoin(event)
|
||||
case .starAdded:
|
||||
itemStarred(event, star: true)
|
||||
case .starRemoved:
|
||||
itemStarred(event, star: false)
|
||||
case .reactionAdded:
|
||||
addedReaction(event)
|
||||
case .reactionRemoved:
|
||||
removedReaction(event)
|
||||
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.
|
||||
// Until they are released other clients should ignore this event.
|
||||
break
|
||||
case .teamPlanChange:
|
||||
teamPlanChange(event)
|
||||
case .teamPrefChange:
|
||||
teamPreferenceChange(event)
|
||||
case .teamRename:
|
||||
teamNameChange(event)
|
||||
case .teamDomainChange:
|
||||
teamDomainChange(event)
|
||||
case .emailDomainChange:
|
||||
emailDomainChange(event)
|
||||
case .teamProfileChange:
|
||||
teamProfileChange(event)
|
||||
case .teamProfileDelete:
|
||||
teamProfileDeleted(event)
|
||||
case .teamProfileReorder:
|
||||
teamProfileReordered(event)
|
||||
case .botAdded:
|
||||
bot(event)
|
||||
case .botChanged:
|
||||
bot(event)
|
||||
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:
|
||||
// Team migration event
|
||||
break
|
||||
case .reconnectURL:
|
||||
// The reconnect_url event is currently unsupported and experimental.
|
||||
break
|
||||
case .subteamCreated, .subteamUpdated:
|
||||
subteam(event)
|
||||
case .subteamSelfAdded:
|
||||
subteamAddedSelf(event)
|
||||
case .subteamSelfRemoved:
|
||||
subteamRemovedSelf(event)
|
||||
case .error:
|
||||
// Error event
|
||||
break
|
||||
case .goodbye:
|
||||
// Goodbye event
|
||||
break
|
||||
case .unknown:
|
||||
// Unsupported event
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Client setup
|
||||
open 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 messageDispatcher(_ event: Event) {
|
||||
guard let value = event.subtype, let subtype = MessageSubtype(rawValue:value) else {
|
||||
return
|
||||
}
|
||||
switch subtype {
|
||||
case .messageChanged:
|
||||
messageChanged(event)
|
||||
case .messageDeleted:
|
||||
messageDeleted(event)
|
||||
default:
|
||||
messageReceived(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Messages
|
||||
extension Client {
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func messageDeleted(_ event: Event) {
|
||||
guard
|
||||
let id = event.channel?.id,
|
||||
let key = event.message?.deletedTs
|
||||
else {
|
||||
return
|
||||
}
|
||||
_ = channels[id]?.messages.removeValue(forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Channels
|
||||
extension Client {
|
||||
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)
|
||||
|
||||
let timeout = DispatchTime.now() + Double(Int64(5.0 * Double(UInt64.nanosecondsPerSecond))) / Double(UInt64.nanosecondsPerSecond)
|
||||
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,
|
||||
let id = channel.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
channels[id]?.lastRead = event.ts
|
||||
}
|
||||
|
||||
func channelCreated(_ event: Event) {
|
||||
guard
|
||||
let channel = event.channel,
|
||||
let id = channel.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
channels[id] = channel
|
||||
}
|
||||
|
||||
func channelDeleted(_ event: Event) {
|
||||
guard
|
||||
let channel = event.channel,
|
||||
let id = channel.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
channels.removeValue(forKey: id)
|
||||
}
|
||||
|
||||
func channelJoined(_ event: Event) {
|
||||
guard
|
||||
let channel = event.channel,
|
||||
let id = channel.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
channels[id] = event.channel
|
||||
}
|
||||
|
||||
func channelLeft(_ event: Event) {
|
||||
guard
|
||||
let channel = event.channel,
|
||||
let id = channel.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
|
||||
if let userID = authenticatedUser?.id, let index = channels[id]?.members?.index(of: userID) {
|
||||
channels[id]?.members?.remove(at: index)
|
||||
}
|
||||
}
|
||||
|
||||
func channelRenamed(_ event: Event) {
|
||||
guard
|
||||
let channel = event.channel,
|
||||
let id = channel.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
channels[id]?.name = channel.name
|
||||
}
|
||||
|
||||
func channelArchived(_ event: Event, archived: Bool) {
|
||||
guard
|
||||
let channel = event.channel,
|
||||
let id = channel.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
channels[id]?.isArchived = archived
|
||||
}
|
||||
|
||||
func channelHistoryChanged(_ event: Event) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Do Not Disturb
|
||||
extension Client {
|
||||
func doNotDisturbUpdated(_ event: Event) {
|
||||
guard let dndStatus = event.dndStatus else {
|
||||
return
|
||||
}
|
||||
authenticatedUser?.doNotDisturbStatus = dndStatus
|
||||
}
|
||||
|
||||
func doNotDisturbUserUpdated(_ event: Event) {
|
||||
guard
|
||||
let dndStatus = event.dndStatus,
|
||||
let user = event.user,
|
||||
let id = user.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
users[id]?.doNotDisturbStatus = dndStatus
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - IM & Group Open/Close
|
||||
extension Client {
|
||||
func open(_ event: Event, open: Bool) {
|
||||
guard
|
||||
let channel = event.channel,
|
||||
let id = channel.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
channels[id]?.isOpen = open
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Files
|
||||
extension Client {
|
||||
func processFile(_ event: Event) {
|
||||
for file in event.files {
|
||||
guard
|
||||
let id = file.id
|
||||
else {
|
||||
continue
|
||||
}
|
||||
if let comment = file.initialComment, let commentID = comment.id {
|
||||
if files[id]?.comments[commentID] == nil {
|
||||
files[id]?.comments[commentID] = comment
|
||||
}
|
||||
}
|
||||
files[id] = file
|
||||
}
|
||||
}
|
||||
|
||||
func filePrivate(_ event: Event) {
|
||||
for file in event.files {
|
||||
guard
|
||||
let id = file.id
|
||||
else {
|
||||
continue
|
||||
}
|
||||
files[id]?.isPublic = false
|
||||
}
|
||||
}
|
||||
|
||||
func deleteFile(_ event: Event) {
|
||||
for file in event.files {
|
||||
guard
|
||||
let id = file.id
|
||||
else {
|
||||
continue
|
||||
}
|
||||
if files[id] != nil {
|
||||
files.removeValue(forKey: id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func fileCommentAdded(_ event: Event) {
|
||||
for file in event.files {
|
||||
guard
|
||||
let id = file.id,
|
||||
let comment = event.comment,
|
||||
let commentID = comment.id
|
||||
else {
|
||||
continue
|
||||
}
|
||||
files[id]?.comments[commentID] = comment
|
||||
}
|
||||
}
|
||||
|
||||
func fileCommentEdited(_ event: Event) {
|
||||
for file in event.files {
|
||||
guard
|
||||
let id = file.id,
|
||||
let comment = event.comment,
|
||||
let commentID = comment.id
|
||||
else {
|
||||
continue
|
||||
}
|
||||
files[id]?.comments[commentID]?.comment = comment.comment
|
||||
}
|
||||
}
|
||||
|
||||
func fileCommentDeleted(_ event: Event) {
|
||||
for file in event.files {
|
||||
guard
|
||||
let id = file.id,
|
||||
let comment = event.comment,
|
||||
let commentID = comment.id
|
||||
else {
|
||||
continue
|
||||
}
|
||||
_ = files[id]?.comments.removeValue(forKey: commentID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Pins
|
||||
extension Client {
|
||||
func pinAdded(_ event: Event) {
|
||||
guard
|
||||
let id = event.channelID,
|
||||
let item = event.item
|
||||
else {
|
||||
return
|
||||
}
|
||||
channels[id]?.pinnedItems.append(item)
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Stars
|
||||
extension Client {
|
||||
func itemStarred(_ event: Event, star: Bool) {
|
||||
guard
|
||||
let item = event.item,
|
||||
let type = item.type
|
||||
else {
|
||||
return
|
||||
}
|
||||
switch type {
|
||||
case "message":
|
||||
starMessage(item, star: star)
|
||||
case "file":
|
||||
starFile(item, star: star)
|
||||
case "file_comment":
|
||||
starComment(item)
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
let id = file.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
files[id]?.isStarred = star
|
||||
if let stars = files[id]?.stars {
|
||||
if star == true {
|
||||
files[id]?.stars = stars + 1
|
||||
} else {
|
||||
if stars > 0 {
|
||||
files[id]?.stars = stars - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
extension Client {
|
||||
func addedReaction(_ event: Event) {
|
||||
guard
|
||||
let item = event.item,
|
||||
let type = item.type,
|
||||
let reaction = event.reaction,
|
||||
let userID = event.user?.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
switch type {
|
||||
case "message":
|
||||
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))
|
||||
case "file":
|
||||
guard let id = item.file?.id else {
|
||||
return
|
||||
}
|
||||
files[id]?.reactions.append(Reaction(name: reaction, user: userID))
|
||||
case "file_comment":
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
func removedReaction(_ event: Event) {
|
||||
guard
|
||||
let item = event.item,
|
||||
let type = item.type,
|
||||
let key = event.reaction,
|
||||
let userID = event.user?.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
switch type {
|
||||
case "message":
|
||||
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,
|
||||
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,
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Preferences
|
||||
extension Client {
|
||||
func changePreference(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
authenticatedUser?.preferences?[name] = event.value
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - User Change
|
||||
extension Client {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - User Presence
|
||||
extension Client {
|
||||
func presenceChange(_ event: Event) {
|
||||
guard
|
||||
let user = event.user,
|
||||
let id = user.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
users[id]?.presence = event.presence
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Team
|
||||
extension Client {
|
||||
func teamJoin(_ event: Event) {
|
||||
guard
|
||||
let user = event.user,
|
||||
let id = user.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
users[id] = user
|
||||
}
|
||||
|
||||
func teamPlanChange(_ event: Event) {
|
||||
guard let plan = event.plan else {
|
||||
return
|
||||
}
|
||||
team?.plan = plan
|
||||
}
|
||||
|
||||
func teamPreferenceChange(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
team?.prefs?[name] = event.value
|
||||
}
|
||||
|
||||
func teamNameChange(_ event: Event) {
|
||||
guard let name = event.name else {
|
||||
return
|
||||
}
|
||||
team?.name = name
|
||||
}
|
||||
|
||||
func teamDomainChange(_ event: Event) {
|
||||
guard let domain = event.domain else {
|
||||
return
|
||||
}
|
||||
team?.domain = domain
|
||||
}
|
||||
|
||||
func emailDomainChange(_ event: Event) {
|
||||
guard let domain = event.emailDomain else {
|
||||
return
|
||||
}
|
||||
team?.emailDomain = domain
|
||||
}
|
||||
|
||||
func emojiChanged(_ event: Event) {}
|
||||
}
|
||||
|
||||
// MARK: - Bots
|
||||
extension Client {
|
||||
func bot(_ event: Event) {
|
||||
guard
|
||||
let bot = event.bot,
|
||||
let id = bot.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
bots[id] = bot
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Subteams
|
||||
extension Client {
|
||||
func subteam(_ event: Event) {
|
||||
guard
|
||||
let subteam = event.subteam,
|
||||
let id = subteam.id
|
||||
else {
|
||||
return
|
||||
}
|
||||
userGroups[id] = subteam
|
||||
}
|
||||
|
||||
func subteamAddedSelf(_ event: Event) {
|
||||
guard
|
||||
let subteamID = event.subteamID,
|
||||
authenticatedUser?.userGroups != nil
|
||||
else {
|
||||
return
|
||||
}
|
||||
authenticatedUser?.userGroups![subteamID] = subteamID
|
||||
}
|
||||
|
||||
func subteamRemovedSelf(_ event: Event) {
|
||||
guard let subteamID = event.subteamID else {
|
||||
return
|
||||
}
|
||||
_ = authenticatedUser?.userGroups?.removeValue(forKey: subteamID)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Team Profiles
|
||||
extension Client {
|
||||
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])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Authenticated User
|
||||
extension Client {
|
||||
func manualPresenceChange(_ event: Event) {
|
||||
guard let presence = event.presence else {
|
||||
return
|
||||
}
|
||||
authenticatedUser?.presence = presence
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Utilities
|
||||
public extension Client {
|
||||
fileprivate func addUser(_ aUser: [String: Any]) {
|
||||
let user = User(user: aUser)
|
||||
if let id = user.id {
|
||||
users[id] = user
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func addChannel(_ aChannel: [String: Any]) {
|
||||
let channel = Channel(channel: aChannel)
|
||||
if let id = channel.id {
|
||||
channels[id] = channel
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func addBot(_ aBot: [String: Any]) {
|
||||
let bot = Bot(bot: aBot)
|
||||
if let id = bot.id {
|
||||
bots[id] = bot
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func enumerateSubteams(_ subteams: [String: Any]?) {
|
||||
if let subteams = subteams {
|
||||
if let all = subteams["all"] as? [[String: Any]] {
|
||||
for item in all {
|
||||
let u = UserGroup(userGroup: item)
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func enumerateObjects(_ array: [Any]?, initalizer: ([String: Any]) -> Void) {
|
||||
if let array = array {
|
||||
for object in array {
|
||||
if let dictionary = object as? [String: Any] {
|
||||
initalizer(dictionary)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
# SKCore: SlackKit Models
|
||||

|
||||

|
||||

|
||||
[](https://github.com/apple/swift-package-manager)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](https://cocoapods.org)
|
||||
|
||||
SKCore contains the shared model objects used by [SlackKit](https://www.github.com/SlackKit/SlackKit) and the other [SlackKit modules](https://www.github.com/SlackKit).
|
||||
Regular → Executable
+61
-22
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Action.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
// Copyright © 2017 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
|
||||
@@ -22,65 +22,76 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
public struct Action {
|
||||
|
||||
public let name: String?
|
||||
public let text: String?
|
||||
public let type: String?
|
||||
public let value: String?
|
||||
public let url: String?
|
||||
public let style: ActionStyle?
|
||||
public let confirm: Confirm?
|
||||
|
||||
internal init(action:[String: Any]?) {
|
||||
public let options: [Option]?
|
||||
public let dataSource: DataSource?
|
||||
|
||||
public init(action: [String: Any]?) {
|
||||
name = action?["name"] as? String
|
||||
text = action?["text"] as? String
|
||||
type = action?["type"] as? String
|
||||
value = action?["value"] as? String
|
||||
url = action?["url"] as? String
|
||||
style = ActionStyle(rawValue: action?["style"] as? String ?? "")
|
||||
confirm = Confirm(confirm:action?["confirm"] as? [String: Any])
|
||||
options = (action?["options"] as? [[String: Any]])?.map { Option(option: $0) }
|
||||
dataSource = DataSource(rawValue: action?["data_source"] as? String ?? "")
|
||||
}
|
||||
|
||||
public init(name: String, text: String, style: ActionStyle = .Default, value: String? = nil, confirm: Confirm? = nil) {
|
||||
self.type = "button"
|
||||
|
||||
public init(name: String, text: String, type: String = "button", style: ActionStyle = .defaultStyle, value: String? = nil,
|
||||
url: String? = nil, confirm: Confirm? = nil, options: [Option]? = nil, dataSource: DataSource? = nil) {
|
||||
self.name = name
|
||||
self.text = text
|
||||
self.type = type
|
||||
self.value = value
|
||||
self.url = url
|
||||
self.style = style
|
||||
self.confirm = confirm
|
||||
self.options = options
|
||||
self.dataSource = dataSource
|
||||
}
|
||||
|
||||
internal var dictionary: [String: Any] {
|
||||
|
||||
public var dictionary: [String: Any] {
|
||||
var dict = [String: Any]()
|
||||
dict["name"] = name
|
||||
dict["text"] = text
|
||||
dict["type"] = type
|
||||
dict["value"] = value
|
||||
dict["url"] = url
|
||||
dict["style"] = style?.rawValue
|
||||
dict["confirm"] = confirm?.dictionary
|
||||
dict["options"] = options?.map { $0.dictionary }
|
||||
dict["data_source"] = dataSource?.rawValue
|
||||
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]?) {
|
||||
|
||||
public 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] {
|
||||
|
||||
public var dictionary: [String: Any] {
|
||||
var dict = [String: Any]()
|
||||
dict["title"] = title
|
||||
dict["text"] = text
|
||||
@@ -89,15 +100,43 @@ public struct Action {
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
public struct Option {
|
||||
public let text: String?
|
||||
public let value: String?
|
||||
|
||||
public init(option: [String: Any]?) {
|
||||
text = option?["text"] as? String
|
||||
value = option?["value"] as? String
|
||||
}
|
||||
|
||||
public init(text: String, value: String) {
|
||||
self.text = text
|
||||
self.value = value
|
||||
}
|
||||
|
||||
public var dictionary: [String: Any] {
|
||||
var dict = [String: Any]()
|
||||
dict["text"] = text
|
||||
dict["value"] = value
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
public enum DataSource: String {
|
||||
case users
|
||||
case channels
|
||||
case conversations
|
||||
}
|
||||
}
|
||||
|
||||
public enum ActionStyle: String {
|
||||
case Default = "default"
|
||||
case Primary = "primary"
|
||||
case Danger = "danger"
|
||||
case defaultStyle = "default"
|
||||
case primary = "primary"
|
||||
case danger = "danger"
|
||||
}
|
||||
|
||||
public enum ResponseType: String {
|
||||
case InChannel = "in_channel"
|
||||
case Ephemeral = "ephemeral"
|
||||
public enum MessageResponseType: String {
|
||||
case inChannel = "in_channel"
|
||||
case ephemeral = "ephemeral"
|
||||
}
|
||||
Regular → Executable
+44
-13
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Attachment.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
// Copyright © 2017 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
|
||||
@@ -22,7 +22,6 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
public struct Attachment {
|
||||
|
||||
public let fallback: String?
|
||||
public let callbackID: String?
|
||||
public let type: String?
|
||||
@@ -41,8 +40,9 @@ public struct Attachment {
|
||||
public let footer: String?
|
||||
public let footerIcon: String?
|
||||
public let ts: Int?
|
||||
public let markdownEnabledFields: Set<AttachmentTextField>?
|
||||
|
||||
internal init(attachment: [String: Any]?) {
|
||||
public init(attachment: [String: Any]?) {
|
||||
fallback = attachment?["fallback"] as? String
|
||||
callbackID = attachment?["callback_id"] as? String
|
||||
type = attachment?["attachment_type"] as? String
|
||||
@@ -61,9 +61,30 @@ public struct Attachment {
|
||||
ts = attachment?["ts"] as? Int
|
||||
fields = (attachment?["fields"] as? [[String: Any]])?.map { AttachmentField(field: $0) }
|
||||
actions = (attachment?["actions"] as? [[String: Any]])?.map { Action(action: $0) }
|
||||
markdownEnabledFields = (attachment?["mrkdwn_in"] as? [String]).map { Set($0.compactMap(AttachmentTextField.init)) }
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
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,
|
||||
markdownFields: Set<AttachmentTextField>? = nil
|
||||
) {
|
||||
self.fallback = fallback
|
||||
self.callbackID = callbackID
|
||||
self.type = type
|
||||
@@ -82,34 +103,44 @@ public struct Attachment {
|
||||
self.footer = footer
|
||||
self.footerIcon = footerIcon
|
||||
self.ts = ts
|
||||
self.markdownEnabledFields = markdownFields
|
||||
}
|
||||
|
||||
internal var dictionary: [String: Any] {
|
||||
|
||||
public 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
|
||||
attachment["author_name"] = authorName
|
||||
attachment["author_link"] = authorLink
|
||||
attachment["author_icon"] = authorIcon
|
||||
attachment["title"] = title
|
||||
attachment["title_link"] = titleLink
|
||||
attachment["text"] = text
|
||||
attachment["fields"] = fields?.map{$0.dictionary}
|
||||
attachment["actions"] = actions?.map{$0.dictionary}
|
||||
attachment["fields"] = fields?.map { $0.dictionary }
|
||||
attachment["actions"] = actions?.map { $0.dictionary }
|
||||
attachment["image_url"] = imageURL
|
||||
attachment["thumb_url"] = thumbURL
|
||||
attachment["footer"] = footer
|
||||
attachment["footer_icon"] = footerIcon
|
||||
attachment["ts"] = ts
|
||||
attachment["mrkdwn_in"] = markdownEnabledFields?.map { $0.rawValue }
|
||||
return attachment
|
||||
}
|
||||
}
|
||||
|
||||
public enum AttachmentColor: String {
|
||||
case Good = "good"
|
||||
case Warning = "warning"
|
||||
case Danger = "danger"
|
||||
case good, warning, danger
|
||||
}
|
||||
|
||||
public enum AttachmentTextField: String {
|
||||
case fallback = "fallback"
|
||||
case pretext = "pretext"
|
||||
case authorName = "author_name"
|
||||
case title = "title"
|
||||
case text = "text"
|
||||
case fields = "fields"
|
||||
case footer = "footer"
|
||||
}
|
||||
Regular → Executable
+8
-9
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AttachmentField.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
// Copyright © 2017 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
|
||||
@@ -22,24 +22,23 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
public struct AttachmentField {
|
||||
|
||||
public let title: String?
|
||||
public let value: String?
|
||||
public let short: Bool?
|
||||
|
||||
internal init(field: [String: Any]?) {
|
||||
|
||||
public 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) {
|
||||
|
||||
public init(title: String?, value: String?, short: Bool? = nil) {
|
||||
self.title = title
|
||||
self.value = value.slackFormatEscaping
|
||||
self.value = value
|
||||
self.short = short
|
||||
}
|
||||
|
||||
internal var dictionary: [String: Any] {
|
||||
|
||||
public var dictionary: [String: Any] {
|
||||
var field = [String: Any]()
|
||||
field["title"] = title
|
||||
field["value"] = value
|
||||
Regular → Executable
+8
-9
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Bot.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
// Copyright © 2017 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
|
||||
@@ -22,19 +22,18 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
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: Any]?
|
||||
|
||||
internal init(bot: [String: Any]?) {
|
||||
public var botToken: String?
|
||||
public var name: String?
|
||||
public var icons: [String: Any]?
|
||||
|
||||
public init(bot: [String: Any]?) {
|
||||
id = bot?["id"] as? String
|
||||
name = bot?["name"] as? String
|
||||
icons = bot?["icons"] as? [String: Any]
|
||||
}
|
||||
|
||||
internal init(botUser: [String: Any]?) {
|
||||
|
||||
public init(botUser: [String: Any]?) {
|
||||
id = botUser?["bot_user_id"] as? String
|
||||
botToken = botUser?["bot_access_token"] as? String
|
||||
}
|
||||
Regular → Executable
+20
-21
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Channel.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
// Copyright © 2017 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
|
||||
@@ -22,34 +22,33 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
public struct Channel {
|
||||
|
||||
public let id: String?
|
||||
public let created: Int?
|
||||
public let creator: String?
|
||||
internal(set) public var name: String?
|
||||
internal(set) public var isArchived: Bool?
|
||||
internal(set) public var isGeneral: Bool?
|
||||
public var name: String?
|
||||
public var isArchived: Bool?
|
||||
public var isGeneral: Bool?
|
||||
public let isGroup: Bool?
|
||||
public let isIM: Bool?
|
||||
public let isMPIM: Bool?
|
||||
internal(set) public var user: String?
|
||||
internal(set) public var isUserDeleted: Bool?
|
||||
internal(set) public var isOpen: Bool?
|
||||
internal(set) public var topic: Topic?
|
||||
internal(set) public var purpose: Topic?
|
||||
internal(set) public var isMember: Bool?
|
||||
public var user: String?
|
||||
public var isUserDeleted: Bool?
|
||||
public var isOpen: Bool?
|
||||
public var topic: Topic?
|
||||
public var purpose: Topic?
|
||||
public var isMember: Bool?
|
||||
public var lastRead: String?
|
||||
internal(set) public var latest: Message?
|
||||
public var latest: Message?
|
||||
public var unread: Int?
|
||||
public var unreadCountDisplay: Int?
|
||||
internal(set) public var hasPins: Bool?
|
||||
internal(set) public var members: [String]?
|
||||
public var hasPins: Bool?
|
||||
public var members: [String]?
|
||||
// Client use
|
||||
internal(set) public var pinnedItems = [Item]()
|
||||
internal(set) public var usersTyping = [String]()
|
||||
internal(set) public var messages = [String: Message]()
|
||||
|
||||
internal init(channel: [String: Any]?) {
|
||||
public var pinnedItems = [Item]()
|
||||
public var usersTyping = [String]()
|
||||
public var messages = [String: Message]()
|
||||
|
||||
public init(channel: [String: Any]?) {
|
||||
id = channel?["id"] as? String
|
||||
name = channel?["name"] as? String
|
||||
created = channel?["created"] as? Int
|
||||
@@ -77,8 +76,8 @@ public struct Channel {
|
||||
latest = Message(ts: channel?["latest"] as? String)
|
||||
}
|
||||
}
|
||||
|
||||
internal init(id:String?) {
|
||||
|
||||
public init(id: String?) {
|
||||
self.id = id
|
||||
created = nil
|
||||
creator = nil
|
||||
Regular → Executable
+14
-14
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Comment.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
// Copyright © 2017 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
|
||||
@@ -22,30 +22,30 @@
|
||||
// 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]?) {
|
||||
public var created: Int?
|
||||
public var comment: String?
|
||||
public var starred: Bool?
|
||||
public var stars: Int?
|
||||
public var reactions = [Reaction]()
|
||||
|
||||
public init(comment: [String: Any]?) {
|
||||
self.comment = comment?["comment"] as? String
|
||||
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
|
||||
reactions = Reaction.reactionsFromArray(comment?["reactions"] as? [[String: Any]])
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
|
||||
public init(id: String?) {
|
||||
self.id = id
|
||||
self.user = nil
|
||||
}
|
||||
|
||||
public static func ==(lhs: Comment, rhs: Comment) -> Bool {
|
||||
|
||||
public static func == (lhs: Comment, rhs: Comment) -> Bool {
|
||||
return lhs.id == rhs.id
|
||||
}
|
||||
}
|
||||
Regular → Executable
+6
-7
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// CustomProfile.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
// Copyright © 2017 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
|
||||
@@ -22,10 +22,9 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
public struct CustomProfile {
|
||||
|
||||
internal(set) public var fields = [String: CustomProfileField]()
|
||||
|
||||
internal init(profile: [String: Any]?) {
|
||||
public var fields = [String: CustomProfileField]()
|
||||
|
||||
public init(profile: [String: Any]?) {
|
||||
if let eventFields = profile?["fields"] as? [Any] {
|
||||
for field in eventFields {
|
||||
var cpf: CustomProfileField?
|
||||
@@ -38,8 +37,8 @@ public struct CustomProfile {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal init(customFields: [String: Any]?) {
|
||||
|
||||
public init(customFields: [String: Any]?) {
|
||||
if let customFields = customFields {
|
||||
for key in customFields.keys {
|
||||
let cpf = CustomProfileField(field: customFields[key] as? [String: Any])
|
||||
Regular → Executable
+17
-18
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// CustomProfileField.swift
|
||||
//
|
||||
// Copyright © 2016 Peter Zignego. All rights reserved.
|
||||
// Copyright © 2017 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
|
||||
@@ -22,19 +22,18 @@
|
||||
// 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]?) {
|
||||
public var id: String?
|
||||
public var alt: String?
|
||||
public var value: String?
|
||||
public var hidden: Bool?
|
||||
public var hint: String?
|
||||
public var label: String?
|
||||
public var options: String?
|
||||
public var ordering: Int?
|
||||
public var possibleValues: [String]?
|
||||
public var type: String?
|
||||
|
||||
public init(field: [String: Any]?) {
|
||||
id = field?["id"] as? String
|
||||
alt = field?["alt"] as? String
|
||||
value = field?["value"] as? String
|
||||
@@ -46,12 +45,12 @@ public struct CustomProfileField {
|
||||
possibleValues = field?["possible_values"] as? [String]
|
||||
type = field?["type"] as? String
|
||||
}
|
||||
|
||||
internal init(id: String?) {
|
||||
|
||||
public init(id: String?) {
|
||||
self.id = id
|
||||
}
|
||||
|
||||
internal mutating func updateProfileField(_ profile: CustomProfileField?) {
|
||||
|
||||
public 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
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user