Code Monkey home page Code Monkey logo

skrtmapi's Introduction

SKRTMAPI has been consolidated into SlackKit

A module for connecting to the Slack Real Time Messaging API.

Installation

CocoaPods

Add SKRTMAPI to your pod file:

use_frameworks!
pod 'SKRTMAPI'

and run

# Use CocoaPods version >= 1.4.0
pod install

Carthage

Add SKRTMAPI to your Cartfile:

github "SlackKit/SKRTMAPI"

and run

carthage bootstrap

Drag the built SKRTMAPI.framework into your Xcode project.

Swift Package Manager

Add SKRTMAPI to your Package.swift

import PackageDescription
  
let package = Package(
	dependencies: [
		.package(url: "https://github.com/pvzig/SKRTMAPI.git", .upToNextMinor(from: "4.1.0"))
	]
)

Run swift build on your application’s main directory.

To use the library in your project import it:

import SKRTMAPI

Usage

Initialize an instance of SKRTMAPI with a Slack auth token:

let rtm = SKRTMAPI(token: "xoxb-SLACK_AUTH_TOKEN")
rtm.connect()

If your bot doesn't need any state information when you connect, pass false for the withInfo parameter:

let rtm = SKRTMAPI(token: "xoxb-SLACK_AUTH_TOKEN")
rtm.connect(withInfo: false)

Customize the connection with RTMOptions:

let options = RTMOptions(simpleLatest: false, noUnreads: false, mpimAware: true, pingInterval: 30, timeout: 300, reconnect: true)
let rtm = SKRTMAPI(token: "xoxb-SLACK_AUTH_TOKEN", options: options)
rtm.connect()

Provide your own web socket implementation by conforming to RTMWebSocket:

public protocol RTMWebSocket {
    init()
    var delegate: RTMDelegate? { get set }
    func connect(url: URL)
    func disconnect()
    func sendMessage(_ message: String) throws
}
let rtmWebSocket = YourRTMWebSocket()
let rtm = SKRTMAPI(token: "xoxb-SLACK_AUTH_TOKEN", rtm: rtmWebSocket)
rtm.connect()

skrtmapi's People

Contributors

jack-stripe avatar poissonballon avatar pvzig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.