Add virtual coin loans
check / local-gate (push) Failing after 42s

This commit is contained in:
JWeBot Contributors
2026-10-15 18:43:49 +08:00
parent 2bb2effc04
commit bbddb5be6f
25 changed files with 346 additions and 25 deletions
+22
View File
@@ -0,0 +1,22 @@
# coin-loan
Author: `jwebot`
贷款
Help:
- `/贷款;/还款`
Registered commands:
- `/贷款`
- `/借款`
- `/loan`
- `/borrow`
- `/还款`
- `/repay`
The adapter has no direct Ledger, GUI, environment, shell, or network access.
It delegates to the reviewed `coin-loan` Kernel service profile
and returns a structured `ReplyPlan`.
+14
View File
@@ -0,0 +1,14 @@
id = "coin-loan"
author = "jwebot"
description = "贷款"
help = ["/贷款;/还款"]
version = "1.0.0"
api_version = "1"
entrypoint = "coin_loan:plugin"
type = "command"
[capabilities]
commands = ["/贷款", "/借款", "/loan", "/borrow", "/还款", "/repay"]
storage = false
network_profiles = []
service_profiles = ["coin-loan"]
@@ -0,0 +1,45 @@
"""Generated reviewed adapter for coin-loan."""
from jwebot_sdk import Event, ExtensionResult, ReplyPlan, SingleGroupContext
PROFILE = 'coin-loan'
AUTHOR = 'jwebot'
DESCRIPTION = '贷款'
HELP_ENTRIES = ('/贷款;/还款',)
COMMANDS = ('/贷款', '/借款', '/loan', '/borrow', '/还款', '/repay')
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_loan 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, ('/贷款;/还款',))
self.assertIn('/贷款', registered)
self.assertEqual(len(registered), 6)
if __name__ == "__main__":
unittest.main()