Browse Source

bot res and install to tribes server, deleted field on tribe

push-params
Evan Feenstra 4 years ago
parent
commit
339e895344
  1. 8
      api/bots/mother.ts
  2. 50
      api/controllers/bots.ts
  3. 1
      api/controllers/chatTribes.ts
  4. 5
      api/network/intercept.ts
  5. 24
      api/utils/tribes.ts
  6. 9
      dist/api/bots/mother.js
  7. 2
      dist/api/bots/mother.js.map
  8. 53
      dist/api/controllers/bots.js
  9. 2
      dist/api/controllers/bots.js.map
  10. 1
      dist/api/controllers/chatTribes.js
  11. 2
      dist/api/controllers/chatTribes.js.map
  12. 2
      dist/api/network/intercept.js
  13. 2
      dist/api/network/intercept.js.map
  14. 27
      dist/api/utils/tribes.js
  15. 2
      dist/api/utils/tribes.js.map

8
api/bots/mother.ts

@ -1,6 +1,7 @@
// import * as SphinxBot from '../../../sphinx-bot'
import * as Sphinx from 'sphinx-bot'
import { finalAction } from '../controllers/actions'
import { installBot } from '../controllers/bots'
import * as path from 'path'
import * as WelcomeBot from './welcome'
import * as LoopBot from './loop'
@ -85,8 +86,11 @@ export function init() {
const bot = await getBotByName(botName)
if(bot && bot.uuid) {
console.log('=> FOUDN BOT', bot)
// send msg to bot owner
// await models.ChatBot.create(chatBot)
const chat = await models.Chat.findOne({where:{
uuid: message.channel.id
}})
if(!chat) return
installBot(chat.id, bot)
} else {
const embed = new Sphinx.MessageEmbed()
.setAuthor('MotherBot')

50
api/controllers/bots.ts

@ -20,18 +20,30 @@ export const getBots = async (req, res) => {
}
export const createBot = async (req, res) => {
const { name, webhook } = req.body
const { name, webhook, price_per_use, img, description, tags, } = req.body
const uuid = await tribes.genSignedTimestamp()
const newBot = {
name, uuid, webhook,
id: crypto.randomBytes(12).toString('hex').toUpperCase(),
secret: crypto.randomBytes(16).toString('hex').toUpperCase(),
pricePerUse: 0
pricePerUse: price_per_use||0
}
try {
const owner = await models.Contact.findOne({ where: { isOwner: true } })
const theBot = await models.Bot.create(newBot)
// post to bots.sphinx.chat
tribes.declare_bot({
uuid,
owner_pubkey: owner.publicKey,
price_per_use,
name: name,
description: description||'',
tags: tags||[],
img: img||'',
unlisted:false,
deleted:false,
})
success(res, jsonUtils.botToJson(theBot))
} catch (e) {
failure(res, 'bot creation failed')
@ -50,33 +62,29 @@ export const deleteBot = async (req, res) => {
}
}
// async function broadcastAction(chat,text){
// finalAction(<Action>{
// action:'broadcast',
// text, chatUUID: chat.uuid,
// botName:'MotherBot'
// })
// }
export function installBot(botname, botInTribe) {
console.log("INSTALL BOT NOW")
// search registry for bot (by name)
// need bot uuid and maker pubkey
// send bot_install to bot maker
// generate ChatMember with bot=true
// bot_maker_pubkey, bot_uuid, bot_prefix
export async function installBot(chatId:number, bot_json) {
const {uuid,owner_pubkey,unique_name,price_per_use} = bot_json
const chatBot = {
chatId,
botPrefix: '/' +unique_name,
botType: constants.bot_types.remote,
botUuid: uuid,
botMakerPubkey: owner_pubkey,
pricePerUse: price_per_use
}
console.log("installBot INSTALL BOT NOW",chatBot)
keysendBotInstall(chatBot)
await models.ChatBot.create(chatBot)
}
export async function sendBotInstall(_, b): Promise<boolean> {
export async function keysendBotInstall(b): Promise<boolean> {
return await botKeysend(
constants.message_types.bot_install,
b.botUuid, b.botMakerPubkey, b.pricePerUse,
)
}
export async function sendBotCmd(msg, b): Promise<boolean> {
export async function keysendBotCmd(msg, b): Promise<boolean> {
return await botKeysend(
constants.message_types.bot_cmd,
b.botUuid, b.botMakerPubkey, b.pricePerUse,

1
api/controllers/chatTribes.ts

@ -222,6 +222,7 @@ export async function editTribe(req, res) {
unlisted,
is_private: req.body.private,
app_url,
deleted: false,
})
} catch(e) {
okToUpdate = false

5
api/network/intercept.ts

@ -1,7 +1,7 @@
import {Msg} from './interfaces'
import { models } from '../models'
import {builtinBotEmit,buildBotPayload} from '../bots'
import {sendBotCmd} from '../controllers/bots'
import {keysendBotCmd} from '../controllers/bots'
import * as path from 'path'
import fetch from 'node-fetch'
@ -64,11 +64,10 @@ async function emitMessageToBot(msg, botInTribe): Promise<boolean> {
case constants.bot_types.local:
return postToBotServer(msg, botInTribe)
case constants.bot_types.remote:
return sendBotCmd(msg, botInTribe)
return keysendBotCmd(msg, botInTribe)
default:
return false
}
}
async function postToBotServer(msg, botInTribe): Promise<boolean> {

24
api/utils/tribes.ts

@ -99,7 +99,28 @@ export async function declare({ uuid, name, description, tags, img, group_key, h
}
}
export async function edit({ uuid, host, name, description, tags, img, price_per_message, price_to_join, owner_alias, escrow_amount, escrow_millis, unlisted, is_private, app_url }) {
export async function declare_bot({ uuid, name, description, tags, img, price_per_use, owner_pubkey, unlisted, deleted }) {
const host = getHost()
try {
await fetch('https://' + host + '/bots', {
method: 'POST',
body: JSON.stringify({
uuid, owner_pubkey,
name, description, tags, img: img || '',
price_per_use: price_per_use || 0,
unlisted: unlisted||false,
deleted: deleted||false,
}),
headers: { 'Content-Type': 'application/json' }
})
// const j = await r.json()
} catch (e) {
console.log('[tribes] unauthorized to declare')
throw e
}
}
export async function edit({ uuid, host, name, description, tags, img, price_per_message, price_to_join, owner_alias, escrow_amount, escrow_millis, unlisted, is_private, app_url, deleted }) {
try {
const token = await genSignedTimestamp()
await fetch('https://' + host + '/tribe?token=' + token, {
@ -114,6 +135,7 @@ export async function edit({ uuid, host, name, description, tags, img, price_per
owner_alias,
unlisted: unlisted||false,
private: is_private||false,
deleted: deleted||false,
app_url: app_url||'',
}),
headers: { 'Content-Type': 'application/json' }

9
dist/api/bots/mother.js

@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
// import * as SphinxBot from '../../../sphinx-bot'
const Sphinx = require("sphinx-bot");
const actions_1 = require("../controllers/actions");
const bots_1 = require("../controllers/bots");
const path = require("path");
const WelcomeBot = require("./welcome");
const LoopBot = require("./loop");
@ -92,8 +93,12 @@ function init() {
const bot = yield getBotByName(botName);
if (bot && bot.uuid) {
console.log('=> FOUDN BOT', bot);
// send msg to bot owner
// await models.ChatBot.create(chatBot)
const chat = yield models_1.models.Chat.findOne({ where: {
uuid: message.channel.id
} });
if (!chat)
return;
bots_1.installBot(chat.id, bot);
}
else {
const embed = new Sphinx.MessageEmbed()

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

File diff suppressed because one or more lines are too long

53
dist/api/controllers/bots.js

@ -29,17 +29,29 @@ exports.getBots = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
}
});
exports.createBot = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const { name, webhook } = req.body;
const { name, webhook, price_per_use, img, description, tags, } = req.body;
const uuid = yield tribes.genSignedTimestamp();
const newBot = {
name, uuid, webhook,
id: crypto.randomBytes(12).toString('hex').toUpperCase(),
secret: crypto.randomBytes(16).toString('hex').toUpperCase(),
pricePerUse: 0
pricePerUse: price_per_use || 0
};
try {
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const theBot = yield models_1.models.Bot.create(newBot);
// post to bots.sphinx.chat
tribes.declare_bot({
uuid,
owner_pubkey: owner.publicKey,
price_per_use,
name: name,
description: description || '',
tags: tags || [],
img: img || '',
unlisted: false,
deleted: false,
});
res_1.success(res, jsonUtils.botToJson(theBot));
}
catch (e) {
@ -59,34 +71,35 @@ exports.deleteBot = (req, res) => __awaiter(void 0, void 0, void 0, function* ()
res_1.failure(res, e);
}
});
// async function broadcastAction(chat,text){
// finalAction(<Action>{
// action:'broadcast',
// text, chatUUID: chat.uuid,
// botName:'MotherBot'
// })
// }
function installBot(botname, botInTribe) {
console.log("INSTALL BOT NOW");
// search registry for bot (by name)
// need bot uuid and maker pubkey
// send bot_install to bot maker
// generate ChatMember with bot=true
// bot_maker_pubkey, bot_uuid, bot_prefix
function installBot(chatId, bot_json) {
return __awaiter(this, void 0, void 0, function* () {
const { uuid, owner_pubkey, unique_name, price_per_use } = bot_json;
const chatBot = {
chatId,
botPrefix: '/' + unique_name,
botType: constants.bot_types.remote,
botUuid: uuid,
botMakerPubkey: owner_pubkey,
pricePerUse: price_per_use
};
console.log("installBot INSTALL BOT NOW", chatBot);
keysendBotInstall(chatBot);
yield models_1.models.ChatBot.create(chatBot);
});
}
exports.installBot = installBot;
function sendBotInstall(_, b) {
function keysendBotInstall(b) {
return __awaiter(this, void 0, void 0, function* () {
return yield botKeysend(constants.message_types.bot_install, b.botUuid, b.botMakerPubkey, b.pricePerUse);
});
}
exports.sendBotInstall = sendBotInstall;
function sendBotCmd(msg, b) {
exports.keysendBotInstall = keysendBotInstall;
function keysendBotCmd(msg, b) {
return __awaiter(this, void 0, void 0, function* () {
return yield botKeysend(constants.message_types.bot_cmd, b.botUuid, b.botMakerPubkey, b.pricePerUse, msg.message.content);
});
}
exports.sendBotCmd = sendBotCmd;
exports.keysendBotCmd = keysendBotCmd;
function receiveBotInstall(payload) {
return __awaiter(this, void 0, void 0, function* () {
console.log('=> receiveBotInstall');

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

@ -1 +1 @@
{"version":3,"file":"bots.js","sourceRoot":"","sources":["../../../api/controllers/bots.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,6BAA4B;AAC5B,0CAAyC;AACzC,iCAAgC;AAChC,sCAAkC;AAClC,2CAA0C;AAC1C,sCAA+C;AAC/C,sCAAqC;AAErC,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,6BAA6B,CAAC,CAAC,CAAA;AAEjE,QAAA,OAAO,GAAG,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;IACxC,IAAI;QACF,MAAM,IAAI,GAAG,MAAM,eAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAA;QACvC,aAAO,CAAC,GAAG,EAAE;YACX,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;SAC5C,CAAC,CAAA;KACH;IAAC,OAAO,CAAC,EAAE;QACV,aAAO,CAAC,GAAG,EAAE,SAAS,CAAC,CAAA;KACxB;AACH,CAAC,CAAA,CAAA;AAEY,QAAA,SAAS,GAAG,CAAO,GAAG,EAAE,GAAG,EAAE,EAAE;IAC1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AM,OAAO,GAAG,eAAe,CAAA;QAC/B,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,OAAO;YACb,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,QAAQ;gBACR,OAAO,EAAE,EAAC,OAAO,EAAE,OAAO,IAAE,EAAE,EAAC;gBAC/B,MAAM,EAAE;oBACN,OAAO,EAAE,KAAK,CAAC,SAAS;iBACzB;aACF;YACD,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,aAAa,IAAI,QAAQ,CAAC;SACzC,CAAA;QACD,IAAI;YACF,MAAM,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;YAC/B,OAAO,IAAI,CAAA;SACZ;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,KAAK,CAAA;SACb;IACH,CAAC;CAAA;AAtBD,gCAsBC;AAED,oEAAoE;AAEpE,SAAsB,aAAa,CAAC,OAAO;;QACzC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;QAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC5C,oCAAoC;QAEpC,yCAAyC;QACzC,4CAA4C;QAC5C,gCAAgC;QAChC,qDAAqD;QACrD,oCAAoC;IACtC,CAAC;CAAA;AAVD,sCAUC;AAED,SAAsB,aAAa,CAAC,OAAO;;QACzC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAA;QAC/B,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;QAC5C,uBAAuB;QACvB,8BAA8B;IAEhC,CAAC;CAAA;AAND,sCAMC"}

1
dist/api/controllers/chatTribes.js

@ -210,6 +210,7 @@ function editTribe(req, res) {
unlisted,
is_private: req.body.private,
app_url,
deleted: false,
});
}
catch (e) {

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

File diff suppressed because one or more lines are too long

2
dist/api/network/intercept.js

@ -73,7 +73,7 @@ function emitMessageToBot(msg, botInTribe) {
case constants.bot_types.local:
return postToBotServer(msg, botInTribe);
case constants.bot_types.remote:
return bots_2.sendBotCmd(msg, botInTribe);
return bots_2.keysendBotCmd(msg, botInTribe);
default:
return false;
}

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

@ -1 +1 @@
{"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../api/network/intercept.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,sCAAkC;AAClC,kCAAsD;AACtD,8CAA8C;AAC9C,6BAA4B;AAC5B,2CAA8B;AAE9B,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,IAAG,OAAO,KAAG,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE;YAC5C,OAAO,KAAK,CAAA,CAAC,sCAAsC;SACpD;QACD,MAAM,IAAI,GAAG,MAAM,eAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAC,KAAK,EAAC;gBAC5C,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,IAAI;aACpB,EAAC,CAAC,CAAA;QACH,IAAG,CAAC,IAAI;YAAE,OAAO,KAAK,CAAA;QAEtB,IAAI,OAAO,GAAG,KAAK,CAAA;QAEnB,IAAG,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAC1B,qBAAc,CAAC,GAAG,CAAC,CAAA;YACnB,OAAO,GAAG,IAAI,CAAA;SACf;QACD,IAAG,OAAO;YAAE,OAAO,OAAO,CAAA;QAE1B,MAAM,WAAW,GAAG,MAAM,eAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAC,KAAK,EAAC;gBACtD,MAAM,EAAE,IAAI,CA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ACF,CAAC,CAAA;QACF,OAAO,CAAC,CAAC,EAAE,CAAA;IACb,CAAC;CAAA;AAED,SAAe,YAAY,CAAC,KAAK,EAAE,QAAQ;;QAC1C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACjD,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;SAC5C;IACF,CAAC;CAAA"}

27
dist/api/utils/tribes.js

@ -121,7 +121,31 @@ function declare({ uuid, name, description, tags, img, group_key, host, price_pe
});
}
exports.declare = declare;
function edit({ uuid, host, name, description, tags, img, price_per_message, price_to_join, owner_alias, escrow_amount, escrow_millis, unlisted, is_private, app_url }) {
function declare_bot({ uuid, name, description, tags, img, price_per_use, owner_pubkey, unlisted, deleted }) {
return __awaiter(this, void 0, void 0, function* () {
const host = getHost();
try {
yield node_fetch_1.default('https://' + host + '/bots', {
method: 'POST',
body: JSON.stringify({
uuid, owner_pubkey,
name, description, tags, img: img || '',
price_per_use: price_per_use || 0,
unlisted: unlisted || false,
deleted: deleted || false,
}),
headers: { 'Content-Type': 'application/json' }
});
// const j = await r.json()
}
catch (e) {
console.log('[tribes] unauthorized to declare');
throw e;
}
});
}
exports.declare_bot = declare_bot;
function edit({ uuid, host, name, description, tags, img, price_per_message, price_to_join, owner_alias, escrow_amount, escrow_millis, unlisted, is_private, app_url, deleted }) {
return __awaiter(this, void 0, void 0, function* () {
try {
const token = yield genSignedTimestamp();
@ -137,6 +161,7 @@ function edit({ uuid, host, name, description, tags, img, price_per_message, pri
owner_alias,
unlisted: unlisted || false,
private: is_private || false,
deleted: deleted || false,
app_url: app_url || '',
}),
headers: { 'Content-Type': 'application/json' }

2
dist/api/utils/tribes.js.map

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