我可以在python3中调用具有修饰函数名称的函数修饰器吗

问题描述

我知道我的问题很奇怪,但是我必须做这样的事情:

def on_update(self,context):
        self.possibleContext=[r"\/file\/",r"\/anyFile\/"]
        def inner(function,*args,**kwargs):
            self.handlers.append(function)
            #i define result,is the dictionary returned by telegram request
            function(result,**kwargs)
            return update
        return inner

在轮询功能下有一个装饰器,应调用每个装饰器

    def polling(self,timeout: int = 0,**kwargs):
        print(f"Started {self.bot['first_name']} on TeleLib V.{self.version}")
        try:
            update_id = self.getUpdates()[0]['update_id']
        except IndexError:
            update_id = None
        while True:
            try:
                for funct in self.handlers:
#Here i should call the decorator,not the function,because the decorator call the function giving it an argument
            except Error1:
                #here some telegram errors exceptions
            except Error2:
                #ecc
        for update in self.getUpdates(offset=update_id,timeout=timeout):
            update_id = update['update_id'] + 1
            self.polling()
            return update

,这里是一个示例函数

@client.on_update('ciikk')
def funzione(update):
    client.sendMessage(update['message']['chat']['id'],update['message']['text'])

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)