Browse Source

cleanup

push-params
Evan Feenstra 4 years ago
parent
commit
85ce759b91
  1. 27
      api/controllers/bots.ts
  2. 2
      api/network/interfaces.ts
  3. 22
      dist/api/controllers/bots.js
  4. 2
      dist/api/controllers/bots.js.map

27
api/controllers/bots.ts

@ -112,24 +112,21 @@ export async function keysendBotCmd(msg, b): Promise<boolean> {
) )
} }
export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_use, chat_uuid:string, content?:string): Promise<boolean> { export async function botKeysend(msg_type, bot_uuid, botmaker_pubkey, amount, chat_uuid:string, content?:string): Promise<boolean> {
const owner = await models.Contact.findOne({ where: { isOwner: true } }) const owner = await models.Contact.findOne({ where: { isOwner: true } })
const dest = botmaker_pubkey
const MIN_SATS = 3 const MIN_SATS = 3
const destkey = botmaker_pubkey const amt = Math.max(amount || MIN_SATS)
const opts = { const opts = {
dest: destkey, amt,
data: { dest,
data: <network.Msg>{
type: msg_type, type: msg_type,
bot_uuid, bot_uuid,
message: {content: content||''}, message: {content: content||'', amount:amt},
sender: { sender: {pub_key: owner.publicKey, alias: owner.alias},
pub_key: owner.publicKey, chat: {uuid:chat_uuid}
},
chat: {
uuid:chat_uuid
}
}, },
amt: Math.max(price_per_use || MIN_SATS)
} }
try { try {
await network.signAndSend(opts) await network.signAndSend(opts)
@ -166,9 +163,13 @@ export async function receiveBotInstall(payload) {
console.log("CREATE bot MEMBER", botMember) console.log("CREATE bot MEMBER", botMember)
await models.BotMember.create(botMember) await models.BotMember.create(botMember)
} }
//- need to pub back MQTT bot_install?? //- need to pub back MQTT bot_install??
//- and if the pubkey=the botOwnerPubkey, confirm chatbot? //- and if the pubkey=the botOwnerPubkey, confirm chatbot?
// NO - send a /guildjoin msg to BOT lib!
// and add routes to lib express with the strings for MSG_TYPE
// and here - postToBotServer /install (also do this for /uninstall)
} }
// ONLY FOR BOT MAKER // ONLY FOR BOT MAKER

2
api/network/interfaces.ts

@ -11,6 +11,6 @@ export interface Msg {
sender: { sender: {
pub_key: string, pub_key: string,
alias: string, alias: string,
role: number role?: number
} }
} }

22
dist/api/controllers/bots.js

@ -117,25 +117,22 @@ function keysendBotCmd(msg, b) {
}); });
} }
exports.keysendBotCmd = keysendBotCmd; exports.keysendBotCmd = keysendBotCmd;
function botKeysend(msg_type, bot_uuid, botmaker_pubkey, price_per_use, chat_uuid, content) { function botKeysend(msg_type, bot_uuid, botmaker_pubkey, amount, chat_uuid, content) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } }); const owner = yield models_1.models.Contact.findOne({ where: { isOwner: true } });
const dest = botmaker_pubkey;
const MIN_SATS = 3; const MIN_SATS = 3;
const destkey = botmaker_pubkey; const amt = Math.max(amount || MIN_SATS);
const opts = { const opts = {
dest: destkey, amt,
dest,
data: { data: {
type: msg_type, type: msg_type,
bot_uuid, bot_uuid,
message: { content: content || '' }, message: { content: content || '', amount: amt },
sender: { sender: { pub_key: owner.publicKey, alias: owner.alias },
pub_key: owner.publicKey, chat: { uuid: chat_uuid }
},
chat: {
uuid: chat_uuid
}
}, },
amt: Math.max(price_per_use || MIN_SATS)
}; };
try { try {
yield network.signAndSend(opts); yield network.signAndSend(opts);
@ -175,6 +172,9 @@ function receiveBotInstall(payload) {
} }
//- need to pub back MQTT bot_install?? //- need to pub back MQTT bot_install??
//- and if the pubkey=the botOwnerPubkey, confirm chatbot? //- and if the pubkey=the botOwnerPubkey, confirm chatbot?
// NO - send a /guildjoin msg to BOT lib!
// and add routes to lib express with the strings for MSG_TYPE
// and here - postToBotServer /install (also do this for /uninstall)
}); });
} }
exports.receiveBotInstall = receiveBotInstall; exports.receiveBotInstall = receiveBotInstall;

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

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