Browse Source

delay builtinBotEmit, bot_res doesnt require bot_uuid

push-params
Evan Feenstra 5 years ago
parent
commit
316966d83b
  1. 4
      api/bots/index.ts
  2. 12
      api/network/receive.ts
  3. 4
      dist/api/bots/index.js
  4. 2
      dist/api/bots/index.js.map
  5. 14
      dist/api/network/receive.js
  6. 2
      dist/api/network/receive.js.map

4
api/bots/index.ts

@ -48,7 +48,9 @@ function buildBotPayload(msg:Msg): SphinxBot.Message {
}
function builtinBotEmit(msg:Msg){
SphinxBot._emit('message', buildBotPayload(msg))
setTimeout(()=>{
SphinxBot._emit('message', buildBotPayload(msg))
},1200)
}
export {init,builtinBotEmit,buildBotPayload}

12
api/network/receive.ts

@ -34,19 +34,25 @@ const typesThatNeedPricePerMessage = [
export const typesToReplay=[ // should match typesToForward
msgtypes.message, msgtypes.group_join, msgtypes.group_leave
]
const botMakerTypes=[
const botTypes=[
constants.message_types.bot_install,
constants.message_types.bot_cmd,
constants.message_types.bot_res,
]
const botMakerTypes=[
constants.message_types.bot_install,
constants.message_types.bot_cmd,
]
async function onReceive(payload){
console.log('===> onReceive',JSON.stringify(payload,null,2))
if(!(payload.type||payload.type===0)) return console.log('no payload.type')
if(botMakerTypes.includes(payload.type)) {
if(botTypes.includes(payload.type)) {
// if is admin on tribe? or is bot maker?
console.log("=> got bot msg type!!!!")
if(!payload.bot_uuid) return console.log('no bot uuid')
if(botMakerTypes.includes(payload.type)) {
if(!payload.bot_uuid) return console.log('bot maker type: no bot uuid')
}
return ACTIONS[payload.type](payload)
}

4
dist/api/bots/index.js

@ -60,7 +60,9 @@ function buildBotPayload(msg) {
}
exports.buildBotPayload = buildBotPayload;
function builtinBotEmit(msg) {
SphinxBot._emit('message', buildBotPayload(msg));
setTimeout(() => {
SphinxBot._emit('message', buildBotPayload(msg));
}, 1200);
}
exports.builtinBotEmit = builtinBotEmit;
//# sourceMappingURL=index.js.map

2
dist/api/bots/index.js.map

@ -1 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../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AAA;IACN,CAAC;CAAA;AAgCO,oBAAI;AA9BZ,SAAS,eAAe,CAAC,GAAO;IAC5B,MAAM,CAAC,GAAsB;QACzB,OAAO,EAAC;YACJ,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI;YACjB,IAAI,EAAC,cAAW,CAAC;SACpB;QACD,KAAK,EAAC,cAAW,CAAC;QAClB,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO;QAC5B,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM;QAC1B,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,MAAM,EAAE;YACJ,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,OAAO;YACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK;YAC1B,KAAK,EAAC,EAAE;SACX;KACJ,CAAA;IACD,IAAG,GAAG,CAAC,MAAM,CAAC,IAAI,KAAG,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE;QAC7C,IAAG,CAAC,CAAC,MAAM;YAAE,CAAC,CAAC,MAAM,CAAC,KAAK,GAAC,CAAC;oBACzB,IAAI,EAAC,OAAO;iBACf,CAAC,CAAA;KACL;IACD,OAAO,CAAC,CAAA;AACZ,CAAC;AAQ2B,0CAAe;AAN3C,SAAS,cAAc,CAAC,GAAO;IAC3B,UAAU,CAAC,GAAE,EAAE;QACX,SAAS,CAAC,KAAK,CAAC,SAAS,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAA;IACpD,CAAC,EAAC,IAAI,CAAC,CAAA;AACX,CAAC;AAEY,wCAAc"}

14
dist/api/network/receive.js

@ -42,21 +42,27 @@ const typesThatNeedPricePerMessage = [
exports.typesToReplay = [
msgtypes.message, msgtypes.group_join, msgtypes.group_leave
];
const botMakerTypes = [
const botTypes = [
constants.message_types.bot_install,
constants.message_types.bot_cmd,
constants.message_types.bot_res,
];
const botMakerTypes = [
constants.message_types.bot_install,
constants.message_types.bot_cmd,
];
function onReceive(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log('===> onReceive', JSON.stringify(payload, null, 2));
if (!(payload.type || payload.type === 0))
return console.log('no payload.type');
if (botMakerTypes.includes(payload.type)) {
if (botTypes.includes(payload.type)) {
// if is admin on tribe? or is bot maker?
console.log("=> got bot msg type!!!!");
if (!payload.bot_uuid)
return console.log('no bot uuid');
if (botMakerTypes.includes(payload.type)) {
if (!payload.bot_uuid)
return console.log('bot maker type: no bot uuid');
}
return controllers_1.ACTIONS[payload.type](payload);
}
// if tribe, owner must forward to MQTT

2
dist/api/network/receive.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save