【问题标题】:How to get raw message text (e.g. email address) in Botkit message handler如何在 Botkit 消息处理程序中获取原始消息文本(例如电子邮件地址)
【发布时间】:2016-07-26 08:49:30
【问题描述】:

在 botkit 中,我设置了 message_received 或任何其他处理程序。当我收到消息时,它的text 属性应该包含用户编写的实际消息。不幸的是,当此消息包含例如电子邮件地址 我收到此消息的松弛格式。示例:

用户输入:Hey, send an email to foo@bar.com

botkit 给我:Hey, send an email to <mailto:foo@bar.com|foo@bar.com>

有没有办法以原始形式获取它,或者我应该手动解包?

【问题讨论】:

  • 不是一个重度 botkit 用户,但我相信这直接来自 Slack,并且 botkit 不会对其进行任何进一步的处理。而且我不知道有什么方法可以告诉 Slack 您希望接收原始格式的链接。我认为最好的办法是用手打开它。

标签: node.js slack-api slack botkit


【解决方案1】:

做一些类似的事情:

var matches = response.text.match(/\|.*>/)
log.info("Matches : " + matches)
if (matches) {
    mail = matches[0].substring(1, matches[0].length - 1)
    log.info("Mail : " + mail)
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    • 2016-04-03
    • 2021-02-06
    相关资源
    最近更新 更多