Compare commits

..

82 Commits

Author SHA1 Message Date
Peter Zignego 6385afb34a Fix preprocessor macros 2019-02-19 23:28:05 -05:00
Peter Zignego b880356dde Don’t build for CocoaPods 2019-02-19 22:47:36 -05:00
Peter Zignego fdd2a5aa36 4.2.1 2019-02-19 22:19:23 -05:00
Peter Zignego 93f8da2f69 Merge pull request #146 from pvzig/podspec
Fix podspec
2019-02-19 22:01:10 -05:00
Peter Zignego a165f3e57f Fix podspec 2019-02-19 21:40:33 -05:00
Peter Zignego d7f2221d77 Merge pull request #145 from rectalogic/files
Message contains an array of "files", not a single "file".
2019-02-18 22:51:08 -05:00
Peter Zignego 02bda676a9 Merge pull request #144 from henry2423/master
Add support for Ephemeral message API
2019-02-18 22:50:11 -05:00
Peter Zignego e4bd44e939 Merge pull request #140 from RobotsAndPencils/support-multiple-files
Add support for multiple files in a single event
2019-02-16 13:51:30 -05:00
Andrew Wason d83fbb1d7e Message contains an array of "files", not a single "file". 2019-02-15 17:13:59 -05:00
Henry Huang c2734a66c3 [FIX] sendEphemeral function parameter 2019-02-15 15:07:56 -06:00
Henry Huang 721f8964cf [ADD] post Ephemeral message API function 2019-02-15 15:02:57 -06:00
Brandon Evans 37ca701ae0 Add support for multiple files in a single event
> The file attribute attached to messages is replaced with a new files field that includes an array of files in a different format instead.
https://api.slack.com/changelog/2018-05-file-threads-soon-tread
2019-02-15 13:59:30 -07:00
Peter Zignego c1a89eedda Merge pull request #141 from RobotsAndPencils/add-user-profile-status
Add users.profile.set endpoint
2019-02-15 13:45:55 -05:00
Brandon Evans 8aeb88cea3 Add users.profile.set endpoint
This isn't an ideal implementation because it's not clear from the documentation if sending everything in the URL for a JSON request is supported, but this does work when tested manually.

This isn't complete support for the endpoint. In particular, custom profile fields won't be set.

https://api.slack.com/methods/users.profile.set
2019-02-14 17:33:32 -07:00
Peter Zignego b776ef02a7 Update podspec 2019-02-11 14:46:28 -05:00
Peter Zignego 0befabb620 Remove SDKROOT (Carthage) 2019-02-10 20:09:45 -05:00
Peter Zignego 0edc193314 Simulator build fixes 2019-02-10 19:57:14 -05:00
Peter Zignego 806a72efec Update podspec 2019-02-10 19:03:05 -05:00
Peter Zignego ea02b850f5 Fix code signing build issues 2019-02-10 19:02:46 -05:00
Peter Zignego ec83087712 Merge pull request #139 from pvzig/monorepo
Switch back to a monorepo structure
2019-02-10 13:38:37 -05:00
Peter Zignego 798397b21c Update readme 2019-02-10 13:37:43 -05:00
Peter Zignego 5677a13372 Set deployment targets 2019-02-10 13:37:35 -05:00
Peter Zignego 581f1b94bd Trigger master 2019-02-10 13:31:00 -05:00
Peter Zignego dbd403739b Add examples 2019-02-10 13:28:49 -05:00
Peter Zignego e0af108b85 Merge pull request #138 from pvzig/azure-pipelines
Set up CI with Azure Pipelines
2019-01-31 23:27:52 -05:00
Peter Zignego efa95e34df Fix package 2019-01-31 23:22:41 -05:00
Peter Zignego 5232879f77 Merge branch 'monorepo' into azure-pipelines 2019-01-31 23:17:52 -05:00
azure-pipelines[bot] 7716a304c9 Set up CI with Azure Pipelines 2019-02-01 04:14:00 +00:00
Peter Zignego 7ca9bfbd0b Bring back linux 2019-01-31 23:11:38 -05:00
Peter Zignego f4afca3cab Linux fixes 2019-01-31 23:10:36 -05:00
Peter Zignego bcd33ab9e7 Update azure-pipelines.yml 2019-01-31 00:54:37 -05:00
Peter Zignego 96cb9e09e3 Testing out Azure Pipelines 2019-01-29 20:38:17 -05:00
Peter Zignego 9ac93890f4 All the great schemes 2019-01-28 20:45:27 -05:00
Peter Zignego ca232f8e8f Update .swift-version 2019-01-27 16:11:35 -05:00
Peter Zignego 9b859f0c99 Don’t check in package manager .resolved files 2019-01-27 16:10:37 -05:00
Peter Zignego 07e5b8636f Swift package 2019-01-27 16:09:05 -05:00
Peter Zignego 37b7b74914 Compiles 2019-01-27 16:08:53 -05:00
Peter Zignego 78c07974bf SKServer Swift 4.2 fix-it 2019-01-27 16:08:01 -05:00
Peter Zignego d44e04cd07 Clean up 2019-01-27 14:40:05 -05:00
Peter Zignego d8fffe738d Organize 2019-01-27 14:00:15 -05:00
Peter Zignego 239eb94093 monorepo 2019-01-27 11:57:06 -05:00
Peter Zignego c2f3731a69 Swift 4 2018-02-18 22:46:32 -05:00
Peter Zignego 48f80cc13d Merge pull request #121 from emorydunn/multispace
Multiple Workspace Support
2018-01-23 18:10:17 -05:00
Emory Dunn 0396d9c6d5 Add ClientConnection to Xcode 2018-01-22 14:44:46 -08:00
Emory Dunn 3514b637c8 Preserve compatibility with previous version
Add computed properties for `rtm` and `webAPI` that return the first client’s connections.
2017-12-28 22:45:10 -08:00
Emory Dunn 78ce839cc1 Move ClientConnection class to its own file 2017-12-28 22:36:38 -08:00
Emory Dunn 831bb20ff7 Add multiple client support
Add a new `ClientConnection` class to hold each client’s `Client`, RTM, and WebAPI connections.
2017-12-28 22:20:37 -08:00
Peter Zignego 43dda4a2f0 Update README.md 2017-07-14 16:51:39 -04:00
Peter Zignego 2f0978ccc4 majorVersion 4 2017-07-14 16:47:06 -04:00
Peter Zignego 71c5eda4a1 SwiftLint + gardening 2017-06-09 16:45:22 -04:00
Peter Zignego 4b241374ea Update README.md 2017-06-04 14:22:02 -04:00
Peter Zignego dd07b545c7 Merge branch '4.0'
# Conflicts:
#	Cartfile
#	Package.swift
#	Podfile
#	README.md
#	SlackKit.podspec
#	SlackKit.xcodeproj/project.pbxproj
#	Sources/SlackKit/Model/Message.swift
#	Sources/SlackKit/Model/User.swift
#	Sources/SlackKit/NetworkInterface.swift
#	Sources/SlackKit/WebAPI.swift
#	Supporting Files/Info.plist
2017-06-04 13:16:25 -04:00
Peter Zignego af4ba6623c Carthage support 2017-06-04 13:12:24 -04:00
Peter Zignego d8d22f6083 Update .swift-version 2017-06-03 18:02:24 -04:00
Peter Zignego 6fcfe2fda4 Update README.md 2017-06-02 23:08:38 -04:00
Peter Zignego 3ee4e0fd1d Update README.md 2017-05-26 13:28:23 -04:00
Peter Zignego 79457aa13d Merge pull request #90 from skagedal/master
Add support for status text and status emoji
2017-04-15 10:27:34 -04:00
Simon Kågedal Reimer ac2657b7e1 Add support for status text and status emoji 2017-04-14 21:02:54 +02:00
Peter Zignego 82130f2e67 Merge pull request #89 from johntmcintosh/threads
Add support for the `thread_ts` parameter used to indicate and track threaded conversations
2017-04-11 21:41:46 -04:00
John McIntosh b9573c4e8b Add support for the thread_ts parameter used to indicate and track threaded conversations 2017-04-11 09:57:39 -05:00
Peter Zignego 6481620e7a Bump podspec 2017-04-09 17:16:46 -04:00
Peter Zignego 35e7ead8d1 Merge branch 'master' of https://github.com/pvzig/SlackKit 2017-04-09 17:14:46 -04:00
Peter Zignego 0f896fdaee xcodeproj gardening 2017-04-09 17:14:36 -04:00
Peter Zignego 8a4fceaa00 Swift 3.1 gardening 2017-04-09 17:12:08 -04:00
Peter Zignego 6007f790db Update README.md 2017-04-09 17:10:53 -04:00
Peter Zignego 05e7f2baa3 Merge pull request #88 from Xiangxin/swift3.1
Swift 3.1 initial update
2017-04-09 16:51:31 -04:00
Xiangxin 39871172e9 Adapt swift 3.1 changes and fix warnings 2017-03-30 14:50:26 +08:00
Peter Zignego 491f80741b Update podspec 2017-03-19 19:32:39 -04:00
Peter Zignego 0eb9ea31e1 3.1.11 2017-03-19 19:11:16 -04:00
Peter Zignego 8865376c3c Merge branch 'master' of https://github.com/pvzig/SlackKit 2017-03-18 15:21:42 -04:00
Peter Zignego d86d0108ff Update podfile 2017-03-18 15:21:01 -04:00
Peter Zignego b45b7085ce Update Package.swift 2017-03-18 15:17:30 -04:00
Peter Zignego 91193c6b2e Update podspec 2017-03-18 14:07:58 -04:00
Peter Zignego 9720b1c05c Merge branch 'master' of https://github.com/pvzig/SlackKit 2017-03-18 12:20:55 -04:00
Peter Zignego 9766a5ad6c Bump version strings 2017-03-18 12:20:48 -04:00
Peter Zignego 1e181e7580 Update README.md 2017-03-18 12:07:10 -04:00
Peter Zignego f6d6c779ae Update dependencies 2017-03-18 11:14:56 -04:00
Peter Zignego 11bb50f8d2 Delete Podfile.lock 2017-03-13 11:56:05 -04:00
Peter Zignego d721e0ba1a Delete Cartfile.resolved 2017-03-13 11:55:54 -04:00
Peter Zignego ba6066875c Update Package.swift 2017-03-13 11:55:40 -04:00
Peter Zignego 0f1a1a9de5 Update Cartfile 2017-03-13 11:54:43 -04:00
Peter Zignego a81cebf5c8 Update Podfile 2017-03-13 11:54:05 -04:00
189 changed files with 11873 additions and 304 deletions
+2
View File
@@ -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
View File
@@ -1 +1 @@
3.1.1
4.2
+7
View File
@@ -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
+2
View File
@@ -0,0 +1,2 @@
github "daltoniam/Starscream" == 3.0.6
github "httpswift/swifter" == 1.4.5
+18
View File
@@ -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")
]
)
+191
View File
@@ -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
}
}
+8
View File
@@ -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()
+18
View File
@@ -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")
]
)
+135
View File
@@ -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.
@@ -0,0 +1,11 @@
framework module Starscream {
umbrella header "Starscream.h"
export *
module * { export * }
}
module Starscream.Swift {
header "Starscream-Swift.h"
requires objc
}
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.
@@ -0,0 +1,4 @@
framework module Swifter {
header "Swifter-Swift.h"
requires objc
}
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
Versions/Current/Headers
+1
View File
@@ -0,0 +1 @@
Versions/Current/Modules
+1
View File
@@ -0,0 +1 @@
Versions/Current/Resources
+1
View File
@@ -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>
@@ -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
+1
View File
@@ -0,0 +1 @@
Versions/Current/Headers
+1
View File
@@ -0,0 +1 @@
Versions/Current/Modules
+1
View File
@@ -0,0 +1 @@
Versions/Current/Resources
+1
View File
@@ -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>
@@ -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>
Binary file not shown.
+1
View File
@@ -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.
@@ -0,0 +1,11 @@
framework module Starscream {
umbrella header "Starscream.h"
export *
module * { export * }
}
module Starscream.Swift {
header "Starscream-Swift.h"
requires objc
}
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.
@@ -0,0 +1,4 @@
framework module Swifter {
header "Swifter-Swift.h"
requires objc
}
Binary file not shown.
+76 -7
View File
@@ -1,14 +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: [
Target(name: "SlackKit")
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"])
],
dependencies: [
.Package(url: "https://github.com/SlackKit/SKCore", "4.0.0"),
.Package(url: "https://github.com/SlackKit/SKClient", "4.0.0"),
.Package(url: "https://github.com/SlackKit/SKRTMAPI", "4.0.0"),
.Package(url: "https://github.com/SlackKit/SKServer", "4.0.0")
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
+15 -15
View File
@@ -2,27 +2,27 @@ use_frameworks!
target 'SlackKit macOS' do
platform :osx, '10.11'
pod 'SKCore'
pod 'SKClient'
pod 'SKWebAPI'
pod 'SKRTMAPI'
pod 'SKServer'
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'
pod 'SKClient'
pod 'SKWebAPI'
pod 'SKRTMAPI'
pod 'SKServer'
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'
pod 'SKClient'
pod 'SKWebAPI'
pod 'SKRTMAPI'
pod 'SKServer'
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
+11 -9
View File
@@ -1,6 +1,6 @@
<p align="center"><img src="https://cloud.githubusercontent.com/assets/8311605/24083714/e921a0d4-0cb2-11e7-8384-d42113ef5056.png" alt="SlackKit" width="500"/></p>
![Swift Version](https://img.shields.io/badge/Swift-3.1.1-orange.svg)
![Swift Version](https://img.shields.io/badge/Swift-4.2-orange.svg)
![Plaforms](https://img.shields.io/badge/Platforms-macOS,iOS,tvOS,Linux-lightgrey.svg)
![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
@@ -25,16 +25,17 @@ import PackageDescription
let package = Package(
dependencies: [
.Package(url: "https://github.com/SlackKit/SlackKit.git", "4.0.0")
.package(url: "https://github.com/SlackKit/SlackKit.git", .upToNextMinor(from: "4.2.0"))
]
)
```
#### Carthage
Add `SlackKit` to your `Cartfile`:
```
github "SlackKit/SlackKit"
github "pvzig/SlackKit"
```
#### CocoaPods
@@ -189,15 +190,16 @@ Dont need the whole banana? Want more control over the low-level implementati
| Module | Slack Service |
| ------------- |------------- |
| **[SKClient](https://github.com/SlackKit/SKClient)** | Write your own client implementation|
| **[SKRTMAPI](https://github.com/SlackKit/SKRTMAPI)** | Connect to the Slack RTM API|
| **[SKServer](https://github.com/SlackKit/SKServer)** | Spin up a server|
| **[SKWebAPI](https://github.com/SlackKit/SKWebAPI)** | Access the Slack Web API|
| **[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
You can find the source code for several example applications [here](https://github.com/SlackKit/Examples).
You can find the source code for several example applications [here](https://github.com/pvzig/SlackKit/tree/master/Examples).
### Tutorials
Coming soon!
- [Build a Slack Bot and Deploy to Heroku](https://medium.com/@pvzig/building-slack-bots-in-swift-b99e243e444c)
### Get In Touch
Twitter: [@pvzig](https://twitter.com/pvzig)
+86
View File
@@ -0,0 +1,86 @@
# SKClient: SlackKit Client Module
![Swift Version](https://img.shields.io/badge/Swift-4.0.3-orange.svg)
![Plaforms](https://img.shields.io/badge/Platforms-macOS,iOS,tvOS,Linux-lightgrey.svg)
![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage)
[![CocoaPods compatible](https://img.shields.io/badge/CocoaPods-compatible-brightgreen.svg)](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 applications 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())
```
+879
View File
@@ -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)
}
}
}
}
}
+9
View File
@@ -0,0 +1,9 @@
# SKCore: SlackKit Models
![Swift Version](https://img.shields.io/badge/Swift-4.0.3-orange.svg)
![Plaforms](https://img.shields.io/badge/Platforms-macOS,iOS,tvOS,Linux-lightgrey.svg)
![License MIT](https://img.shields.io/badge/License-MIT-lightgrey.svg)
[![SwiftPM compatible](https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-brightgreen.svg)](https://github.com/Carthage/Carthage)
[![CocoaPods compatible](https://img.shields.io/badge/CocoaPods-compatible-brightgreen.svg)](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).
+142
View File
@@ -0,0 +1,142 @@
//
// Action.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.
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?
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, 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
}
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?
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
}
public var dictionary: [String: Any] {
var dict = [String: Any]()
dict["title"] = title
dict["text"] = text
dict["ok_text"] = okText
dict["dismiss_text"] = dismissText
return dict
}
}
public 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 defaultStyle = "default"
case primary = "primary"
case danger = "danger"
}
public enum MessageResponseType: String {
case inChannel = "in_channel"
case ephemeral = "ephemeral"
}
+146
View File
@@ -0,0 +1,146 @@
//
// Attachment.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.
public struct Attachment {
public let fallback: String?
public let callbackID: String?
public let type: String?
public let color: String?
public let pretext: String?
public let authorName: String?
public let authorLink: String?
public let authorIcon: String?
public let title: String?
public let titleLink: String?
public let text: String?
public let fields: [AttachmentField]?
public let actions: [Action]?
public let imageURL: String?
public let thumbURL: String?
public let footer: String?
public let footerIcon: String?
public let ts: Int?
public let markdownEnabledFields: Set<AttachmentTextField>?
public init(attachment: [String: Any]?) {
fallback = attachment?["fallback"] as? String
callbackID = attachment?["callback_id"] as? String
type = attachment?["attachment_type"] as? String
color = attachment?["color"] as? String
pretext = attachment?["pretext"] as? String
authorName = attachment?["author_name"] as? String
authorLink = attachment?["author_link"] as? String
authorIcon = attachment?["author_icon"] as? String
title = attachment?["title"] as? String
titleLink = attachment?["title_link"] as? String
text = attachment?["text"] as? String
imageURL = attachment?["image_url"] as? String
thumbURL = attachment?["thumb_url"] as? String
footer = attachment?["footer"] as? String
footerIcon = attachment?["footer_icon"] as? String
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,
markdownFields: Set<AttachmentTextField>? = nil
) {
self.fallback = fallback
self.callbackID = callbackID
self.type = type
self.color = colorHex
self.pretext = pretext
self.authorName = authorName
self.authorLink = authorLink
self.authorIcon = authorIcon
self.title = title
self.titleLink = titleLink
self.text = text
self.fields = fields
self.actions = actions
self.imageURL = imageURL
self.thumbURL = thumbURL
self.footer = footer
self.footerIcon = footerIcon
self.ts = ts
self.markdownEnabledFields = markdownFields
}
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["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["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, 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"
}
+48
View File
@@ -0,0 +1,48 @@
//
// AttachmentField.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.
public struct AttachmentField {
public let title: String?
public let value: String?
public let short: Bool?
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) {
self.title = title
self.value = value
self.short = short
}
public var dictionary: [String: Any] {
var field = [String: Any]()
field["title"] = title
field["value"] = value
field["short"] = short
return field
}
}
+40
View File
@@ -0,0 +1,40 @@
//
// Bot.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.
public struct Bot {
public let id: String?
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]
}
public init(botUser: [String: Any]?) {
id = botUser?["bot_user_id"] as? String
botToken = botUser?["bot_access_token"] as? String
}
}
+88
View File
@@ -0,0 +1,88 @@
//
// Channel.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.
public struct Channel {
public let id: String?
public let created: Int?
public let creator: String?
public var name: String?
public var isArchived: Bool?
public var isGeneral: Bool?
public let isGroup: Bool?
public let isIM: Bool?
public let isMPIM: 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?
public var latest: Message?
public var unread: Int?
public var unreadCountDisplay: Int?
public var hasPins: Bool?
public var members: [String]?
// Client use
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
creator = channel?["creator"] as? String
isArchived = channel?["is_archived"] as? Bool
isGeneral = channel?["is_general"] as? Bool
isGroup = channel?["is_group"] as? Bool
isIM = channel?["is_im"] as? Bool
isMPIM = channel?["is_mpim"] as? Bool
isUserDeleted = channel?["is_user_deleted"] as? Bool
user = channel?["user"] as? String
isOpen = channel?["is_open"] as? Bool
topic = Topic(topic: channel?["topic"] as? [String: Any])
purpose = Topic(topic: channel?["purpose"] as? [String: Any])
isMember = channel?["is_member"] as? Bool
lastRead = channel?["last_read"] as? String
unread = channel?["unread_count"] as? Int
unreadCountDisplay = channel?["unread_count_display"] as? Int
hasPins = channel?["has_pins"] as? Bool
members = channel?["members"] as? [String]
if let latestMesssageDictionary = channel?["latest"] as? [String: Any] {
latest = Message(dictionary: latestMesssageDictionary)
} else {
latest = Message(ts: channel?["latest"] as? String)
}
}
public init(id: String?) {
self.id = id
created = nil
creator = nil
isGroup = false
isIM = false
isMPIM = false
}
}
+51
View File
@@ -0,0 +1,51 @@
//
// Comment.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.
public struct Comment: Equatable {
public let id: String?
public let user: String?
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
reactions = Reaction.reactionsFromArray(comment?["reactions"] as? [[String: Any]])
}
public init(id: String?) {
self.id = id
self.user = nil
}
public static func == (lhs: Comment, rhs: Comment) -> Bool {
return lhs.id == rhs.id
}
}
+49
View File
@@ -0,0 +1,49 @@
//
// CustomProfile.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.
public struct CustomProfile {
public var fields = [String: CustomProfileField]()
public init(profile: [String: Any]?) {
if let eventFields = profile?["fields"] as? [Any] {
for field in eventFields {
var cpf: CustomProfileField?
if let fieldDictionary = field as? [String: Any] {
cpf = CustomProfileField(field: fieldDictionary)
} else {
cpf = CustomProfileField(id: field as? String)
}
if let id = cpf?.id { fields[id] = cpf }
}
}
}
public init(customFields: [String: Any]?) {
if let customFields = customFields {
for key in customFields.keys {
let cpf = CustomProfileField(field: customFields[key] as? [String: Any])
self.fields[key] = cpf
}
}
}
}
+65
View File
@@ -0,0 +1,65 @@
//
// CustomProfileField.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.
public struct CustomProfileField {
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
hidden = field?["is_hidden"] as? Bool
hint = field?["hint"] as? String
label = field?["label"] as? String
options = field?["options"] as? String
ordering = field?["ordering"] as? Int
possibleValues = field?["possible_values"] as? [String]
type = field?["type"] as? String
}
public init(id: String?) {
self.id = id
}
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
hidden = profile?.hidden != nil ? profile?.hidden : hidden
hint = profile?.hint != nil ? profile?.hint : hint
label = profile?.label != nil ? profile?.label : label
options = profile?.options != nil ? profile?.options : options
ordering = profile?.ordering != nil ? profile?.ordering : ordering
possibleValues = profile?.possibleValues != nil ? profile?.possibleValues : possibleValues
type = profile?.type != nil ? profile?.type : type
}
}
+38
View File
@@ -0,0 +1,38 @@
//
// DoNotDisturbStatus.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.
public struct DoNotDisturbStatus {
public var enabled: Bool?
public var nextDoNotDisturbStart: Int?
public var nextDoNotDisturbEnd: Int?
public var snoozeEnabled: Bool?
public var snoozeEndtime: Int?
public init(status: [String: Any]?) {
enabled = status?["dnd_enabled"] as? Bool
nextDoNotDisturbStart = status?["next_dnd_start_ts"] as? Int
nextDoNotDisturbEnd = status?["next_dnd_end_ts"] as? Int
snoozeEnabled = status?["snooze_enabled"] as? Bool
snoozeEndtime = status?["snooze_endtime"] as? Int
}
}
+32
View File
@@ -0,0 +1,32 @@
//
// Edited.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.
public struct Edited {
public let user: String?
public let ts: String?
public init(edited: [String: Any]?) {
user = edited?["user"] as? String
ts = edited?["ts"] as? String
}
}

Some files were not shown because too many files have changed in this diff Show More