A set of Frameworks for interacting with Slack APIs and building bots in Swift on OSX and Heroku
Chameleon provides frameworks for:
- Web API
- Real time messaging API
- Bot: Uses Web/RTM and provides an API for custom services (i.e. karma)
Using Chameleon you are able to interact with these an a type-safe manner.
You need Swift 3 installed to use or contribute to Chameleon, I recommend using swiftenv.
swiftenv install DEVELOPMENT-SNAPSHOT-2016-05-09-a
swiftenv global DEVELOPMENT-SNAPSHOT-2016-05-09-a
This will install the snapshot and set it as the default installation of Swift 3.
You will need to configure a new bot user for your team. Copy the token, you will need it.
If you plan to run a bot on Heroku you will need a Heroku account (free is fine!) and also have the Heroku Toolbelt installed.
- Download the latest Chameleon source and extract it
- Open a terminal window and go to the directory containing
Package.swift
- Type
swift build
- Type
.build/debug/app --token="<your-bot-token>"
- Go into a default channel in your slack and say "hey @yourBot" - it should respond.
- Download the latest Chameleon source and extract it
- Open a terminal window and go to the directory containing
Package.swift
- Using the Heroku CLI login and create a new app.
- Set the buildpack
heroku buildpacks:set https://github.com/oarrabi/heroku-buildpack-swift
- Create a file called
Procfile
and add the text:worker: App --token="<your-bot-token>"
- Deploy to Heroku by typing:
git add .
git commit -am 'depoy to heroku'
git push heroku master
- Once that has completed type:
heroku ps:scale worker=1
- Go into a default channel in your slack and say "hey @yourBot" - it should respond.
This is a work in progress so expect improvements as well as breaking changes!
Chameleon is functional however there is still a lot to do before it is complete
- Currently the 'persistence layer' is memory :(
- The Web and Real time messaging APIs can do a lot - I have built support for the core/most common features but they are incomplete. I will add more over time until they are complete.
- Once stable and the API is 'firmer' the individual frameworks will be broken out. They all live here for now for ease of development, however, separation should be considered when contributing.
#Acknowledgement This was my first dive into 'Server Side Swift'; 95% of this code was done over a total of a few days but getting working in the terminal and then deployed to Heroku took far longer... This project would likely have ended up as mostly useless OSX app if it hadn't been for the teams from Vapor and Zewo pioneering the server side Swift movement. I am especially thankful for the help and patience of Logan Wright, Tanner Nelson and Dan Appel
Feel free to open an issue or PR, if you wanna chat you can find me on Twitter (@IanKay) or on iOS Developers