def decorator(func: Callable) -> Callable:
            if isinstance(self, pyrogram.Client):
                self.add_handler(pyrogram.CallbackQueryHandler(func, filters),
                                 group)
            elif isinstance(self, Filter) or self is None:
                func.handler = (pyrogram.CallbackQueryHandler(func, self),
                                group if filters is None else filters)

            return func
Exemplo n.º 2
0
        def decorator(func):
            handler = pyrogram.CallbackQueryHandler(func, filters)

            if isinstance(self, Filter):
                return pyrogram.CallbackQueryHandler(
                    func, self), group if filters is None else filters

            if self is not None:
                self.add_handler(handler, group)

            return handler, group
Exemplo n.º 3
0
        def decorator(func: callable) -> Tuple[Handler, int]:
            if isinstance(func, tuple):
                func = func[0].callback

            handler = pyrogram.CallbackQueryHandler(func, filters)

            if isinstance(self, Filter):
                return pyrogram.CallbackQueryHandler(func, self), group if filters is None else filters

            if self is not None:
                self.add_handler(handler, group)

            return handler, group
Exemplo n.º 4
0
 def __init__(self, *args,**kwargs):
     super().__init__(*args,**kwargs)
     super().add_handler(
         pyrogram.CallbackQueryHandler(
             on_callback
         )
     )
 def decorator(func):
     self.add_handler(pyrogram.CallbackQueryHandler(func, filters), group)
     return func
Exemplo n.º 6
0
            description = " " + " \r\n ❤️ @Bfas237Bots "
            sent = bot.send_document(update.from_user.id, required_file_name, progress = prog, progress_args = (update.message.message_id, update.from_user.id, required_file_name), caption='**File Size**: {}\n\n**Completed in**:  `{}` **Seconds**\n'.format(str(pretty_size(total_length)), str(int(t2 - t1))), reply_to_message_id=update.message.message_id)
        
            time.sleep(1)
         
            bot.edit_message_caption(update.from_user.id,sent.message_id, caption='{}'.format(description))
     
            os.remove(required_file_name)
        else:
            bot.edit_message_text(update.from_user.id, update.message.message_id, "No valid Download link was found.\n\n The server terminated all request. Kindly try again")
    except Exception as Err:
        bot.edit_message_text(update.from_user.id, update.message.message_id, Err)
        
        traceback.print_exc()
      
if __name__ == "__main__" :
    # create download directory, if not exist
    if not os.path.isdir(Config.DOWNLOAD_LOCATION):
        os.makedirs(Config.DOWNLOAD_LOCATION)
    app.add_handler(pyrogram.MessageHandler(start, pyrogram.Filters.command(["start"])))
    app.add_handler(pyrogram.MessageHandler(ft, pyrogram.Filters.command(["ft"])))
    app.add_handler(pyrogram.MessageHandler(fo, pyrogram.Filters.command(["fo"])))
    app.add_handler(pyrogram.MessageHandler(search, pyrogram.Filters.command(["search" , "s"])))
    app.add_handler(pyrogram.MessageHandler(help, pyrogram.Filters.command(["help"])))
    app.add_handler(pyrogram.MessageHandler(messages, pyrogram.Filters.text))
    app.add_handler(pyrogram.CallbackQueryHandler(button))
    app.run()