Add Transpond Message
Created by: binsee
PR: #727
Read the page code, see the official forwarding message implementation code. And this code is very simple, you can easily in a formal way to achieve forwarding messages, such as the direct forwarding of the received file.
angular.module("Controllers").controller("transpondDialogController", ["$rootScope", "$scope", "$timeout", "$state", "$log", "$document", "chatFactory", "contactFactory", "appFactory", "chatroomFactory", "confFactory", "mmpop", "ngDialog", "utilFactory", "stateManageService", "accountFactory",
function(e, t, a, n, i, o, chatFactory, c, s, l, confFactory, f, u, m, g, accountFactory) {
function h(msg, userName) {
if (e.MsgType != confFactory.MSGTYPE_SYS) {
var newMsg = angular.copy(msg);
newMsg.ToUserName = userName;
newMsg.FromUserName = accountFactory.getUserName();
newMsg.isTranspond = !0;
newMsg.MsgIdBeforeTranspond = msg.MsgIdBeforeTranspond || msg.MsgId;
newMsg._h = void 0;
newMsg._offsetTop = void 0;
newMsg.MMSourceMsgId = msg.MsgId;
newMsg.Scene = 2;
newMsg = chatFactory.createMessage(newMsg);
newMsg.sendByLocal = !1;
newMsg.Content = m.htmlDecode(newMsg.Content.replace(/^@\w+:<br\/>/, ""));
newMsg.MMActualSender = accountFactory.getUserName();
newMsg.MMSendContent && (newMsg.MMSendContent = newMsg.MMSendContent.replace(/^@\w+:\s/, ""));
newMsg.MMDigest && (newMsg.MMDigest = newMsg.MMDigest.replace(/^@\w+:/, ""));
newMsg.MMActualContent && (newMsg.MMActualContent = m.clearHtmlStr(newMsg.MMActualContent.replace(/^@\w+:<br\/>/, "")));
chatFactory.appendMessage(newMsg);
chatFactory.sendMessage(newMsg)
}
}
// ...........
Use:
id='' // roomId or userId
// Room.toString()
// Contact.id
// Message.from()
bot.on('message',async m => {
m.transpond(id)
})