Skip to main content

dico-interaction

Interaction module for dico.

Features

  • Webserver included, powered by aiohttp.
  • Easier interaction usage.

Installation

pip install -U dico-interaction

Example

Gateway Client

from dico import Client, Button, ActionRow, ButtonStyles
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):
    button = Button(style=ButtonStyles.PRIMARY, label="Hello!", custom_id=f"hello{ctx.id}")
    await ctx.send("Hello, World!", components=[ActionRow(button)])
    
    
@interaction.context_menu(name="say", menu_type=3)
async def say_menu(ctx: InteractionContext):
    await ctx.send(f"You said: {ctx.target.content}")
    

@interaction.component_callback("hello")
async def hello_callback(ctx: InteractionContext):
    await ctx.send("Hello again!", ephemeral=True)

client.run()

Webserver

import ssl  # SSL is forced to register your webserver URL to discord.
from dico import Button, ActionRow, ButtonStyles
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):
    button = Button(style=ButtonStyles.PRIMARY, label="Hello!", custom_id=f"hello{ctx.id}")
    await ctx.send("Hello, World!", components=[ActionRow(button)])
    
    
@interaction.context_menu(name="say", menu_type=3)
async def say_menu(ctx: InteractionContext):
    await ctx.send(f"You said: {ctx.target.content}")
    

@interaction.component_callback("hello")
async def hello_callback(ctx: InteractionContext):
    await ctx.send("Hello again!", ephemeral=True)

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)

Metadata

Release files for dico-interaction 0.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dico-interaction 0.0.9
File Size Uploaded Provenance
dico-interaction-0.0.9.tar.gz 13.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for dico-interaction 0.0.9
File Interpreter ABI Platform
dico_interaction-0.0.9-py3-none-any.whl Python 3 none any Details

Total release size: 30.1 kB

Release files / dico-interaction-0.0.9.tar.gz

Download URL dico-interaction-0.0.9.tar.gz
Size 13.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bff8c4a7b2eb26bad3e2805a210f609457b86caac329a024cedd3038cdc14558
BLAKE2b-256 checksum
How to use checksums
3826faca74e7f820e336ac64ba7909484adaf0b2568316f2595dfb3b268d39ce
Upload date
Uploaded using Trusted Publishing?
What is 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.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / dico_interaction-0.0.9-py3-none-any.whl

Download URL dico_interaction-0.0.9-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e25266e0328110025042d1925aef124b36ba89228337f953ac7ed8b58af24fc0
BLAKE2b-256 checksum
How to use checksums
a91638cf7f84b0b881cde76f9668013e854e6f4fb8298de32111e2890fe8a17d
Upload date
Uploaded using Trusted Publishing?
What is 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.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Security for dico-interaction 0.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page