添加支票问题

添加支票问题,第1张

添加支票问题

我有一些代码可用于生成check函数

wait_for
。以下是我用来等待消息的方法

from collections.abc import Sequencedef make_sequence(seq):    if seq is None:        return ()    if isinstance(seq, Sequence) and not isinstance(seq, str):        return seq    else:        return (seq,)def message_check(channel=None, author=None, content=None, ignore_bot=True, lower=True):    channel = make_sequence(channel)    author = make_sequence(author)    content = make_sequence(content)    if lower:        content = tuple(c.lower() for c in content)    def check(message):        if ignore_bot and message.author.bot: return False        if channel and message.channel not in channel: return False        if author and message.author not in author: return False        actual_content = message.content.lower() if lower else message.content        if content and actual_content not in content: return False        return True    return check

然后,您可以轻松地将想要接收的消息的要求传递给

wait_for

check = message_check(author=ctx.author, channel=ctx.channel, content=('y', 'yes'))msg = await self.bot.wait_for("message", timeout=20.0, check=check)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5630902.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存