Add lita-slack to your Lita instance's Gemfile:
token(String) – The bot's Slack API token. Create a bot and get its token at https://my.slack.com/services/new/lita.
link_names(Boolean) – Set to
trueto turn all Slack usernames in messages sent by Lita into links.
parse(String) – Specify the parsing mode. See https://api.slack.com/docs/formatting#parsing_modes.
proxy(String) – Specify a HTTP proxy URL. (e.g. "http://squid.example.com:3128")
unfurl_links(Boolean) – Set to
trueto automatically add previews for all links in messages sent by Lita.
unfurl_media(Boolean) – Set to
falseto prevent automatic previews for media files in messages sent by Lita.
Note: When using lita-slack, the adapter will overwrite the bot's name and mention name with the values set on the server, so
config.robot.mention_name will have no effect.
Each Slack user has a unique ID that never changes even if their real name or username changes. To populate the
config.robot.admins attribute, you'll need to use these IDs for each user you want to mark as an administrator. If you're using Lita version 4.1 or greater, you can get a user's ID by sending Lita the command
users find NICKNAME_OF_USER.
Lita.configure do |config| config.robot.adapter = :slack config.robot.admins = ["U012A3BCD"] config.adapters.slack.token = "abcd-1234567890-hWYd21AmMH2UHAkx29vb5c1Y" config.adapters.slack. = true config.adapters.slack.parse = "full" config.adapters.slack. = false config.adapters.slack.unfurl_media = false end
Lita will join your default channel after initial setup. To have it join additional channels or private groups, simply invite it to them via your Slack client as you would any normal user.
:connected- When the robot has connected to Slack. No payload.
:disconnected- When the robot has disconnected from Slack. No payload.
:slack_channel_created- When the robot creates/updates a channel's or group's info, as directed by Slack. The payload has a single object, a
Lita::Slack::Adapters::SlackChannelobject, under the
:slack_reaction_added- When a reaction has been added to a previous message. The payload includes
Lita::Userfor the sender of the message in question),
:name(the string name of the reaction added),
Lita::Userfor the user that created the original item that has been reacted to),
:item(a hash of raw data from Slack about the message), and
:event_ts(a string timestamp used to identify the message).
:slack_reaction_removed- When a reaction has been removed from a previous message. The payload is the same as the
:slack_user_created- When the robot creates/updates a user's info - name, mention name, etc., as directed by Slack. The payload has a single object, a
Lita::Slack::Adapters::SlackUserobject, under the
Chat service API
lita-slack supports Lita 4.6's chat service API for Slack-specific functionality. You can access this API object by calling the
Lita::Robot#chat_service. See the API docs for
Lita::Adapters::Slack::ChatService for details about the provided methods.
The API documentation, useful for plugin authors, can be found for the latest gem release on RubyDoc.info