我可以调用python3中具有修饰函数名的函数装饰器吗
我知道我的问题很奇怪,但我必须这样做:我可以调用python3中具有修饰函数名的函数装饰器吗,python,python-3.x,telegram,telegram-bot,Python,Python 3.x,Telegram,Telegram Bot,我知道我的问题很奇怪,但我必须这样做: def on_update(self, context): self.possibleContext=[r"\/file\/",r"\/anyFile\/"] def inner(function, *args, **kwargs): self.handlers.append(function) #i define result, is
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, *args, **kwargs)
return update
return inner
在轮询函数下有一个decorator,它应该调用每个decorator
def polling(self, timeout: int = 0, *args, **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'])