正确使用Errbot中的流

时间:2019-04-10 14:36:19

标签: python errbot

我正在使用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):

运行ports之后,我能否得到以下显示正则表达式的消息,我想将其隐藏。

您的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")

0 个答案:

没有答案