查询webex bot并等待答案

问题描述

我想向Cisco webexteams机器人发送查询,以检查与Cisco设备有关的各种参数。我已经成功地编写了一些有效的代码,但是它依靠sleep来等待响应,例如:

try:
    sent_message = api.messages.create(room.id,text=MODEL)
    time.sleep(3)

    messages_in_room = api.messages.list(room.id)
    for message in messages_in_room:
        if message.markdown is not None:
            returned_mes = message
            break
except ApiError as e:
    print(e)

我希望首先,将GeneratorContainer(messages_in_room)设置为max=2时,仅返回最新的2条消息。没有。 我对if message.markdown is not None进行了一些笨拙的检查,以区分send_message和消息。它们的格式分别如下:

{
  "id": "abc","roomId": "bcd","roomType": "direct","text": "MyModel","personId": "cde","personEmail": "[email protected]","created": "2020-09-23T12:39:57.894Z"
}


{
  "id": "xyz","text": "Returned text","personId": "pqr","personEmail": "[email protected]","markdown": "moreblah","html": "<p>blah</p>","created": "2020-09-23T12:39:59.745Z"
}

在异步设置(如RabbitMQ)中,您会获得某种syncID,但这里的ID与您发送的内容和您检索的内容都不匹配,但roomID除外,但是使用此方法无助于区分在“匹配”的消息对之间,因为该RoomID下已经存在几条消息。我想知道其他人如何规避了这个问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)