This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# cs-major-autochess
|
||||
|
||||
Author: `jwebot`
|
||||
|
||||
CS自走棋
|
||||
|
||||
Help:
|
||||
|
||||
- `/自走棋开始|报名`
|
||||
|
||||
Registered commands:
|
||||
|
||||
- `/自走棋`
|
||||
- `/cs自走棋`
|
||||
- `/autochess`
|
||||
- `/选`
|
||||
- `/刷新`
|
||||
- `/锁定`
|
||||
- `/战术`
|
||||
- `/升级教练`
|
||||
- `/上阵`
|
||||
- `/下阵`
|
||||
- `/出售`
|
||||
- `/阵容`
|
||||
- `/赛程`
|
||||
- `/结束回合`
|
||||
|
||||
The adapter has no direct Ledger, GUI, environment, shell, or network access.
|
||||
It delegates to the reviewed `cs-major-autochess` Kernel service profile
|
||||
and returns a structured `ReplyPlan`.
|
||||
@@ -0,0 +1,14 @@
|
||||
id = "cs-major-autochess"
|
||||
author = "jwebot"
|
||||
description = "CS自走棋"
|
||||
help = ["/自走棋开始|报名"]
|
||||
version = "1.0.0"
|
||||
api_version = "1"
|
||||
entrypoint = "cs_major_autochess:plugin"
|
||||
type = "command"
|
||||
|
||||
[capabilities]
|
||||
commands = ["/自走棋", "/cs自走棋", "/autochess", "/选", "/刷新", "/锁定", "/战术", "/升级教练", "/上阵", "/下阵", "/出售", "/阵容", "/赛程", "/结束回合"]
|
||||
storage = false
|
||||
network_profiles = []
|
||||
service_profiles = ["cs-major-autochess"]
|
||||
@@ -0,0 +1,37 @@
|
||||
"""Generated reviewed adapter for cs-major-autochess."""
|
||||
|
||||
from jwebot_sdk import Event, ExtensionResult, ReplyPlan, SingleGroupContext
|
||||
|
||||
|
||||
PROFILE = 'cs-major-autochess'
|
||||
AUTHOR = 'jwebot'
|
||||
DESCRIPTION = 'CS自走棋'
|
||||
HELP_ENTRIES = ('/自走棋开始|报名',)
|
||||
COMMANDS = ('/自走棋', '/cs自走棋', '/autochess', '/选', '/刷新', '/锁定', '/战术', '/升级教练', '/上阵', '/下阵', '/出售', '/阵容', '/赛程', '/结束回合')
|
||||
|
||||
|
||||
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 cs_major_autochess 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, 'CS自走棋')
|
||||
self.assertEqual(HELP_ENTRIES, ('/自走棋开始|报名',))
|
||||
self.assertIn('/自走棋', registered)
|
||||
self.assertEqual(len(registered), 14)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user