text: from asyncio import Lock, create_task
  from time import time
  
  from pyrogram import filters
  from pyrogram.types import Message
  
  tasks = {}
  TASKS_LOCK = Lock()
  arrow = lambda x: (x.text if x else "") + "\n`→`"
  
  
  def all_tasks():
      return tasks
  
  
  async def add_task(
      taskFunc,
      task_name,
      *args,
      **kwargs,
  ):
  
      async with TASKS_LOCK:
          global tasks
  
          task_id = (list(tasks.keys())[-1] + 1) if tasks else 0
  
          task = create_task(
              taskFunc(*args, **kwargs),
              name=task_name,
          )
          tasks[task_id] = task, int(time())
      return task, task_id
  
  
  async def rm_task(task_id=None):
      global tasks
  
      async with TASKS_LOCK:
          for key, value in list(tasks.items()):
              if value[0].done() or value[0].cancelled():
                  del tasks[key]
  
          if (task_id is not None) and (task_id in tasks):
              task = tasks[task_id][0]
  
              if not task.done():
                  task.cancel()
  
              del tasks[task_id]
  