Slack.State
A struct for holding the state of a Slack RTM session using Agents as simple wrappers around holding users and channels. For example, you could fetch all channels from an existing state struct:
Slack.State.channels(state) # %{"1": %{id: 1, name: "Foo"}}
You can also manually update the list of channels:
Slack.State.update_channels(state, [%{id: 2, name: "bar"}])
Slack.State.channels(state) # %{"1": %{id: 1, name: "Foo"}, "2": %{id: 2, name: "bar"}}
You also have access to who you’re currently logged in as through the me
field.
Summary↑
channels(state) | Retreive all channels from the state |
update_channels(state, channels) | Takes a state and a list of channels and adds the channels to the map of stored channels |
update_users(state, users) | Takes a state and a list of users and adds the users to the map of stored users |
users(state) | Retreive all users from the state |
Types ↑
state :: %Slack.State{socket: :websocket_req, channels: pid, me: Map, users: pid}
Functions
Retreive all channels from the state
Takes a state and a list of channels and adds the channels to the map of stored channels.
Takes a state and a list of users and adds the users to the map of stored users.
Retreive all users from the state