Skip to main content

Officially supported Keybase python bot client library

Project description

This is the officially support Keybase Python library. It is an unopinionated, simple wrapper around the Keybase CLI API for creating an interactive bot or general scripting. This library does not attempt to do intent parsing or manage state at all. You'll have to build that yourself, but with the examples, this library will hopefully make whatever you want to build much much easier :).

See https://github.com/keybase/keybase-bot for a similar framework in Javascript.

This library is very far from exhaustively covering the complete Keybase API, but it is our hope that it will be easy to add to (see chat_client.py for the pattern). It currently does reading from channels and writing messages/reactions pretty well. That's enough for the vast majority of basic functionality. Future work can add teams behavior, more wallet functionality (e.g. sending money), ...

Installation

pip install pykeybasebot

Python 3.7 or greater, please. And it's all async, so you'll need to call into it with that in mind.

Setup

Generally speaking, here's what you need to do:

  1. Create a handler function that takes event objects and does something with them. This function will get called with your bot instance (described below) and the KbEvent instance.
  2. Create a bot. You must initialize this with the username of the running keybase user and the handler function to call with each event. You may optionally pass in: (1) the event loop that you want new tasks to be sent to (this is necessary if you want to lock on async behavior -- see the examples), (2) the location of the running keybase app (defaults to keybase which is fine if it's in your PATH), your user's home directory, or pid_file. These three are more useful for complicated local development with multiple accounts and less useful if you're running in a docker container or as the only user on your system.
  3. If you are not already running on a logged-in device, you need to do that. We recommend doing this with the oneshot command. It's in the examples.
  4. start the bot inside the asyncio event loop. This bot command wraps keybase chat api-listen, (and it takes basically the same exact options) and fires off events to your handler function.

Examples

Definitely definitely check out the examples. We're really counting on them to make it clear how to use this library.

Developing

PRs are extremely welcome. First, hop into a Python 3.7 environment however you like to manage python environments. The tests are admittedly weak. If you clone and pull down the repo, this command should get you all set up:

python setup.py test

Updating

Increment the version in setup.py, compile the new version, and push it to PyPI.

python setup.py sdist bdist_wheel
python -m twine upload dist/* --verbose

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

pykeybasebot-0.1.1.tar.gz (6.8 kB view details)

Uploaded Source

Built Distribution

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

pykeybasebot-0.1.1-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file pykeybasebot-0.1.1.tar.gz.

File metadata

  • Download URL: pykeybasebot-0.1.1.tar.gz
  • Upload date:
  • Size: 6.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pykeybasebot-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4711d9aeab784baacbd31a2e67f3a76d9c61082e01a1aae0040d6ede67d95991
MD5 9d12754b7149062c1ece4d2fc464af4e
BLAKE2b-256 cdc746155e057d16271c4d6b32fd10544d49aafeb659e7094590d08a6e3d7751

See more details on using hashes here.

File details

Details for the file pykeybasebot-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pykeybasebot-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for pykeybasebot-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dba4fe7fb8effef98ba3ac3a5900a149e63916c103123e8a32ca2772a1dbcbb2
MD5 9844a1097861f6caeba336e4d4d8640c
BLAKE2b-256 8fc16bae585073740153e4e6f36b0d483e8bd70d048414a5c94db446f764e05c

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