gpt4 book ai didi

javascript - 如何更改 Bot/Skype channel 传入消息文本格式

转载 作者:太空宇宙 更新时间:2023-11-03 22:27:07 24 4
gpt4 key购买 nike

机器人模拟器可以很好地处理明文响应,但当我尝试通过 Skype 执行相同操作时,机器人响应为:

I don't understand, please try again

我发现 Skype 会自动格式化电子邮件,将其包装在 <a /> 中。标签 - XMM 格式,我有点困惑应该做什么。我认为将传入文本格式更改为纯文本可以解决此问题。

我发现这就像 similar issue on Github但这是在 C# 上进行的,我使用的是 Node.JS。

如何将 bot/skype channel 的默认文本格式更改为纯文本而不是 markdown,这样 Skype 就不会自动格式化?

更新根据@ezequiel-jadib但仍然没有运气。也许我做错了?

// bot.js
bot.use(...[logger]);

// logger.js
module.exports = exports = {
receive: (e, next) => {
e.textFormat('plain');
logConversation(e);
next();
},
send: (e, next) => {
logConversation(e);
next();
}
};

最佳答案

要解决这种情况,您需要验证是否有 HTML 封装的电子邮件地址,然后从字符串中提取电子邮件部分,然后将其保存到 session.dialogData

例如替换 line 40 :

const usernameOrEmail = session.dialogData.usernameOrEmail = results.response;

与:

// where results.response is in the format '<a href="hello@world.com">hello@world.com</a>'
var exampleEmailWrappedInHtml = results.response;

// validate if we have email wrapped in HTML from Skype
if(exampleEmailWrappedInHtml.match(/<a href="mailto:/i)) {
console.log('HTML wrapped email detected!');
const usernameOrEmail = session.dialogData.usernameOrEmail = exampleEmailWrappedInHtml.split('>')[1].split('<')[0];
} else {
console.log('no match.');
}

关于javascript - 如何更改 Bot/Skype channel 传入消息文本格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44413243/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com