コード例 #1
0
ファイル: pcr_gacha.py プロジェクト: Hidoshikun/MadaoBot
async def tenjou(session: CommandSession):
    user_id = session.ctx['user_id']
    if not util.check_interval(user_id, __module__, 60):
        msg = "您抽的太快啦,请让Madao休息一下,过几分钟再抽吧~"
        await session.send(msg)
        return

    at_msg = ''
    if session.ctx['message_type'] == 'group':
        at_msg = '[CQ:at,qq={}]\n'.format(str(user_id))

    up_str = ""
    for c in up:
        up_str += " " + str(c) + "★3"
    at_msg += "本期up角色:" + up_str
    at_msg += "\n本次抽卡结果:"

    up_num, star1_num, star2_num, star3_num, result, first_up = gacha10(
        0, 0, 0, 0, 0, [], 0)

    text_result = ""

    name = session.ctx['user_id']
    count = 0
    w = 4
    h = math.ceil(len(result) / w)
    background = Image.new('RGBA', (w * 65 + 5, h * 65 + 5),
                           color='lavenderblush')
    for y in range(h):
        for x in range(w):
            if count < len(result):
                pic = Image.open(os.path.join(res_root,
                                              result[count] + '.png'))
                background.paste(pic, (x * 65 + 5, y * 65 + 5))
                count += 1

    background.save(res_root + f'\\out\\{name}.png')

    text_result += "\n★3数量{}, ★2数量{}".format(star3_num + up_num, star2_num)

    text_result += ", 女神密石数量{}".format(star3_num * 50 + star2_num * 10 +
                                       star1_num)

    if first_up == 0:
        text_result += ", 并没有抽出本期up,恭喜你遇见了12%的概率,还是乖乖去井出来吧"
    elif first_up <= 40:
        text_result += ", 在第{}抽抽出了本期up,你的喜悦我收到了,滚回去喂鲨鱼吧".format(first_up)
    elif first_up <= 100:
        text_result += ", 在第{}抽抽出了本期up,亚洲中上水平,请烧香拜佛再接再厉".format(first_up)
    elif first_up <= 220:
        text_result += ", 在第{}抽抽出了本期up,平均水平,咱就有事没事日行一善攒点人品吧".format(first_up)
    else:
        text_result += ", 在第{}抽抽出了本期up,咱们好歹出货了就不讲究什么了".format(first_up)

    util.set_interval(user_id, __module__)
    await session.send(at_msg +
                       f'[CQ:image,file=file:///{res_root}\\out\\{name}.png]' +
                       text_result)
コード例 #2
0
ファイル: fgo_gacha.py プロジェクト: Hidoshikun/MadaoBot
async def gacha(session: CommandSession):
    user_id = session.ctx['user_id']
    if not util.check_interval(user_id, __module__, 60):
        session.finish('您抽的太快了,请让Madao休息一下,过几分钟后再来查吧', at_sender=True)

    at_msg = ''
    if session.ctx['message_type'] == 'group':
        at_msg = '[CQ:at,qq={}]\n'.format(str(user_id))

    at_msg += "本期卡池:" + pool_name + "\n"
    limit_chara = ""
    for c in limited_s5_servant:
        limit_chara += " " + str(c) + "★5"
    for c in limited_s3_servant:
        limit_chara += " " + str(c) + "★3"
    at_msg += "本期限定:" + limit_chara + "\n"
    recmd_chara = ""
    for c in recommend_s4_servant:
        recmd_chara += " " + str(c) + "★4"
    for c in recommend_s3_servant:
        recmd_chara += " " + str(c) + "★3"
    at_msg += "本期推荐:" + recmd_chara + "\n"

    at_msg += "本次抽卡结果:\n"

    text_result = ""

    results = gacha_ten()
    ls5_servant, ns5_servant, _ls5_craft, _ns5_craft = filter_s5(results)

    name = session.ctx['user_id']
    count, width, height, space = 0, 132, 144, 10
    background = Image.new('RGBA', (width * 5 + space, height * 2 + space), color='lavenderblush')

    for x in range(5):
        for y in range(2):
            pic = Image.open(os.path.join(res_root, results[count] + '.jpg'))
            background.paste(pic, (x * width + space, y * height + space))
            count += 1
    background.save(res_root + f'\\out\\{name}.png')

    if len(ls5_servant) == 0 and len(ns5_servant) == 0:
        text_result += "木有五星也没事,相信自己,下一发就出聊"
    elif len(ls5_servant) == 1 and len(ns5_servant) == 0:
        text_result += "本期限定get,恭喜恭喜,今天这么开心不如给大伙们发个红包吧"
    elif len(ls5_servant) == 0 and len(ns5_servant) == 1:
        text_result += "五星从者+1,感觉来了,不要停下来啊~~"
    elif len(ls5_servant) + len(ns5_servant) > 1:
        text_result += "五星数量" + str(len(ls5_servant) + len(ns5_servant)) + ", 啊这,先提前谢谢老板(伸手"
    text_result += "\n--- 抽卡形式仅为猜测,请以实际情况为准,P.S.卡池太大懒得维护了,凑合抽吧 --- "

    util.set_interval(user_id, __module__)
    await session.send(at_msg + f'[CQ:image,file=file:///{res_root}\\out\\{name}.png]\n' + text_result)
コード例 #3
0
ファイル: pcr_jjc.py プロジェクト: Hidoshikun/MadaoBot
async def jjc_search(session: CommandSession):
    user_id = session.ctx['user_id']
    if not util.check_interval(user_id, __module__, 60):
        session.finish('您查询的太快了,请让Madao休息一下,过几分钟后再来查吧', at_sender=True)

    name_list = session.current_arg_text.strip()
    name_list = re.sub(r'[??,,_]', ' ', name_list)
    name_list = name_list.split()
    if 0 >= len(name_list):
        session.finish('请输入防守方角色,用空格隔开', at_sender=True)
    if 5 < len(name_list):
        session.finish('编队不能多于5名角色', at_sender=True)

    it = []
    id_list = []
    for i in name_config.values():
        it += i
    for n in name_list:
        if n not in it:
            session.finish(f'Madao暂时不知道{n}是谁哦,请换个名称查询', at_sender=True)
        for i, j in name_config.items():
            if n in j:
                id_list.append(int(i))
    for i in id_list:
        if id_list.count(i) >= 2:
            session.finish(f'查询列表中有重复的角色 {name_config[str(i)][1]},请重新查询',
                           at_sender=True)

    try:
        result = await do_search(id_list)
        if not result:
            await session.send('好像没有找到解法,请开动想象力自由发挥吧', at_sender=True)
        else:
            if session.ctx['message_type'] == 'group':
                at_msg = '[CQ:at,qq={}]'.format(str(user_id))
            else:
                at_msg = "您"

            msg = "当前防守阵容:" + str([id2name(i) for i in id_list]) + "\n"
            msg += "已为骑士君" + at_msg + "查询到排名前五的解法:\n"
            for r in result:
                msg += r.to_text() + "\n"

            msg += "Madao当前仅支持国服查询,Powered by pcrdfans.com"
            util.set_interval(user_id, __module__)
            await session.send(msg)
    except Exception as e:
        msg = "Error: {}".format(type(e))
        await session.send(msg)
コード例 #4
0
async def feedback(session: CommandSession):
    user_id = session.ctx['user_id']
    at_msg = '[CQ:at,qq={}]'.format(str(user_id))
    if not util.check_interval(user_id, __module__, 86400):
        session.finish(at_msg + '每天只能反馈一次哦,明天再来吧', at_sender=True)

    to_user = session.bot.config.SUPERUSERS[0]
    text = session.current_arg
    if not text:
        await session.send(f"留言[空格]后输入您要反馈的内容", at_sender=True)
    else:
        util.set_interval(user_id, __module__)

        await session.bot.send_private_msg(self_id=session.ctx['self_id'], user_id=to_user,
                                           message=f'Q{user_id}@群{session.ctx["group_id"]}\n{text}')
        await session.send(f'您的留言已发送!\n=======\n{text}', at_sender=True)
コード例 #5
0
ファイル: fgo_gacha.py プロジェクト: Hidoshikun/MadaoBot
async def gacha(session: CommandSession):
    user_id = session.ctx['user_id']
    if not util.check_interval(user_id, __module__, 60):
        session.finish('您抽的太快了,请让Madao休息一下,过几分钟后再来查吧', at_sender=True)

    at_msg = ''
    if session.ctx['message_type'] == 'group':
        at_msg = '[CQ:at,qq={}]\n'.format(str(user_id))

    at_msg += "本期卡池:" + pool_name + "\n"
    limit_chara = ""
    for c in limited_s5_servant:
        limit_chara += " " + str(c) + "★5"
    for c in limited_s3_servant:
        limit_chara += " " + str(c) + "★3"
    at_msg += "本期限定:" + limit_chara + "\n"
    recmd_chara = ""
    for c in recommend_s4_servant:
        recmd_chara += " " + str(c) + "★4"
    for c in recommend_s3_servant:
        recmd_chara += " " + str(c) + "★3"
    at_msg += "本期推荐:" + recmd_chara + "\n"

    at_msg += "本次抽卡结果:\n"

    text_result = ""

    results = []
    # 五次十连
    for _ in range(1, 5):
        results.extend(gacha_ten())
    # 六次单抽
    for _ in range(1, 6):
        results.append(gacha_one())

    ls5_servant, ns5_servant, ls5_craft, ns5_craft = filter_s5(results)
    s5_results = ls5_servant + ls5_craft + ns5_servant + ns5_craft
    logger.debug(s5_results)

    if len(s5_results) == 0:
        text_result = "好像没有五星呢,我仿佛听到了钱扔进大海的声音~~~"
    else:
        name = session.ctx['user_id']
        count, width, height, space = 0, 132, 144, 10

        w = 4
        h = math.ceil(len(s5_results) / w)

        background = Image.new('RGBA', (width * w + space, height * h + space), color='lavenderblush')

        for y in range(h):
            for x in range(w):
                if count < len(s5_results):
                    pic = Image.open(os.path.join(res_root, s5_results[count] + '.jpg'))
                    background.paste(pic, (x * width + space, y * height + space))
                    count += 1

        background.save(res_root + f'\\out\\{name}.png')

        if len(ls5_servant) == 0 and len(ns5_servant) == 0:
            text_result += "嗯?一个五星从者都没有吗"
        elif len(ls5_servant) == 1 and len(ns5_servant) == 0:
            text_result += "一般一般,世界第三~"
        elif len(ls5_servant) == 0 and len(ns5_servant) == 1:
            text_result += "五星从者+1,感觉来了,不要停下来啊~~"
        elif len(ls5_servant) + len(ns5_servant) > 1:
            text_result += "五星数量" + str(len(ls5_servant) + len(ns5_servant)) + ", 啊这,已经可以了,你已经很欧了"

        text_result += "\n--- 抽卡形式仅为猜测,请以实际情况为准,P.S.卡池太大懒得维护了,凑合抽吧 --- "
        text_result = f'[CQ:image,file=file:///{res_root}\\out\\{name}.png]\n' + text_result

        util.set_interval(user_id, __module__)

    await session.send(at_msg + text_result)
コード例 #6
0
ファイル: pcr_gacha.py プロジェクト: Hidoshikun/MadaoBot
async def pcr_gacha(session: CommandSession):
    user_id = session.ctx['user_id']
    if not util.check_interval(user_id, __module__, 60):
        session.finish('您抽的太快啦,请让Madao休息一下,一分钟后再抽吧', at_sender=True)

    result = []
    up_num, star3_num, star2_num = 0, 0, 0

    at_msg = ''
    if session.ctx['message_type'] == 'group':
        at_msg = '[CQ:at,qq={}]\n'.format(str(user_id))

    up_str = ""
    for c in up:
        up_str += " " + str(c) + "★★★"
    at_msg += "本期up角色:" + up_str
    at_msg += "\n本次抽卡结果:\n"

    text_result = ""

    for n in range(9):
        i = random.random() * 1000
        if i <= up_prob:
            up_num += 1
            chara = random.choice(up)
            text_result += str(chara) + "★3(up) "
            result.append(chara)
        elif s3_prob >= i > up_prob:  # 3星
            star3_num += 1
            chara = random.choice(star3)
            text_result += str(chara) + "★3 "
            result.append(chara)
        elif s2_prob >= i > s3_prob:  # 2星
            star2_num += 1
            chara = random.choice(star2)
            text_result += str(chara) + "★2 "
            result.append(chara)
        else:  # 1星
            chara = random.choice(star1)
            text_result += str(chara) + "★ "
            result.append(chara)

    if random.random() * 1000 > s3_prob:
        star2_num += 1
        chara = random.choice(star2)
        text_result += str(chara) + "★2 "
        result.append(chara)
    else:
        star3_num += 1
        chara = random.choice(star3)
        text_result += str(chara) + "★3 "
        result.append(chara)

    name = session.ctx['user_id']
    a = 0
    background = Image.new('RGBA', (330, 135), color='lavenderblush')

    for x in range(5):
        for y in range(2):
            pic = Image.open(os.path.join(res_root, result[a] + '.png'))
            background.paste(pic, (x * 65 + 5, y * 65 + 5))
            a += 1
    background.save(res_root + f'\\out\\{name}.png')

    text_result += "\n★3数量{}, ★2数量{}".format(star3_num + up_num, star2_num)

    if up_num >= 1:
        text_result += ",抽到了本期up,大概这就是海豹吧"

    if star3_num + up_num >= 2:
        text_result += ",欧洲狗吃我一刀!"
    elif star3_num == 1:
        text_result += ",有三星就挺好的,你说对不"
    elif star3_num == 0 and up_num == 0 and star2_num == 1:
        text_result += ",19密石get,人生还是如此波澜不惊"
    util.set_interval(user_id, __module__)
    await session.send(
        at_msg + f'[CQ:image,file=file:///{res_root}\\out\\{name}.png]\n' +
        text_result)