This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# coin-taffy
|
||||
|
||||
Author: `jwebot`
|
||||
|
||||
Taffy金币
|
||||
|
||||
Help:
|
||||
|
||||
- `/Taffy金币`
|
||||
|
||||
Registered commands:
|
||||
|
||||
- `/Taffy金币`
|
||||
- `/taffycoins`
|
||||
|
||||
The adapter has no direct Ledger, GUI, environment, shell, or network access.
|
||||
It delegates to the reviewed `coin-taffy` Kernel service profile
|
||||
and returns a structured `ReplyPlan`.
|
||||
@@ -0,0 +1,14 @@
|
||||
id = "coin-taffy"
|
||||
author = "jwebot"
|
||||
description = "Taffy金币"
|
||||
help = ["/Taffy金币"]
|
||||
version = "1.0.0"
|
||||
api_version = "1"
|
||||
entrypoint = "coin_taffy:plugin"
|
||||
type = "command"
|
||||
|
||||
[capabilities]
|
||||
commands = ["/Taffy金币", "/taffycoins"]
|
||||
storage = false
|
||||
network_profiles = []
|
||||
service_profiles = ["coin-taffy"]
|
||||
@@ -0,0 +1,45 @@
|
||||
"""Generated reviewed adapter for coin-taffy."""
|
||||
|
||||
from jwebot_sdk import Event, ExtensionResult, ReplyPlan, SingleGroupContext
|
||||
|
||||
|
||||
PROFILE = 'coin-taffy'
|
||||
AUTHOR = 'jwebot'
|
||||
DESCRIPTION = 'Taffy金币'
|
||||
HELP_ENTRIES = ('/Taffy金币',)
|
||||
COMMANDS = ('/Taffy金币', '/taffycoins')
|
||||
|
||||
|
||||
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(),
|
||||
},
|
||||
)
|
||||
texts = response.get("texts")
|
||||
if isinstance(texts, list) and texts and all(
|
||||
isinstance(item, str) and item.strip() for item in texts
|
||||
):
|
||||
return ExtensionResult(
|
||||
reply=ReplyPlan.multi_text(texts),
|
||||
metadata={"local_extension": PROFILE, "author": AUTHOR},
|
||||
)
|
||||
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 coin_taffy 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, 'Taffy金币')
|
||||
self.assertEqual(HELP_ENTRIES, ('/Taffy金币',))
|
||||
self.assertIn('/Taffy金币', registered)
|
||||
self.assertEqual(len(registered), 2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -9,8 +9,7 @@ Help:
|
||||
- `/金币 /wallet;/游戏记录 /gamehistory`
|
||||
- `/抽奖 [金额];/draw`
|
||||
- `/彩票 开始|报名|状态|开奖|取消;/lottery`
|
||||
- `/21点 开始 [1~500];/blackjack start`
|
||||
- `/21点 要牌|停牌|状态|结束;/blackjack`
|
||||
- `/21点 单人开始|要牌|停牌|状态;多人启动|加入|开始|放200`
|
||||
- `/游戏帮助;/games`
|
||||
|
||||
Registered commands:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
id = "single-player-games"
|
||||
author = "jwebot"
|
||||
description = "金币游戏"
|
||||
help = ["/金币 /wallet;/游戏记录 /gamehistory", "/抽奖 [金额];/draw", "/彩票 开始|报名|状态|开奖|取消;/lottery", "/21点 开始 [1~500];/blackjack start", "/21点 要牌|停牌|状态|结束;/blackjack", "/游戏帮助;/games"]
|
||||
help = ["/金币 /wallet;/游戏记录 /gamehistory", "/抽奖 [金额];/draw", "/彩票 开始|报名|状态|开奖|取消;/lottery", "/21点 单人开始|要牌|停牌|状态;多人启动|加入|开始|放200", "/游戏帮助;/games"]
|
||||
version = "1.0.0"
|
||||
api_version = "1"
|
||||
entrypoint = "single_player_games:plugin"
|
||||
|
||||
@@ -6,7 +6,7 @@ from jwebot_sdk import Event, ExtensionResult, ReplyPlan, SingleGroupContext
|
||||
PROFILE = 'single-player-games'
|
||||
AUTHOR = 'jwebot'
|
||||
DESCRIPTION = '金币游戏'
|
||||
HELP_ENTRIES = ('/金币 /wallet;/游戏记录 /gamehistory', '/抽奖 [金额];/draw', '/彩票 开始|报名|状态|开奖|取消;/lottery', '/21点 开始 [1~500];/blackjack start', '/21点 要牌|停牌|状态|结束;/blackjack', '/游戏帮助;/games')
|
||||
HELP_ENTRIES = ('/金币 /wallet;/游戏记录 /gamehistory', '/抽奖 [金额];/draw', '/彩票 开始|报名|状态|开奖|取消;/lottery', '/21点 单人开始|要牌|停牌|状态;多人启动|加入|开始|放200', '/游戏帮助;/games')
|
||||
COMMANDS = ('/金币', '/wallet', '/抽奖', '/draw', '/彩票', '/买彩票', '/lottery', '/21点', '/二十一点', '/blackjack', '/游戏记录', '/个人记录', '/gamehistory', '/游戏帮助', '/games')
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class PluginTests(unittest.TestCase):
|
||||
]
|
||||
self.assertEqual(AUTHOR, 'jwebot')
|
||||
self.assertEqual(DESCRIPTION, '金币游戏')
|
||||
self.assertEqual(HELP_ENTRIES, ('/金币 /wallet;/游戏记录 /gamehistory', '/抽奖 [金额];/draw', '/彩票 开始|报名|状态|开奖|取消;/lottery', '/21点 开始 [1~500];/blackjack start', '/21点 要牌|停牌|状态|结束;/blackjack', '/游戏帮助;/games'))
|
||||
self.assertEqual(HELP_ENTRIES, ('/金币 /wallet;/游戏记录 /gamehistory', '/抽奖 [金额];/draw', '/彩票 开始|报名|状态|开奖|取消;/lottery', '/21点 单人开始|要牌|停牌|状态;多人启动|加入|开始|放200', '/游戏帮助;/games'))
|
||||
self.assertIn('/金币', registered)
|
||||
self.assertEqual(len(registered), 15)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user