def stateful_wait_for(self, call):
if isinstance(call.func, ast.Attribute):
if call.func.attr in ['wait_for_message', 'wait_for_reaction']:
if self.interactive and not prompt_change(
'A possible change was found to change {} into wait_for.'.format(call.func.attr)
):
return call
event = call.func.attr.split('_')[2]
event = 'message' if event == 'message' else 'reaction_add'
call.func.attr = 'wait_for'
if call.args:
timeout = call.args[0]
call.args = []
call.keywords.append(ast.keyword(arg='timeout', value=timeout))
call.args.insert(0, ast.Str(s=event))
for kw in list(call.keywords):
if kw.arg != 'check' and kw.arg != 'timeout':
call.keywords.remove(kw)
warnings.warn('wait_for change detected. Rewrite removes the author, channel, and content '
'keyword arguments from this method.')
stats_counter['call_changes'] += 1
return call
评论列表
文章目录