The gateway implementation for the fuwa eco-system
Project description
Fuwa Gateway
The gateway implementation for the fuwa eco-system
Example
import asyncio
import logging
from fuwa.gateway.connection import GatewayConnection
from fuwa.gateway.intents import IntentsFlags
logging.basicConfig(level=logging.INFO)
intents = IntentsFlags(
guilds=True,
guild_messages=True
)
async def launch():
connection = GatewayConnection(
"Your Bot Token Here",
intents
)
await connection.open_connection("wss://gateway.discord.gg/") # you would preferrably
# get this gateway url with fuwa-http
async def my_event_handler(event_data: dict):
content = event_data["content"]
print(content)
connection.add_event_handler("MESSAGE_CREATE", my_event_handler)
loop = asyncio.get_event_loop()
loop.run_until_complete(launch())
loop.run_forever()
You may think this is quite over the top for a gateway handler, however keep in mind, you are looking at the raw gateway library. If you wanted to, you could just use the Fuwa Gateway, however most of the time, you would use one of the other Fuwa packages along side this, such as the command_framework. Most of the packages will link into Fuwa Gateway, meaning you won't usually have to create your own event handlers. Also, the soon to come bundler, will assist you in creating Fuwa Bots.
Install
pip install fuwa[gateway]
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
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 fuwa-gateway-1.0.2a0.tar.gz.
File metadata
- Download URL: fuwa-gateway-1.0.2a0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f8a9e84e7b415b1196c59897283302bf40c508234c7e93fdcbfbf95fb451702
|
|
| MD5 |
394ca5d780ee9f0c5832196765f9096b
|
|
| BLAKE2b-256 |
205e2a28910c2a53be68cc6f1d4834df20b90ebee7a542609de0a31c648ef300
|
File details
Details for the file fuwa_gateway-1.0.2a0-py3-none-any.whl.
File metadata
- Download URL: fuwa_gateway-1.0.2a0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87dfc2d2ff85d232787d9a40309ab132845c07dddab308baac613218565b333a
|
|
| MD5 |
d394757e1369769ce0d66a208c7f50c7
|
|
| BLAKE2b-256 |
57c8ed2caff52fa4360a4185958a489a7862fd4f0c06ff831bacdbb2a1003f8c
|