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 hashes)

Uploaded Source

Built Distribution

xbotlib-0.1.0-py3-none-any.whl (15.7 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