Skip to main content

A bot for Slack

Project description

PyBites Karmabot - A Python based Slack Chatbot

Tests Black pre-commit BCH compliance codecov

A Python based Slack Chatbot for Community interaction

Features

Karmabot's main features is the management of Karma within the slack community server. You can give karma, reduce karma, check your current karma points and manage your karma related username.

karma example

https://www.youtube.com/watch?v=Yx9qYl6lmzM&t=2s

Additional commands / features are:

  • Jokes powered by PyJokes
  • Overview on top channels of the slack server
  • Random Python tip, quote or nugget from CodeChalleng.es
  • Browse and search python documentation, "pydoc help"

Installation

pip install karmabot

Basic Usage

After installing you can start karmabot by using the command

karmabot

However, you need to supply some settings prior to this.

Settings

By default we will look for a .karmabot file in the directory you used the karmabot command. The file should supply the following information.

KARMABOT_SLACK_USER=
KARMABOT_SLACK_TOKEN=
KARMABOT_SLACK_INVITE_USER_TOKEN=
KARMABOT_DATABASE_URL=
KARMABOT_GENERAL_CHANNEL=
KARMABOT_ADMINS=
  • KARMABOT_SLACK_USER The bot's slack user id.

  • KARMABOT_SLACK_TOKEN The auth toke for your bot

  • KARMABOT_SLACK_INVITE_USER_TOKEN An invite token to invite the bot to new channels. Bots cannot autojoin channels, but we implemented an invite procedure for this.

  • KARMABOT_DATABASE_URL The database url which should be compatible with SqlAlchemy. For the provided docker file use postgres://user42:pw42@localhost:5432/karmabot

  • KARMABOT_GENERAL_CHANNEL The channel id of your main channel slack

  • KARMABOT_ADMINS The slack user ids of the users that should have admin command access separated by commas.

If you do not want to use a file you have to provide environment variables with the above names. If no file is present we default to environment variables.

Development pattern for contributors

We use poetry and pyproject.toml for managing packages, dependencies and some settings.

Setup virtual environment for development

You should follow the instructions to get poetry up and running for your system. We recommend to use a UNIX-based development system (Linux, Mac, WSL). After setting up poetry you can use poetry install within the project folder to install all dependencies.

The poetry virtual environment should be available in the the project folder as .venv folder as specified in poetry.toml. This helps with .venv detection in IDEs.

Testing and linting

For testing you need to install nox separately from the project venv created by poetry. For testing just use the nox command within the project folder. You can run all the nox sessions separately if need, e.g.,

  • only linting nox -rs lint
  • only testing nox -rs test

For different sessions see the nox.py file. Please make sure all tests and checks pass before opening pull requests!

pre-commit

To ensure consistency you can use pre-commit. pip install pre-commit and after cloning the karmabot repo run pre-commit install within the project folder.

This will enable pre-commit hooks for checking before every commit.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

karmabot-1.1.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

karmabot-1.1-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file karmabot-1.1.tar.gz.

File metadata

  • Download URL: karmabot-1.1.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.4

File hashes

Hashes for karmabot-1.1.tar.gz
Algorithm Hash digest
SHA256 6f70c5056b92dd9f0016ac3e1d566bca6ae1c203ff8e0e07be86cd35fae83c81
MD5 baff8db639408bb302e47a139ba6b8e3
BLAKE2b-256 214cc4d481d8bc59e96627c8c71488d79a27b49b1559f6c638d6350e9dd7d1d4

See more details on using hashes here.

File details

Details for the file karmabot-1.1-py3-none-any.whl.

File metadata

  • Download URL: karmabot-1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.4

File hashes

Hashes for karmabot-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b16411b82bc93c153600e9950e519db506babc7dd555dc25c773d6330ac2b1b8
MD5 2dacf69e9e372dc45efd262a6b489517
BLAKE2b-256 5af677cca94788b27fea87e3587fcb6002cdd39638ddab649776f63b59aa976e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page