Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement simple plugins #3

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added examples/plugins/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions examples/plugins/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import asyncio

import velum

import sail

client = velum.GatewayClient()
manager = sail.CommandManager.with_prefix("!")
manager.bind_to_app(client)


async def main():
await sail.load_extension(".test_plugin", client=client, command_manager=manager)
await client.start()


@manager.command()
async def reload(ctx: sail.Context):
await sail.reload_extension(".test_plugin", client=client, command_manager=manager)
await client.rest.send_message("Sail", "Done deal.")


asyncio.run(main())
11 changes: 11 additions & 0 deletions examples/plugins/test_plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import sail

plugin = sail.Plugin()


@plugin.command()
async def plugin_command(ctx: sail.Context):
await plugin.rest.send_message("Sail", f"Sent from plugin {plugin.name!r}!")


load, unload = plugin.entrypoints
1 change: 1 addition & 0 deletions sail/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from sail.errors import *
from sail.impl.command import *
from sail.impl.command_manager import *
from sail.impl.plugin import *
from sail.internal.typing_utils import Greedy as Greedy
from sail.internal.typing_utils import JoinedStr as JoinedStr
from sail.internal.undefined import UNDEFINED as UNDEFINED
Expand Down
Loading