scrapinghub/slackbot is tracked by TopGit as an open-source project, with 1.3k stars on GitHub, written primarily in Python. A chat bot for Slack (https://slack.com).
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
A chat bot for Slack inspired by llimllib/limbo and will.
Features
Based on slack Real Time Messaging API
Simple plugins mechanism
Messages can be handled concurrently
Automatically reconnect to slack when connection is lost
Full-fledged functional tests
Installation
pip install slackbot
Usage
Generate the slack api token
First you need to get the slack api token for your bot. You have two options:
If you use a bot user integration of slack, you can get the api token on the integration page.
If you use a real slack user, you can generate an api token on slack web api page.
Configure the bot
First create a slackbot_settings.py and a run.py in your own instance of slackbot.
Configure the api token
Then you need to configure the API_TOKEN in a python module slackbot_settings.py, which must be located in a python import path. This will be automatically imported by the bot.
slackbot_settings.py:
API_TOKEN = "<your-api-token>"
Alternatively, you can use the environment variable SLACKBOT_API_TOKEN.
Run the bot
from slackbot.bot import Bot
def main():
bot = Bot()
bot.run()
if __name__ == "__main__":
main()
Configure the default answer
Add a DEFAULT_REPLY to slackbot_settings.py:
DEFAULT_REPLY = "Sorry but I didn't understand you"
Configure the docs answer
The message attribute passed to your custom plugins has an special function message.docs_reply() that will parse all the plugins available and return the Docs in each of them.
Send all tracebacks directly to a channel, private channel, or user
Set ERRORS_TO in slackbot_settings.py to the desired recipient. It can be any channel, private channel, or user. Note that the bot must already be in the channel. If a user is specified, ensure that they have sent at least one DM to the bot first.
A chat bot is meaningless unless you can extend/customize it to fit your own use cases.
To write a new plugin, simplely create a function decorated by slackbot.bot.respond_to or slackbot.bot.listen_to:
A function decorated with respond_to is called when a message matching the pattern is sent to the bot (direct message or @botname in a channel/private channel chat)
A function decorated with listen_to is called when a message matching the pattern is sent on a channel/private channel chat (not directly sent to the bot)
from slackbot.bot import respond_to
from slackbot.bot import listen_to
import re
@respond_to('hi', re.IGNORECASE)
def hi(message):
message.reply('I can understand hi or HI!')
# react with thumb up emoji
message.react('+1')
@respond_to('I love you')
def love(message):
message.reply('I love you too!')
@listen_to('Can someone help me?')
def help(message):
# Message is replied to the sender (prefixed with @user)
message.reply('Yes, I can!')
# Message is sent on the channel
message.send('I can help everybody!')
# Start a thread on the original message
message.reply("Here's a threaded reply", in_thread=True)
To extract params from the message, you can use regular expression:
from slackbot.bot import respond_to
@respond_to('Give me (.*)')
def giveme(message, something):
message.reply('Here is {}'.format(something))
If you would like to have a command like 'stats' and 'stats start_date end_date', you can create reg ex like so:
from slackbot.bot import respond_to
import re
@respond_to('stat$', re.IGNORECASE)
@respond_to('stat (.*) (.*)', re.IGNORECASE)
def stats(message, start_date=None, end_date=None):
And add the plugins module to PLUGINS list of slackbot settings, e.g. slackbot_settings.py:
Besides specifying DEFAULT_REPLY in slackbot_settings.py, you can also decorate a function with the @default_reply decorator to make it the default reply handler, which is more handy.
The above default handler would only handle the messages which must (1) match the specified pattern and (2) can't be handled by any other registered handler.
List of third party plugins
You can find a list of the available third party plugins on this page.
TopGit's last sync did not record any GitHub topics for scrapinghub/slackbot. GitHub topics appear in the right sidebar of a repository page; that's the authoritative place to check.
How active is development on scrapinghub/slackbot?
The most recent commit recorded on scrapinghub/slackbot was 3.7 years ago, based on the GitHub push timestamp. The repository has 385 forks — one of the better signals of community interest.
How many stars does scrapinghub/slackbot have?
scrapinghub/slackbot has 1.3k GitHub stars — refresh the page for the live number, or check github.com/scrapinghub/slackbot. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
What is scrapinghub/slackbot?
scrapinghub/slackbot (scrapinghub/slackbot) is a Python project on GitHub. From the project's own README: A chat bot for Slack (https://slack.com).
What language is scrapinghub/slackbot written in?
scrapinghub/slackbot is written primarily in Python. GitHub's language field is based on the largest share of bytes in the default branch.
Read full README in the tab above.
Curious whether slackbot is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about slackbot.