Python wrapper for the revolt.chat API
Project description
Revolt.py
An async library to interact with the https://revolt.chat API.
You can join the support server here and find the library's documentation here.
Installing
You can use pip
to install revolt.py. It differs slightly depending on what OS/Distro you use.
On Windows
py -m pip install -U revolt.py # -U to update
On macOS and Linux
python3 -m pip install -U revolt.py
Example
More examples can be found in the examples folder.
import revolt
import asyncio
class Client(revolt.Client):
async def on_message(self, message: revolt.Message):
if message.content == "hello":
await message.channel.send("hi how are you")
async def main():
async with revolt.utils.client_session() as session:
client = Client(session, "BOT TOKEN HERE")
await client.start()
asyncio.run(main())
Bot interaction example
class Client(revolt.Client):
async def on_interaction(
self, interaction: InteractionEventPayload, message: revolt.Message
) -> None:
logger.info("interaction %s", interaction)
user = self.get_user(interaction["author_id"])
await message.channel.send(
f"Username: {user.name} Your choice is: {interaction['content']} "
)
components = message.components
components[0]["label"] = "edited"
components[0]["enabled"] = False
# update the button component's label
await message.edit(content="edited", components=components)
async def on_message(self, message: revolt.Message):
if message.content == "/button":
await message.channel.send(
"you have these options",
components=[
Component(
type="button",
style="color:white; backgroundColor:green; fontSize:16px; fontWeight:400;",
label="continue",
enabled=True,
),
Component(
type="button", style="color:green", label="quit", enabled=True
),
Component(
type="button", style="color:red", label="restart", enabled=False
),
],
)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
revolt_baidu.py-0.0.1.tar.gz
(48.3 kB
view details)
Built Distribution
File details
Details for the file revolt_baidu.py-0.0.1.tar.gz
.
File metadata
- Download URL: revolt_baidu.py-0.0.1.tar.gz
- Upload date:
- Size: 48.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd16d0c178bae8584a916b76bb6cd5ca9985a70400b9e01ee8ea08686996afbe |
|
MD5 | c7134c22ac93066c41d6646a5e12bcc7 |
|
BLAKE2b-256 | 62f5f4b54224eef103953bc5009c1e9f472e61274f02d27221d953a3106f9a47 |
File details
Details for the file revolt_baidu.py-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: revolt_baidu.py-0.0.1-py3-none-any.whl
- Upload date:
- Size: 69.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47557134df9f53421917f07e716ee716d7124bca6a88964a77dbfe4102d3becc |
|
MD5 | 513b5d29fdc61e3072222b02dd622e12 |
|
BLAKE2b-256 | 6c2442d6139e1745f4aeca7a29f8e2528ef041f7943d5e0c0dcce429a46059d8 |