Skip to main content

Python messenger bot aggregator, supporting Discord, Telegram, and potentially others

Project description

Botter - Simple interface for creating cross-messenger bots

Botter is a framework which allows your bots run in any available messenger. Currently, there are only one implementation for Discord, but it is easy to implement other platforms.

Okay, let's get started!

Getting Started

Creating an Application

At first, you should register a bot in the desired platform. As all messengers provide different ways to do so, we will not describe this process here.

Create Handler

Botter uses event-based architecture, with a most-common event - MessageEvent. Events are handled by EventHandler's.

So, let's create out own:

from botter.api import *
from botter.api.handlers import *

class SimpleEchoHandler(ReplyHandler):
    async def handle_message(self, message: InboundMessage) -> Message:
        return Message(f"You've said:\n" + message.text)

Here we use the ReplyHandler, which:

  • Nests MessageHandler
  • Checks the event is MessageEvent
  • Calls method handle_message() with the message from event.
  • If this method returns Message rather than None, ReplyHandler would send it to server with a mention to the original message's author.

Crate a Bot

Then we need to create a Bot - object that aggregates handlers and mappings to the implementation. Here we use discord driver as an example.

from botter.discord import DiscordBot

class EchoBot(Bot[DiscordBot]):
    token = 'INSERT_YOUR_TOKEN_HERE'
    event_handlers = [ SimpleEchoHandler ]
    client = DiscordBot(token=token)

Okay, let's try it out!

Simple EchoBot - Discord

Wow! It works!

Extending Events

Now, let's try to have some fun with the events.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

botter-0.1.1-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: botter-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.9

File hashes

Hashes for botter-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b27bf292e7e593e68b44fc455f906a6717c4e623beacb961ef9b9e676377af9
MD5 522c1f80cef36e6936029e804b5230fe
BLAKE2b-256 9dde5b6fb3304c170158531ba351cf5bcd41250c86704a0716b8ba18cf4794e5

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