out386 / aria-telegram-mirror-bot

A Telegram bot to download files via HTTP(S)/BitTorrent and upload them to Google Drive
MIT License
518 stars 401 forks source link

Previous status message is not deleting! #84

Closed tmdted closed 4 years ago

tmdted commented 4 years ago

If we did not request /mirrorstatus within few minutes, previous status messages are not deleting and just sleeps after new update request is made.

    } else {
      var ttl = 3600000;
      msgTools.sendMessage(bot, msg, res.message, ttl, message => {
        dlManager.addStatus(message, res.message);
        setTimeout(() => {
          dlManager.deleteStatus(msg.chat.id);
        }, ttl);
        resolve();
      }, true);

ttl = 3600000 which means 1 hour, i made this change in in sendStatusMessage function of index.ts, thus these previous status messages are deleting fine after this 1 hour!! BUT it should be deleted after a new request is made

And also I want the status message to be permanent without this timer, i tried that by setting this to false, but /mirrorstatus message we send is not being deleted after the statusupdate. what to do? anyone help!

out386 commented 4 years ago

If you want status messages sent by /mirrorstatus to not be auto-deleted, change line 95 of index.ts to sendStatusMessage(msg, true);

tmdted commented 4 years ago

Solved! Thanx @out386

out386 commented 4 years ago

What was the solution?

tmdted commented 4 years ago

After this, bot works like a charm Everything else on index.ts is same except this mirrorstatus thing, I did the laststatus deletion here also,thus it runs twice, tho i don't know its necessary or not 🤷‍♂️! I did this because i faced that problem, so Maybe running twice could delete old messages left.. but you see, if sendStatusMessage(msg, true); , there won't be any old messages left undeleted🤷‍♂️ even tho i did this

And very important thing is, if we set sendStatusMessage(msg, true); , the /mirrorstatus message we send won't be deleted after the status message is sent.

Thus i kept a 10 seconds deletion timer for it, so even if any lag also.. the status message will be printed within 10 seconds.. so no worries. But i need an alternate for this, i want the /mirrorstatus msg we send is to be deleted only after status update is send, no timers. But you can see i am not good at coding 😅 Suggest something efficient. @out386

Screenshot-20200225-003007-01.jpg