Errb中流的正确使用

2024-10-03 02:36:42 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用errbot,并且有一个工作流程。我面临的挑战是,在每个流之后,我都有一条消息显示下一个流命令。我想把这个关掉。你知道吗

我的插件有代码

## First
@botcmd(split_args_with=None)
def portscan(self, message, args):
    user = {'id': message.frm.id, 'name': message.frm.first_name}
    datacreate(message.body, user, isbotmessage=False)
    response = "Whats your IP Address?"
    datacreate(response, user, isbotmessage=True)
    return response

第二

@botmatch(r'^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$', flow_only=True, hidden=True)
def psipaddress(self, message, match):

在运行portscan之后,我得到下面显示regex的消息,我想隐藏这个。你知道吗

你的IP地址是什么?你知道吗

如果您在流MyFlows1中,则可以继续: •^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}$

errbot文档提到了以下设置。下一步的暗示。我试过设置这个,但似乎不起作用。你知道吗

errbot.flow.FLOW_END = <errbot.flow._FlowEnd object>
Flow marker indicating that the flow ends.

    class errbot.flow.Flow(root: errbot.flow.FlowRoot, requestor:      errbot.backends.base.Identifier, initial_context: typing.Mapping[str,   typing.Any], next_step_hinting: int = True)[source]
Bases: object

    This is a live Flow. It keeps context of the conversation   (requestor and context). Context is just a python dictionary   representing the state of the conversation.

__init__(root: errbot.flow.FlowRoot, requestor: errbot.backends.base.Identifier, initial_context: typing.Mapping[str, typing.Any], next_step_hinting: int = True)[source]
Parameters: 
root (FlowRoot) -- the root of this flow.
requestor (Identifier) -- the user requesting this flow.
initial_context (Mapping) -- any data we already have that could help executing this flow automatically.
next_step_hinting (int) -- toggle display of the "you are now in the flow xxx, you may continue with yyy, zzz"

从errbot导入botflow、FlowRoot、botflow、botcmd、botmatch 从errbot.flow公司导入流

你知道吗

class Command(BotFlow):
def __init__(self, *args,**kwargs):
    super(Command, self).__init__(*args, **kwargs)
    self.next_step_hinting = False


@botflow
def MyFlows1(self, flow: FlowRoot):
    first_step = flow.connect('portscan', auto_trigger=True)
    second_step = first_step.connect("psipaddress")

Tags: theselftruetypingmessagedefstepcontext