Message.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:CorpBot.py 作者: corpnewt 项目源码 文件源码
def say(bot, msg, target, requestor, characters : int = 2000, maxMessage = 5):
    """A helper function to get the bot to cut his text into chunks."""
    if not bot or not msg or not target:
        return False

    textList = textwrap.wrap(msg, characters, break_long_words=True, replace_whitespace=False)

    if not len(textList):
        return False

    if len(textList) > maxMessage and not target == requestor:
        # PM the contents to the requestor
        await bot.send_message(target, "Since this message is *{} pages* - I'm just going to DM it to you.".format(len(textList)))
        target = requestor

    for message in textList:
        await bot.send_message(target, message)

    return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号