Skip to main content

Official wrapper around Adapt's API for Python.

Project description

adapt.py

Official wrapper around Adapt's API for Python.

Installation

pip install adapt.py

From GitHub:

pip install git+https://github.com/AdaptChat/adapt.py

Usage

import adapt

class Client(adapt.Client):
    """My example client"""

    @adapt.once  # This event will only be called once
    async def on_ready(self, ready: adapt.ReadyEvent) -> None:
        print(f"Logged in as {ready.user}!")

    async def on_message(self, message: adapt.Message) -> None:
        if message.content == "!ping":
            await message.channel.send("Pong!")

if __name__ == "__main__":
    client = Client()
    client.run("token")

Using adapt.py with a custom Adapt instance

Adapt.py defaults to use the official Adapt instance at https://adapt.chat. If you want to use a custom instance, pass an AdaptServer instance to the server kwarg when constructing the client.

AdaptServer.local() can be used as a shortcut to create a server instance for a local instance of Adapt:

from adapt import AdaptServer, Client

client = Client(server=AdaptServer.local())  # Use a local instance of Adapt
...

Or, you can manually pass in URLs:

from adapt import AdaptServer, Client

server = AdaptServer(
    api="https://my-adapt-instance.com/api",
    harmony="https://my-adapt-instance.com/harmony",
    convey="https://my-adapt-instance.com/convey",
)
client = Client(server=server)
...

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

adapt.py-0.1.0a0.tar.gz (37.9 kB view hashes)

Uploaded Source

Built Distribution

adapt.py-0.1.0a0-py3-none-any.whl (46.5 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