text: import os, datetime, glob, subprocess, json
  from pyrogram import Client, filters
  from pyromod import listen
  from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
  from hachoir.parser import createParser
  from hachoir.metadata import extractMetadata
  
  previous_cut_time = '02:00:04'
  
  
  if 'BOT_TOKEN' in os.environ:
      BOT_TOKEN = os.environ.get("BOT_TOKEN")
      API_ID = os.environ.get("API_ID")
      API_HASH = os.environ.get("API_HASH")
  else:
      BOT_TOKEN = " "
      API_ID = " "
      API_HASH = " "
  
  
  Bot = Client(
      ":memory:",
      bot_token = BOT_TOKEN,
      api_id = API_ID,
      api_hash = API_HASH
  )
  
  refresh_button = [
      InlineKeyboardButton(
          text='Refresh List',
          callback_data='refresh'
      )
  ]
  
  msgid = 0
  chatid = 0
  @Bot.on_message(filters.text & ~filters.regex('/previous'))
  async def start(bot, m):
      keyboard = []
      keyboard.append(refresh_button)
      try:
          for file in glob.glob('C:/dlmacvin/1aa/*'):
              keyboard.append(
                  [
                      InlineKeyboardButton(
                          text=file.rsplit('/', 1)[1].replace('1aa\\', ''),
                          callback_data=file.rsplit('/', 1)[1].replace('1aa\\', '')
                      )
                  ]
              )
      except Exception as e:
          print(e)
          return
      keyboard.append(refresh_button)
      await m.reply_text(text="Which one?", reply_markup=InlineKeyboardMarkup(keyboard))
  
  
  @Bot.on_callback_query()
  async def callback(bot, update):
      global chatid, msgid, previous_cut_time
      if update.data == "refresh":
          keyboard = []
          keyboard.append(refresh_button)
          try:
              for file in glob.glob('C:/dlmacvin/1aa/*'):
                  keyboard.append(
                      [
                          InlineKeyboardButton(
                              text=file.rsplit('/', 1)[1].replace('1aa\\', ''),
                              callback_data=file.rsplit('/', 1)[1].replace('1aa\\', '')
                          )
                      ]
                  )
          except Exception as e:
              print(e)
              return
          keyboard.append(refresh_button)
          try:
              await update.message.edit(text=f"Which one of these {len(keyboard)} videos?", reply_markup=InlineKeyboardMarkup(keyboard))
          except:
              await update.message.reply_text("error!! Send /start")
          return
      try:
          name = update.data
          input = 'C:/dlmacvin/1aa/' + name
          metadata = extractMetadata(createParser(input))
          duration = int(metadata.get('duration').seconds)
          dtime = str(datetime.timedelta(seconds=duration))[:11]
          ask = await update.message.reply_text(f'تایم کل ویدیو : {dtime} \n\nجهت کات ویدیو تایم را به این صورت ارسال کنید \n 00:00:00 02:10:00 \n\nOr send /previous to keep the previous cut time.')
          time: Message = await bot.listen(update.message.chat.id, filters=filters.text)
          if time.text == "/previous":
              end = previous_cut_time
          else:
              end = f'0{time.text[:1]}:{time.text[:3][1:]}:{time.text[3:]}'
              previous_cut_time = end
          start = "00:00:00"
          await time.delete(True)
          await ask.delete()
          process_msg = await update.message.reply_text('Processing..')
          ext = '.' + name.rsplit('.', 1)[1]
          end_sec = sum(x * int(t) for x, t in zip([1, 60, 3600], reversed(end)))
          os.system(f'''ffmpeg -ss {start} -i "{input}" -to {end} -c copy "C:/dlmacvin/1aa/videos/{name.replace(ext, '-0'+ext)}"''')
          cut_steps = []
          dif = duration - int(end_sec)
          for i in range(dif // 10):
              cut_steps.append(i * 10)
          for step in cut_steps:
              stp = str(end_sec + step)
              os.system(f'''ffmpeg -ss {start} -i "{input}" -to {stp} -c copy "C:/dlmacvin/1aa/videos/{name.replace(ext, '-'+str(step/10)+ext)}"''')
          await process_msg.delete()
          if chatid == 0:
              msg = await update.message.reply_text('Done! ' + name)
              msgid = msg.message_id
          elif chatid != 0:
              try:
                  await bot.edit_message_text(update.message.chat.id, msgid, 'Done! ' + name)
              except:
                  await bot.edit_message_text(update.message.chat.id, msgid, 'تمام')
          chatid = update.message.from_user.id
      except Exception as e:
          print(e)
  
  
  
  Bot.run()
  