MCPcopy
hub / github.com/nonebot/nonebot2 / format

Method format

nonebot/internal/adapter/template.py:78–82  ·  view source on GitHub ↗

根据传入参数和模板生成消息对象

(  # pyright: ignore[reportIncompatibleMethodOverride]
        self, *args, **kwargs
    )

Source from the content-addressed store, hash-verified

76 return spec
77
78 def format( # pyright: ignore[reportIncompatibleMethodOverride]
79 self, *args, **kwargs
80 ) -> TF:
81 """根据传入参数和模板生成消息对象"""
82 return self._format(args, kwargs)
83
84 def format_map(self, mapping: Mapping[str, Any]) -> TF:
85 """根据传入字典和模板生成消息对象, 在传入字段名不是有效标识符时有用"""

Callers 15

test_template_basisFunction · 0.95
test_malformed_templateFunction · 0.95
_receive_prompt_resultFunction · 0.80
_solve_promptMethod · 0.80
_receiveMethod · 0.80
_key_getterMethod · 0.80
sendMethod · 0.80
rejectMethod · 0.80
reject_argMethod · 0.80
reject_receiveMethod · 0.80
get_receiveMethod · 0.80
set_receiveMethod · 0.80

Calls 1

_formatMethod · 0.95

Tested by 7

test_template_basisFunction · 0.76
test_malformed_templateFunction · 0.76
test_matcherFunction · 0.64
test_argFunction · 0.64
test_template_messageFunction · 0.64
test_message_injectionFunction · 0.64