MCPcopy Index your code
hub / github.com/Itiviti/simple-slack-api

github.com/Itiviti/simple-slack-api @1.4.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.4.0 ↗ · + Follow
994 symbols 2,503 edges 164 files 49 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Build Status GitHub release Coverage Status Join the chat at https://gitter.im/Ullink/simple-slack-api

Simple Slack API

This library allows an application to connect to Slack to receive and send messages from any channel as if it were a slack client.

The main purpose of this library is to build Slack bots able to react to channel events without having to configure any web hook.

With this library you should be able to connect to Slack and to send some messages in less than 20 lines (no one-liners).

Maven/Gradle

You can add this library as a dependency to your Maven or Gradle project through JitPack.

Released versions are also availables on the maven central repository :

  • group id: com.ullink.slack
  • artifact id: simpleslackapi

How to use it ?

You can find some samples of the most common use cases in the samples folder.

Sample code

SlackSession session = SlackSessionFactory.createWebSocketSlackSession("slack-bot-auth-token");
session.connect();
SlackChannel channel = session.findChannelByName("general"); //make sure bot is a member of the channel.
session.sendMessage(channel, "hi im a bot" );

Features

Supported Slack commands

All these commands can be sent through the library provided your bot has the rights to (IE : the bot has to be a member of the group or the channel to post some messages on it)

  • Post a message on a channel / private group / user
  • Post a typing indicator on a channel
  • Update a message
  • Delete a message
  • Join a channel
  • Leave a channel / a private group
  • Invite to a channel / a private group
  • Archive a channel
  • Open a direct message channel (since v0.5.0)
  • Open a multiparty direct message channel (since v0.5.0)
  • Get the presence status of a user
  • Add a reaction emoji to a message
  • Fetch the channel history (since v0.5.0) (needs full user credentials)
  • Invite a user to Slack (since v0.5.0)

On top of these built-in features, it is now possible to send not yet implemented API calls by using the postGenericSlackCommand method :

postGenericSlackCommand(Map<String, String> params, String command);

Supported Slack events

All these events can be listen provided your bot has the rights to (IE : the bot has to be a member of the group or a channel to gets the message events related to it)

  • message posted event
  • message deleted event
  • message updated event
  • channel created event
  • channel / private group deleted event
  • channel / private group archived event
  • channel / private group unarchived event
  • channel / private group renamed event
  • channel / private group joined event
  • reaction added to message event (since v0.5.0)
  • reaction removed from message event (since v0.5.0)
  • team joined event

Attention

From version 1.4.0 upward, channel members are not loaded in memory anymore in order for the api to start up faster. This should have no impact on the current behavior.

Thanks

Many thanks to everyone who has contributed to this library :

  • Christian Sprecher
  • Jan Vidar Krey
  • David Seebacher
  • Wouter Vernaillen
  • Claudio Comandini
  • Maxim Gurkin
  • Ole Kozaczenko
  • Georges Gomes
  • François Valdy
  • Harry Fox
  • Logan Clément
  • Rhys Kenwell
  • Aman Gupta
  • Miklos Sagi
  • Nathalie Mahe
  • Sebastien Lelouvier
  • Nicolas Haquet

(Let me know if I forgot someone, I'll fix that ASAP ;) )

License

This library is licensed under the Creative Commons CC0 1.0 Universal license with no warranty (expressed or implied) for any purpose.

Extension points exported contracts — how you extend this code

ModalElement (Interface)
(no doc) [6 implementers]
sources/src/main/java/com/ullink/slack/simpleslackapi/blocks/ModalElement.java
MessageElement (Interface)
(no doc) [6 implementers]
sources/src/main/java/com/ullink/slack/simpleslackapi/blocks/MessageElement.java
SectionElement (Interface)
(no doc) [16 implementers]
sources/src/main/java/com/ullink/slack/simpleslackapi/blocks/actions/SectionElement.java
ActionsElement (Interface)
(no doc) [10 implementers]
sources/src/main/java/com/ullink/slack/simpleslackapi/blocks/actions/ActionsElement.java
SlackEvent (Interface)
(no doc) [42 implementers]
sources/src/main/java/com/ullink/slack/simpleslackapi/events/SlackEvent.java

Core symbols most depended-on inside this repo

getStringOrNull
called by 115
sources/src/main/java/com/ullink/slack/simpleslackapi/impl/GsonHelper.java
build
called by 87
sources/src/main/java/com/ullink/slack/simpleslackapi/impl/SlackSessionFactory.java
getId
called by 74
sources/src/main/java/com/ullink/slack/simpleslackapi/SlackPersona.java
findChannelById
called by 50
sources/src/main/java/com/ullink/slack/simpleslackapi/SlackSession.java
getSlackChannel
called by 24
sources/src/main/java/com/ullink/slack/simpleslackapi/replies/SlackChannelReply.java
findUserByUserName
called by 22
sources/src/main/java/com/ullink/slack/simpleslackapi/SlackSession.java
getNextMessageId
called by 22
sources/src/main/java/com/ullink/slack/simpleslackapi/impl/SlackWebSocketSessionImpl.java
sendMessage
called by 21
sources/src/main/java/com/ullink/slack/simpleslackapi/SlackSession.java

Shape

Method 813
Class 119
Interface 50
Enum 12

Languages

Java100%

Modules by API surface

sources/src/main/java/com/ullink/slack/simpleslackapi/SlackSessionWrapper.java86 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/SlackSession.java85 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/impl/SlackWebSocketSessionImpl.java62 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/impl/AbstractSlackSessionImpl.java58 symbols
sources/src/test/java/com/ullink/slack/simpleslackapi/impl/TestSlackJSONMessageParser.java47 symbols
sources/src/test/java/com/ullink/slack/simpleslackapi/impl/TestAbstractSlackSessionImpl.java45 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/SlackAttachment.java41 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/SlackFile.java39 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/impl/SlackJSONMessageParser.java33 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/SlackAction.java24 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/impl/SlackIntegrationUser.java23 symbols
sources/src/main/java/com/ullink/slack/simpleslackapi/events/SlackMessagePosted.java23 symbols

For agents

$ claude mcp add simple-slack-api \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact