Skip to main content

XMPP bots for humans

Project description

xbotlib

XMPP bots for humans

status: experimental

A friendly lightweight wrapper around slixmpp for writing XMPP bots in Python. The goal is to make writing and running XMPP bots easy and fun.

xbotlib is a single file implementation which can easily be understood and extended. It provides a small API surface which reflects the slixmpp way of doing things.

Install

$ pip install xbotlib

Example

from xbotlib import Bot

class EchoBot(Bot):
    def react(self, message):
        if message.type == "chat":
          self.reply(to=message.sender, body=message.body)

MyBot()

And then python echo.py. You will be asked a few questions like which account details your bot will be using. This will generate a bot.conf file in the same working directory for further use.

More Examples

  • EchoBot: Sends back what you sent it
  • WhisperBot: Pseudo-anonymous whispering in group chats

See the examples directoy for all listings.

API Reference

Your bot always sub-classes the Bot class provided from xbotlib. All underling functions can be extended. For example, if you want to enable more plugins or add different functionality. If something feels awkwardthen please raise a ticket for that. Seamlessness is still a bitch but we're trying anyway.

Bot.react

A function which you define in your bot implementation in order to respond to chat messages. You can respond to both direct messages and group chat messages in this function by checking the message.type which can be either chat or groupchat.

Arguments:

  • message: sent message and metadata (see message reference below)

Bot.reply

Send back a response to a direct chat message.

Arguments:

  • to: which user account to reply to (direct chat)
  • room: which room to reply to (group chat)
  • body: the message to send

Message

A simple message format.

Attributes:

  • body: the body of the message
  • sender: the sender of the message
  • receive: the receive of the message
  • nickname: the nickname of the sender
  • type: the type of message (chat or groupchat)

Roadmap

  • The library only handles reactions. The bots can only send messages when they receive a message. It would be nice to allow for sending messages at specific times.

  • Extend the bot.conf to allow for multiple bot configurations.

  • Sort out something for how to deploy them. It's easy to run them locally but hard to run them on a server. Maybe something can be done for that as well.

Changes

See the CHANGELOG.md.

License

See the LICENSE.

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

xbotlib-0.2.0.tar.gz (16.5 kB view details)

Uploaded Source

Built Distribution

xbotlib-0.2.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file xbotlib-0.2.0.tar.gz.

File metadata

  • Download URL: xbotlib-0.2.0.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.0 Linux/4.19.0-13-amd64

File hashes

Hashes for xbotlib-0.2.0.tar.gz
Algorithm Hash digest
SHA256 97495e553937fca579dfd1eeca6131ba6c7c596a91ae53158c1acae5c50bc2da
MD5 9e3a2e1e9edfbc2090526561c7b89613
BLAKE2b-256 0f6cca96de40ad2b99bb065075e93bdea8f89d674188a2fe76eed67872f7737f

See more details on using hashes here.

File details

Details for the file xbotlib-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: xbotlib-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.4 CPython/3.9.0 Linux/4.19.0-13-amd64

File hashes

Hashes for xbotlib-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bd1d5bf9e23c89cb32e9fc4444e254d0406dd073b88978498bf1cd429b3ce75c
MD5 7957f91afb39034cdd1b97b90e10e9f7
BLAKE2b-256 1c8f71844bcd6b62141ad4eb6ddb90011871683e0eccfce1f9cd5b5c3c75c343

See more details on using hashes here.

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