Browse Source

Some bug fixes in tasks

TheHamkerCat 5 years ago
parent
commit
67493dc841
2 changed files with 12 additions and 15 deletions
  1. 6 11
      wbb/core/tasks.py
  2. 6 4
      wbb/modules/userbot.py

+ 6 - 11
wbb/core/tasks.py

@@ -44,7 +44,7 @@ async def rm_task(task_id=None):
             if value[0].done() or value[0].cancelled():
                 del tasks[key]
 
-        if task_id:
+        if task_id is not None:
             if task_id in tasks:
                 if not tasks[task_id][0].done():
                     tasks[task_id][0].cancel()
@@ -59,22 +59,17 @@ async def rm_task(task_id=None):
 )
 async def task_cancel(_, message: Message):
     m = message
-    r = m.reply_to_message
+    if len(message.text.split()) != 2:
+        return await m.delete()
 
-    if len(m.text.split()) == 2:
-        mid = int(m.text.split(None, 1)[1])
-    else:
-        mid = r.message_id if r else None
+    task_id = int(m.text.split(None, 1)[1])
 
     tasks = all_tasks()
 
-    if not mid or not tasks:
-        return await m.delete()
-
-    if mid not in tasks:
+    if task_id not in tasks:
         return await m.delete()
 
-    await rm_task(mid)
+    await rm_task(task_id)
     await eor(message, text=f"{arrow(m)} Task cancelled")
 
 

+ 6 - 4
wbb/modules/userbot.py

@@ -17,8 +17,8 @@ from pyrogram import filters
 from pyrogram.errors import MessageNotModified
 from pyrogram.types import Message, ReplyKeyboardMarkup
 
-from wbb import (SUDOERS, USERBOT_PREFIX, app, app2,  # don't remove
-                 arq, eor)
+from wbb import app2  # don't remove
+from wbb import SUDOERS, USERBOT_PREFIX, app, arq, eor
 from wbb.core.sections import section
 from wbb.core.tasks import add_task, rm_task
 
@@ -140,13 +140,15 @@ async def executor(client, message: Message):
             quote=False,
         )
         os.remove(filename)
-        return await status.delete()
+        if status:
+            await status.delete()
+        return
 
     # Edit the output if input is edited
     if message.edit_date:
         status_ = await iter_edit(message, final_output)
         if status_ == 0:
-            pass
+            return await message.reply(final_output, quote=True)
         else:
             return
     await eor(status, text=final_output, quote=True)