Python SDK for building bots on the RealChat platform
Project description
realchat-sdk
Python SDK for building bots on the RealChat platform.
Installation
pip install realchat-sdk
Quick Start
import asyncio
from realchat import Client
client = Client(token="RC.your_bot_token_here")
@client.event("on_ready")
async def on_ready():
print(f"Logged in as {client.user.username}")
@client.event("on_message")
async def on_message(message):
if message.content == "!ping":
await message.channel.send("Pong!")
if message.content == "!hello":
await message.channel.send(f"Hello {message.author.username}!")
asyncio.run(client.start())
Events
| Event | Description |
|---|---|
on_ready |
Bot connected and authenticated |
on_message |
Message received in any channel |
on_typing |
User started typing |
on_presence |
User status changed |
on_disconnect |
WebSocket disconnected |
REST API
from realchat import Client
client = Client(token="RC.your_bot_token_here")
async def main():
# Get bot's user info
user = await client.http.get_me()
print(f"I am {user.username}")
# List servers the bot is in
servers = await client.http.get_servers()
for server in servers:
print(f" - {server.name} ({server.id})")
# Get channels in a server
channels = await client.http.get_channels(servers[0].id)
for channel in channels:
print(f" # {channel.name}")
# Send a message
await client.http.send_message(channel.id, "Hello from my bot!")
# Read messages
messages = await client.http.get_messages(channel.id, limit=10)
for msg in messages:
print(f" {msg.author.username}: {msg.content}")
await client.close()
import asyncio
asyncio.run(main())
Getting a Bot Token
- Go to the Developer Portal
- Create a new bot
- Copy the bot token (starts with
RC.) - Use it in your code
License
MIT
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
realchat_sdk-0.1.0.tar.gz
(71.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file realchat_sdk-0.1.0.tar.gz.
File metadata
- Download URL: realchat_sdk-0.1.0.tar.gz
- Upload date:
- Size: 71.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
848fe5df705690d4e92cb0e8742e0e3259d63163f777f41658e44bcada139095
|
|
| MD5 |
11bb93ecde7ac3c9daa6fc323afcfdf9
|
|
| BLAKE2b-256 |
2441937db7146089511ffe30ee928b0c4924f8dc2a421e9fa88ff574243491aa
|
File details
Details for the file realchat_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: realchat_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93ea185e5ff04b0feee16e5d606316313f381b5da1a482c5b634d94c1a8feb68
|
|
| MD5 |
dafb2de47f418563f98965745868e771
|
|
| BLAKE2b-256 |
40d4d08ae1f6675713a05078cbd21dd54929366474c19efa258e7306c72289e4
|