diff --git a/api/network/intercept.ts b/api/network/intercept.ts index aec9d10..2a09537 100644 --- a/api/network/intercept.ts +++ b/api/network/intercept.ts @@ -14,11 +14,9 @@ restrictions (be able to toggle, or dont show chat) export async function isBotMsg(msg:Msg, sentByMe:boolean): Promise { const txt = msg.message.content const msgType = msg.type - console.log("isBotMsg MSG TYPE", msgType) if(msgType===constants.message_types.bot_res) { return false // bot res msg type not for processing } - console.log("SEND IT AWAYYYYY!") const chat = await models.Chat.findOne({where:{ uuid: msg.chat.uuid }}) @@ -41,15 +39,19 @@ export async function isBotMsg(msg:Msg, sentByMe:boolean): Promise { if(!(botsInTribe && botsInTribe.length)) return false await asyncForEach(botsInTribe, async botInTribe=>{ - console.log('botInTribe.botPrefix',botInTribe.botPrefix) - if(botInTribe.msgTypes){ - try { - const msgTypes = JSON.parse(botInTribe.msgTypes) - if(msgTypes.includes(msgType)){ - builtinBotEmit(msg) - didEmit = true - } - } catch(e){} + if(txt && txt.startsWith(`${botInTribe.botPrefix} `)) { + if(botInTribe.msgTypes){ + try { + const msgTypes = JSON.parse(botInTribe.msgTypes) + if(msgTypes.includes(msgType)){ + builtinBotEmit(msg) + didEmit = true + } + } catch(e){} + } else { // no message types defined, do all? + builtinBotEmit(msg) + didEmit = true + } } }) diff --git a/dist/api/network/intercept.js b/dist/api/network/intercept.js index 0e03dd6..f45a3a5 100644 --- a/dist/api/network/intercept.js +++ b/dist/api/network/intercept.js @@ -22,11 +22,9 @@ function isBotMsg(msg, sentByMe) { return __awaiter(this, void 0, void 0, function* () { const txt = msg.message.content; const msgType = msg.type; - console.log("isBotMsg MSG TYPE", msgType); if (msgType === constants.message_types.bot_res) { return false; // bot res msg type not for processing } - console.log("SEND IT AWAYYYYY!"); const chat = yield models_1.models.Chat.findOne({ where: { uuid: msg.chat.uuid } }); @@ -46,16 +44,21 @@ function isBotMsg(msg, sentByMe) { if (!(botsInTribe && botsInTribe.length)) return false; yield asyncForEach(botsInTribe, (botInTribe) => __awaiter(this, void 0, void 0, function* () { - console.log('botInTribe.botPrefix', botInTribe.botPrefix); - if (botInTribe.msgTypes) { - try { - const msgTypes = JSON.parse(botInTribe.msgTypes); - if (msgTypes.includes(msgType)) { - bots_1.builtinBotEmit(msg); - didEmit = true; + if (txt && txt.startsWith(`${botInTribe.botPrefix} `)) { + if (botInTribe.msgTypes) { + try { + const msgTypes = JSON.parse(botInTribe.msgTypes); + if (msgTypes.includes(msgType)) { + bots_1.builtinBotEmit(msg); + didEmit = true; + } } + catch (e) { } + } + else { // no message types defined, do all? + bots_1.builtinBotEmit(msg); + didEmit = true; } - catch (e) { } } })); return didEmit; diff --git a/dist/api/network/intercept.js.map b/dist/api/network/intercept.js.map index b08bcfa..a6d8451 100644 --- a/dist/api/network/intercept.js.map +++ b/dist/api/network/intercept.js.map @@ -1 +1 @@ -{"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../api/network/intercept.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,sCAAkC;AAClC,kCAAsC;AACtC,6BAA4B;AAE5B,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAC,6BAA6B,CAAC,CAAC,CAAA;AAE7E;;;EAGE;AAEF,kDAAkD;AAClD,SAAsB,QAAQ,CAAC,GAAO,EAAE,QAAgB;;QACtD,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,CAAA;QAC/B,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,CAAA;QACxB,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAA;QACzC,IAAG,OAAO,KAAG,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE;YAC5C,OAAO,KAAK,CAAA,CAAC,sCAAsC;SACpD;QACD,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;QAChC,MAAM,IAAI,GAAG,MAAM,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAC,KAAK,EAAC;gBAC5C,IAAI,EA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