Slackbot utilizes Swift with Vapor framework to build an swift executable that allows you to customize response of your slackbot by simply setting bot token and adding a few lines of Swift codes.
Feel free to open any issue or pull request.
- Swift: 3.0
- Vapor: 0.14
It is recommended to use swiftenv to manage the Swift version.
$ git clone https://github.com/popodidi/Slackbot
$ swift package generate-xcodeproj
$ open Slackbot.xcodeproj
Create a bot to get token if you don't have one.
Set it up in /Sources/Config.swift
import Foundation
struct Slack {
struct Config {
// set your bot token here
static let BotToken = "----Your Bot Token----"
static let SimpleLatest = true
static let NoUnreads = true
}
}
$ brew install openssl
$ brew link openssl -f
$ swift build
$ .build/debug/Slackbot
Choose Slackbot scheme and press Run button
Check out /Sources/MyResponseHandler
and follow the instructions written in comments to override the functions.
For example, if you want to respond to a specific message, "how are you?".
override func response(toMessage text: String) -> String?{
if text == "how are you?"{
return "I'm good"
}else{
// return nil for no response
return nil
}
}
Slackbot is freely distributable under the terms of the MIT license.