Skip to main content

XMPP bots for humans

Project description

xbotlib

XMPP bots for humans

A friendly lightweight wrapper around slixmpp.

xbotlib doesn't want to obscure the workings of the underlying library or invent a totally new API. To this end, 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.

The goal is to make writing and running XMPP bots in Python easy and fun.

Install

$ pip install xbotlib

Example

from xbotlib import Bot

class EchoBot(Bot):
    def reply_direct_chat(self, message):
        self.send_direct_chat(to=message.sender, body=message.body)

MyBot()

And then python echo.py.

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.reply_direct_chat

A function which you define in your bot implementation in order to respond to direct chat messages.

Arguments:

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

Bot.send_direct_chat

Send back a response to a direct chat message.

Arguments:

  • to: who to send it to (can be a user or a room)
  • body: the message to send

Bot.reply_group_chat

A function which you define in your bot implementation in order to respond to group chat messages.

Arguments:

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

Bot.send_group_chat

Send back a response to a group chat message.

Arguments:

  • to: who to send it to (can be a user or a room)
  • body: the message to send

Message

A simple message format.

Attributes:

  • body
  • sender
  • receive
  • nickname
  • type

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 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.1.0.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

xbotlib-0.1.0-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: xbotlib-0.1.0.tar.gz
  • Upload date:
  • Size: 16.2 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.1.0.tar.gz
Algorithm Hash digest
SHA256 da528d59843dee8dbbc20e9bc8a027c0f56249e3acdfc45421aa53af69fcaa1c
MD5 e66a33d7f1376be40435169b27147625
BLAKE2b-256 b1bd084b09333fb01698e049d496f5df8698ffe0a240469406cf6c7362c6179a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xbotlib-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.7 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd4716a6a8b4c72ca84eb73eb10edcd77cd0d576cb8b452267ef5167e9171867
MD5 b1348c89115b2a72f1254b9d73772027
BLAKE2b-256 6f590631483aeb48cb1b88c0cdb6f67d9b749276d85a85dd2925bdaf2641c00b

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