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 gateway.connection import GatewayConnection
from 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.
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
fuwa-gateway-1.0.0a0.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for fuwa_gateway-1.0.0a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e74f7c8f57bdeceb3e306d66253a1e0c0b1de6dd81a54fb29a0997f7bd9e9a0a |
|
MD5 | 9ebec0f6d2d86648bfc43001d16ac41d |
|
BLAKE2b-256 | 0e980b2f2ce38131948cc343a5a1057061c896c20bb8bc40170e49e211550f48 |