class Slack

Overview

Handles connecting and starting Slack websocket session and delegates slack events.

require "../src/slack.cr"
slack = Slack.new(token: ENV["SLACK_TOKEN"])

slack.on(Slack::Event::UserTyping) do |session, event|
  puts "someone is typing 2"
end

slack.run

Defined in:

slack.cr
slack/event.cr
slack/events/hello.cr
slack/events/message.cr
slack/events/message/pinned_item.cr
slack/events/presence_change.cr
slack/events/reaction_added.cr
slack/events/ready.cr
slack/events/reconnect_url.cr
slack/events/star_added.cr
slack/events/unimplemented.cr
slack/events/user_change.cr
slack/events/user_typing.cr
slack/message.cr
slack/user.cr
slack/user/profile.cr
slack/users.cr
slack/util.cr:1
slack/util.cr:31
slack/version.cr

Constant Summary

VERSION = "0.1.0"

Constructors

Instance Method Summary

Constructor Detail

def self.new(token : String) #

[View source]

Instance Method Detail

def channels : Hash(String, Slack::Channel) #

Channels in current Slack session.


[View source]
def channels=(channels : Hash(String, Slack::Channel)) #

Channels in current Slack session.


[View source]
def close #

Close the websocket connection


[View source]
def config #

[View source]
def config=(config) #

[View source]
def debug : Bool #

[View source]
def debug=(debug : Bool) #

[View source]
def me : User | Nil #

Returns me, as the current slack user.


[View source]
def me=(me : User | Nil) #

Returns me, as the current slack user.


[View source]
def on(event : Slack::Event.class, &cb : Slack, Slack::Event -> ) #

Binds a callback to event. Allows multiple bindings to event, and will be called in order of binding


[View source]
def prefs : JSON::Any | Nil #

Preferences


[View source]
def prefs=(prefs : JSON::Any | Nil) #

Preferences


[View source]
def run #

Start Slack RTM event loop


[View source]
def send(msg : String, to channel : String) #

Send a message to slack


[View source]
def send(msg : Slack::Message) #

Send a message to slack


[View source]
def socket : HTTP::WebSocket | Nil #

Websocket connection.


[View source]
def socket=(socket : HTTP::WebSocket | Nil) #

Websocket connection.


[View source]
def users : Slack::Users #

List of users in current Slack.


[View source]
def users=(users : Slack::Users) #

List of users in current Slack.


[View source]
def wss : String | Nil #

[View source]
def wss=(wss : String | Nil) #

[View source]