dokidoki.py 文件源码

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

项目:apex-sigma-plugins 作者: lu-ci 项目源码 文件源码
def dokidoki(cmd, message, args):
    char_letters = ['m', 'n', 'y', 's']
    char = None
    glitch = False
    if args:
        if args[0][0].lower() in char_letters:
            char = args[0][0].lower()
        if args[-1].startswith(':g'):
            glitch = True
    if not char:
        char = secrets.choice(char_letters)
    char_file = files[char]
    with open(f'doki/{char_file}.luci', 'rb') as quote_file:
        quotes = quote_file.read()
    key = cmd.bot.cfg.pref.raw.get('key_to_my_heart')
    if key:
        key = key.encode('utf-8')
        cipher = Fernet(key)
        try:
            ciphered = cipher.decrypt(quotes).decode('utf-8')
        except InvalidToken:
            ciphered = None
        if ciphered:
            if not glitch:
                glitch = secrets.randbelow(6)
                glitch = not bool(glitch)
            if glitch:
                line_count = 1
                thumbnail = chars_glitch[char]
            else:
                line_count = 3
                thumbnail = secrets.choice(chars[char])
            lines = []
            for x in range(0, line_count):
                output = markovify.Text(ciphered).make_short_sentence(500, tries=100)
                output = clean(output, message.author)
                if glitch:
                    output = cipher.encrypt(output.encode('utf-8')).decode('utf-8')
                lines.append(output)
            output_final = ' '.join(lines)
            if glitch:
                title = titles_glitch[char]
            else:
                title = titles[char]
            response = discord.Embed(color=0xe75a70)
            response.add_field(name=f'?? {title}', value=output_final)
            response.set_thumbnail(url=thumbnail)
        else:
            response = discord.Embed(color=0xe75a70, title='?? Sorry but that key is incorrect!')
    else:
        response = discord.Embed(color=0xe75a70, title='?? You are missing the key to my heart!')
    await message.channel.send(embed=response)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号