release: public alpha 0.6.0 baseline
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
# dice
|
||||
|
||||
Author: `jwebot`
|
||||
|
||||
骰子和多人骰子挑战
|
||||
|
||||
Help:
|
||||
|
||||
- `/丢骰子 [NdM]`
|
||||
- `/丢骰子挑战 [5d6|5d20|状态|结算|战绩|结束]`
|
||||
|
||||
Registered commands:
|
||||
|
||||
- `/丢骰子`
|
||||
- `/骰子`
|
||||
- `/丢骰子挑战`
|
||||
- `/骰子挑战`
|
||||
|
||||
The adapter has no direct Ledger, GUI, environment, shell, or network access.
|
||||
It delegates to the reviewed `dice` Kernel service profile
|
||||
and returns a structured `ReplyPlan`.
|
||||
@@ -0,0 +1,14 @@
|
||||
id = "dice"
|
||||
author = "jwebot"
|
||||
description = "骰子和多人骰子挑战"
|
||||
help = ["/丢骰子 [NdM]", "/丢骰子挑战 [5d6|5d20|状态|结算|战绩|结束]"]
|
||||
version = "1.0.0"
|
||||
api_version = "1"
|
||||
entrypoint = "dice:plugin"
|
||||
type = "command"
|
||||
|
||||
[capabilities]
|
||||
commands = ["/丢骰子", "/骰子", "/丢骰子挑战", "/骰子挑战"]
|
||||
storage = false
|
||||
network_profiles = []
|
||||
service_profiles = ["dice"]
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Generated reviewed adapter for dice."""
|
||||
|
||||
from jwebot_sdk import Event, ExtensionResult, ReplyPlan, SingleGroupContext
|
||||
|
||||
|
||||
PROFILE = 'dice'
|
||||
AUTHOR = 'jwebot'
|
||||
DESCRIPTION = '骰子和多人骰子挑战'
|
||||
HELP_ENTRIES = ('/丢骰子 [NdM]', '/丢骰子挑战 [5d6|5d20|状态|结算|战绩|结束]')
|
||||
COMMANDS = ('/丢骰子', '/骰子', '/丢骰子挑战', '/骰子挑战')
|
||||
|
||||
|
||||
def _handler(context: SingleGroupContext, command: str):
|
||||
def handle(event: Event, arguments: str) -> ExtensionResult:
|
||||
response = context.services.call(
|
||||
PROFILE,
|
||||
operation="execute",
|
||||
payload={
|
||||
"command": command,
|
||||
"arguments": arguments,
|
||||
"event": event.to_mapping(),
|
||||
},
|
||||
)
|
||||
text = response.get("text")
|
||||
if not isinstance(text, str) or not text.strip():
|
||||
raise ValueError("local service returned invalid text")
|
||||
return ExtensionResult(
|
||||
reply=ReplyPlan.text(text),
|
||||
metadata={"local_extension": PROFILE, "author": AUTHOR},
|
||||
)
|
||||
|
||||
return handle
|
||||
|
||||
|
||||
def plugin(context: SingleGroupContext) -> None:
|
||||
for command in COMMANDS:
|
||||
context.commands.register(command, _handler(context, command))
|
||||
@@ -0,0 +1,29 @@
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest import mock
|
||||
|
||||
|
||||
SOURCE = Path(__file__).resolve().parents[1] / "src"
|
||||
sys.path.insert(0, str(SOURCE))
|
||||
|
||||
from dice import AUTHOR, DESCRIPTION, HELP_ENTRIES, plugin
|
||||
|
||||
|
||||
class PluginTests(unittest.TestCase):
|
||||
def test_registers_declared_commands_and_author(self):
|
||||
context = mock.Mock()
|
||||
plugin(context)
|
||||
registered = [
|
||||
call.args[0]
|
||||
for call in context.commands.register.call_args_list
|
||||
]
|
||||
self.assertEqual(AUTHOR, 'jwebot')
|
||||
self.assertEqual(DESCRIPTION, '骰子和多人骰子挑战')
|
||||
self.assertEqual(HELP_ENTRIES, ('/丢骰子 [NdM]', '/丢骰子挑战 [5d6|5d20|状态|结算|战绩|结束]'))
|
||||
self.assertIn('/丢骰子', registered)
|
||||
self.assertEqual(len(registered), 4)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user