diff --git a/src/mami.js/sockchat_old.js b/src/mami.js/sockchat_old.js
index 6886db0..6dbc219 100644
--- a/src/mami.js/sockchat_old.js
+++ b/src/mami.js/sockchat_old.js
@@ -143,7 +143,16 @@ Umi.Protocol.SockChat.Protocol = function(pingDuration) {
});
};
- const unfuckText = text => text.replace(/
/g, "\n");
+ const unfuckText = (text, isAction) => {
+ // P7.1 doesn't wrap in , likely a bug in SharpChat
+ // check if this is the case with the PHPChat impl
+ if(isAction && text.startsWith(''))
+ text = text.slice(3, -4);
+
+ return text.replace(/
/g, "\n")
+ .replace(/</g, '<')
+ .replace(/>/g, '>');
+ };
const onMessage = ev => {
const args = ev.detail.data.split("\t");
@@ -249,7 +258,8 @@ Umi.Protocol.SockChat.Protocol = function(pingDuration) {
// message add
handlers['2'] = (timeStamp, userId, msgText, msgId, msgFlags) => {
- let mText = unfuckText(msgText);
+ const mFlags = parseMsgFlags(msgFlags);
+ let mText = unfuckText(msgText, mFlags.isAction);
let mChannelName = selfChannelName;
if(msgFlags[4] !== '0') {
@@ -271,7 +281,7 @@ Umi.Protocol.SockChat.Protocol = function(pingDuration) {
id: userId,
self: userId === selfUserId,
},
- flags: parseMsgFlags(msgFlags),
+ flags: mFlags,
flagsRaw: msgFlags,
isBot: userId === '-1',
text: mText,
@@ -433,6 +443,7 @@ Umi.Protocol.SockChat.Protocol = function(pingDuration) {
// existing message
handlers['7']['1'] = (timeStamp, userId, userName, userColour, userPerms, msgText, msgId, msgNotify, msgFlags) => {
+ const mFlags = parseMsgFlags(msgFlags);
const info = {
msg: {
id: msgId,
@@ -448,9 +459,9 @@ Umi.Protocol.SockChat.Protocol = function(pingDuration) {
},
isBot: userId === '-1',
silent: msgNotify === '0',
- flags: parseMsgFlags(msgFlags),
+ flags: mFlags,
flagsRaw: msgFlags,
- text: unfuckText(msgText),
+ text: unfuckText(msgText, mFlags.isAction),
},
};
@@ -465,6 +476,10 @@ Umi.Protocol.SockChat.Protocol = function(pingDuration) {
type: botParts[1],
args: botParts.slice(2),
};
+
+ // i think this is more Inaccurate Behaviour on the server side
+ if(info.msg.botInfo.type === 'say')
+ info.msg.botInfo.args[0] = unfuckText(info.msg.botInfo.args[0]);
}
eventTarget.dispatch('msg:add', info);