Skip to main content

python bot client for keybase

Project description

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of keybase nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Description: # Python Keybase Bot Library

This 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 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: `sh python setup.py test `

Platform: UNKNOWN Classifier: Programming Language :: Python :: 3 :: Only Classifier: Programming Language :: Python :: 3.7 Classifier: Topic :: Communications :: Chat :: Keybase Classifier: Framework :: Robot Framework :: Library Classifier: Framework :: Robot Framework :: Tool Classifier: Keybase Description-Content-Type: text/markdown

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.0.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

pykeybasebot-0.1.0-py3-none-any.whl (9.6 kB view hashes)

Uploaded Python 3

Supported by

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