gpt4 book ai didi

javascript - Rocket.Chat自定义JavaScript拦截新消息

转载 作者:行者123 更新时间:2023-12-03 00:06:15 48 4
gpt4 key购买 nike

我想知道是否可以拦截通过 Rocket.Chat“自定义脚本”管理部分收到的新消息

最佳答案

编辑/app/ui-message/client/message.js并将以下代码插入Template.message.onCreated

...
Template.message.onCreated(function(){
const {...} ...;

if(typeof window.onMessage==="function"){
window.onMessage(msg);
}

...
});
...

然后在您的自定义 JavaScript 中创建一个带有消息参数的函数,如下所示。

window.onMessage=(msg)=>{
console.log("received message",msg);
}

这将允许您后处理消息,而无需重新编译 Rocket.Chat。

关于javascript - Rocket.Chat自定义JavaScript拦截新消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54953300/

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