Browse Source

local bot install post msg, loop res msg

push-params
Evan Feenstra 4 years ago
parent
commit
582623ac75
  1. 4
      api/builtin/loop.ts
  2. 16
      api/controllers/bots.ts
  3. 4
      dist/api/builtin/loop.js
  4. 2
      dist/api/builtin/loop.js.map
  5. 16
      dist/api/controllers/bots.js
  6. 2
      dist/api/controllers/bots.js.map

4
api/builtin/loop.ts

@ -66,13 +66,13 @@ export function init() {
message.channel.send({ embed })
return
}
if(!(j2&&j2.message)) {
if(!(j2&&j2.server_message)) {
return
}
const embed = new Sphinx.MessageEmbed()
.setAuthor('LoopBot')
.setTitle('Loop Initialized!')
.setDescription(j2.message)
.setDescription('Success!')
message.channel.send({ embed })
return
} catch (e) {

16
api/controllers/bots.ts

@ -94,8 +94,22 @@ export async function installBot(chat, bot_json) {
pricePerUse: price_per_use
}
if(isLocal) {
await models.ChatBot.create(chatBot)
// "install" my local bot and send "INSTALL" event
const myBot = await models.Bot.findOne({where:{
uuid: bot_json.uuid
}})
if(myBot) {
await models.ChatBot.create(chatBot)
postToBotServer(<network.Msg>{
type: constants.message_types.bot_install,
bot_uuid: myBot.uuid,
message: {content:'', amount:0},
sender: {pub_key: owner.publicKey, alias: owner.alias},
chat: {uuid:chat_uuid}
}, myBot, SphinxBot.MSG_TYPE.INSTALL)
}
} else {
// keysend to bot maker
console.log("installBot INSTALL REMOTE BOT NOW",chatBot)
const succeeded = await keysendBotInstall(chatBot, chat_uuid)
if(succeeded) {

4
dist/api/builtin/loop.js

@ -73,13 +73,13 @@ function init() {
message.channel.send({ embed });
return;
}
if (!(j2 && j2.message)) {
if (!(j2 && j2.server_message)) {
return;
}
const embed = new Sphinx.MessageEmbed()
.setAuthor('LoopBot')
.setTitle('Loop Initialized!')
.setDescription(j2.message);
.setDescription('Success!');
message.channel.send({ embed });
return;
}

2
dist/api/builtin/loop.js.map

@ -1 +1 @@
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../../api/builtin/loop.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA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/bots.js

@ -102,9 +102,23 @@ function installBot(chat, bot_json) {
pricePerUse: price_per_use
};
if (isLocal) {
yield models_1.models.ChatBot.create(chatBot);
// "install" my local bot and send "INSTALL" event
const myBot = yield models_1.models.Bot.findOne({ where: {
uuid: bot_json.uuid
} });
if (myBot) {
yield models_1.models.ChatBot.create(chatBot);
postToBotServer({
type: constants.message_types.bot_install,
bot_uuid: myBot.uuid,
message: { content: '', amount: 0 },
sender: { pub_key: owner.publicKey, alias: owner.alias },
chat: { uuid: chat_uuid }
}, myBot, SphinxBot.MSG_TYPE.INSTALL);
}
}
else {
// keysend to bot maker
console.log("installBot INSTALL REMOTE BOT NOW", chatBot);
const succeeded = yield keysendBotInstall(chatBot, chat_uuid);
if (succeeded) {

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

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