From fd131b0b1ddb9efe5005165953885a1ea3d67b42 Mon Sep 17 00:00:00 2001 From: Cedric Hoelzl Date: Wed, 1 Jul 2020 11:32:09 +0200 Subject: [PATCH] kk --- config.js | 15 +++++++-------- db.js | 4 ++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/config.js b/config.js index 5d034e6..7592fbc 100644 --- a/config.js +++ b/config.js @@ -60,18 +60,16 @@ module.exports = function(){ { requirements : (bot,event,message)=>{ return new Promise((resolve,reject)=>{ - if(!message.text || message.reply_to_message.text != "Reply to this message with a tracking id") + if(!message.text || message.reply_to_message.text != "Reply to this message with a tracking id.") return reject(400); return resolve(200); }); }, action : (bot,event,message)=>{ - var ids = message.text.replace('.','').split('\n'); - console.log(ids); + var ids = message.text.replace('.','').replace(',','').split('\n'); return db.get_v(event.chat.id).then(res =>{ if(res){ return db.set_v(event.chat.id,res.concat(ids)).then(res=>{ - console.log(res) return event.reply("Added ids to Tracking.", {"parse_mode":"Markdown"}) }); }else{ @@ -96,7 +94,7 @@ module.exports = function(){ }); }, action : (bot,event,data)=>{ - return event.reply("Reply to this message with a tracking id"); + return event.reply("Reply to this message with a tracking id."); } }, { @@ -114,16 +112,17 @@ module.exports = function(){ }); }else{ return db.get_v(event.chat.id).then(res =>{ - + + if(res){ let kb = []; for(var rr in res){ kb.push([bot.mkcb(rr,"del",rr)]) } kb.push([bot.mkcb_close("Close")]); return event.reply( (res+"") , {"reply_markup":Markup.inlineKeyboard(kb),"parse_mode":"Markdown"}); - }).catch(err => { + }else{ return event.reply("*No Tracking To Delete*", {"parse_mode":"Markdown"}) - }) + } } } } diff --git a/db.js b/db.js index dad67ea..b53859c 100644 --- a/db.js +++ b/db.js @@ -42,13 +42,13 @@ module.exports = function(name){ this.set_v = function(cid,v){ return new Promise((resolve, reject)=>{ - resolve(this.db.find({id:cid}).set('tracking',v).write()); + resolve(this.db.get("chats").find({id:cid}).set('tracking',v).write()); }); }; this.get_v = function(cid){ return new Promise((resolve, reject)=>{ - resolve(this.db.find({id:cid}).value()); + resolve(this.db.get("chats").find({id:cid}).value()); }); }