Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dougeverly/slack.cr
Slack Real Time Messaging API in Crystal
https://github.com/dougeverly/slack.cr
crystal slack
Last synced: 6 days ago
JSON representation
Slack Real Time Messaging API in Crystal
- Host: GitHub
- URL: https://github.com/dougeverly/slack.cr
- Owner: DougEverly
- License: mit
- Created: 2016-09-01T23:24:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-06-05T13:19:51.000Z (over 4 years ago)
- Last Synced: 2024-08-03T17:15:31.373Z (3 months ago)
- Topics: crystal, slack
- Language: Crystal
- Size: 33.2 KB
- Stars: 17
- Watchers: 5
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Slack Real Time API client written in Crystal
[![Build Status](https://travis-ci.com/DougEverly/slack.cr.svg?branch=master)](https://travis-ci.com/DougEverly/slack.cr)
Client to Slack's [Real Time API](https://api.slack.com/rtm) written in Crystal and using WebSockets.
Still early in development.
## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
slack:
github: DougEverly/slack.cr
```## Usage
```crystal
require "slack"
```
## SamplesLook in `samples` directory for example usage.
## Example
```crystal
require "../src/slack.cr"
slack = Slack.new(token: ENV["SLACK_TOKEN"])slack.on(Slack::Event::Message) do |session, event|
if event = event.as?(Slack::Event::Message)
if session.me.as?(User)
puts "Here as User! #{event.class.to_s} #{event.test}"
if event.mentions(session.me)
x = event.reply(text: "oh hi there")
session.send x
endif event.mentions("good morning", "good evening")
if event.mentions(session.me)
x = event.reply(text: "<@#{event.user}>: to you too!")
else
x = event.reply(text: "thank you!")
end
session.send x
end
end
end
endslack.on(Slack::Event::UserTyping) do |session, event|
puts "someone is typing"
endslack.on(Slack::Event::StarAdded) do |session, event|
puts "starred"
endslack.on(Slack::Event::PinAdded) do |session, event|
puts "pin added"
endslack.on(Slack::Reconnect) do |session, event|
puts "pin added"
endslack.start
```
## Contributing
1. Fork it ( https://github.com/DougEverly/slack/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request## Contributors
- [DougEverly](https://github.com/DougEverly) - creator, maintainer