栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

添加支票问题

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

添加支票问题

我有一些代码可用于生成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)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/625017.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号