我知道我的问题很奇怪,但是我必须做这样的事情:
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
在轮询功能下有一个装饰器,应调用每个装饰器
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'])