Interaction module for dico.
Project description
dico-interaction
Interaction module for dico.
Features
- Webserver included, powered by aiohttp.
- Easier interaction usage.
Installation
pip install -U dico-interaction
Example
Gateway Client
Application Command:
from dico import Client
from dico_interaction import InteractionClient, InteractionContext
client = Client("BOT_TOKEN")
interaction = InteractionClient(client=client)
@interaction.slash(name="hello", description="Say hello.")
async def hello(ctx: InteractionContext):
await ctx.send("Hello, World!")
@interaction.context_menu(name="say", menu_type=3)
async def say_menu(ctx: InteractionContext):
await ctx.send(f"You said: {ctx.target.content}")
client.run()
Webserver
import ssl # SSL is forced to register your webserver URL to discord.
from dico_interaction import InteractionClient, InteractionWebserver, InteractionContext
bot_token = ""
bot_public_key = ""
interaction = InteractionClient(respond_via_endpoint=False)
server = InteractionWebserver(bot_token, bot_public_key, interaction)
@interaction.slash(name="hello", description="Say hello.")
async def hello(ctx: InteractionContext):
await ctx.send("Hello, World!")
@interaction.context_menu(name="say", menu_type=3)
async def say_menu(ctx: InteractionContext):
await ctx.send(f"You said: {ctx.target.content}")
ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
ssl_context.load_cert_chain("cert.pem", "privkey.pem")
server.run(host='0.0.0.0', port=1337, ssl_context=ssl_context)
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
dico-interaction-0.0.6.tar.gz
(12.6 kB
view hashes)
Built Distribution
Close
Hashes for dico_interaction-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaeeece88bc5b5b4a730c8f1d7672daa80fc8ad8bb30d0cc2f49505c1b6eb2ed |
|
MD5 | 4fd90b7d4c4a1a2e1d3cf34c9bc43d8f |
|
BLAKE2b-256 | 2d20615d947f9cf1952da98630522fd3c059c04189fc97c410fa277f0761a7ab |