< 可调用对象列表
(创建页面,内容为“此部分可调用机器人的配置文件。 == ''class'' <code>CFG</code> == === ''method'' <code>load</code> === <syntaxhighlight lang="py3"> def load(cls): </syntaxhighlight> 此方法可以加载配置文件。 === ''method'' <code>get</code> === <syntaxhighlight lang="py3"> get(cls, q: str, default: Union[Any, None] = None, cfg_type: Union[type, tuple, None] = None) -> Any: </syntaxhighlight> 参数: * {{Instructor param|q|str}}:配置项 * <cod…”) |
无编辑摘要 |
||
第10行: | 第10行: | ||
=== ''method'' <code>get</code> === | === ''method'' <code>get</code> === | ||
<syntaxhighlight lang="py3"> | <syntaxhighlight lang="py3"> | ||
get(cls, q: str, default: Union[Any, None] = None, cfg_type: Union[type, tuple, None] = None) -> Any | get(cls, q: str, default: Union[Any, None] = None, cfg_type: Union[type, tuple, None] = None) -> Any | ||
</syntaxhighlight> | </syntaxhighlight> | ||
参数: | 参数: | ||
第22行: | 第22行: | ||
=== ''method'' <code>write</code> === | === ''method'' <code>write</code> === | ||
<syntaxhighlight lang="py3"> | <syntaxhighlight lang="py3"> | ||
def write(cls, q: str, value: Union[Any, None], secret: bool = False) | def write(cls, q: str, value: Union[Any, None], secret: bool = False) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
参数: | 参数: | ||
第32行: | 第32行: | ||
=== ''method'' <code>delete</code> === | === ''method'' <code>delete</code> === | ||
<syntaxhighlight lang="py3"> | <syntaxhighlight lang="py3"> | ||
def delete(cls, q: str) -> bool | def delete(cls, q: str) -> bool | ||
</syntaxhighlight> | </syntaxhighlight> | ||
参数: | 参数: | ||
第42行: | 第42行: | ||
=== ''method'' <code>get_url</code> === | === ''method'' <code>get_url</code> === | ||
<syntaxhighlight lang="py3"> | <syntaxhighlight lang="py3"> | ||
def get_url(cls, q: str, default: Union[str, None] = None) -> Union[str, None] | def get_url(cls, q: str, default: Union[str, None] = None) -> Union[str, None] | ||
</syntaxhighlight> | </syntaxhighlight> | ||
参数: | 参数: |
2024年9月19日 (四) 01:16的版本
此部分可调用机器人的配置文件。
class CFG
method load
def load(cls):
此方法可以加载配置文件。
method get
get(cls, q: str, default: Union[Any, None] = None, cfg_type: Union[type, tuple, None] = None) -> Any
参数:
-
q
:配置项 default
:默认值cfg_type
:配置项类型,输入类型或类型元组,若值与类型不匹配则输出日志警告
返回:配置值,若为空则尝试输出默认值
此方法可以获取配置值。
method write
def write(cls, q: str, value: Union[Any, None], secret: bool = False)
参数:
-
q
:配置项 value
:值-
secret
:是否写入secret
类以参与内容安全检查,默认 False
此方法可以修改配置项。
method delete
def delete(cls, q: str) -> bool
参数:
-
q
:配置项
返回:若删除成功返回 True,否则返回 False
此方法可以删除配置项。
method get_url
def get_url(cls, q: str, default: Union[str, None] = None) -> Union[str, None]
参数:
-
q
:配置项 default
:默认值
返回:配置值,若最后没有“/”则会添加,若为空则尝试输出默认值
此方法可以获取配置值,更方便 URL 的连接。