コード例 #1
0
async def lssv(bot, ev: EventInterface):
    parser = ArgumentParser()
    parser.add_argument('-a', '--all', action='store_true')
    parser.add_argument('-i', '--invisible', action='store_true')
    parser.add_argument('-g', '--group', type=int, default=0)
    args = parser.parse_args(ev.get_param().remain)

    verbose_all = args.all
    only_hidden = args.invisible
    if ev.get_author_id() in bot.config.SUPER_USER:
        gid = args.group or ev.get_group_id()
        if not gid:
            await bot.send(ev, 'Usage: -g|--group <group_id> [-a|--all]')
            return
    else:
        gid = ev.get_group_id()

    msg = [f"群{gid}服务一览:"]
    svs = Service.get_loaded_services().values()
    svs = map(lambda sv: (sv, sv.check_enabled(gid)), svs)
    key = cmp_to_key(lambda x, y: (y[1] - x[1]) or (-1 if x[0].name < y[
        0].name else 1 if x[0].name > y[0].name else 0))
    svs = sorted(svs, key=key)
    for sv, on in svs:
        if verbose_all or (sv.visible ^ only_hidden):
            x = '○' if on else '×'
            msg.append(f"|{x}| {sv.name}")
    await bot.send(ev, '\n'.join(msg))
コード例 #2
0
ファイル: whois.py プロジェクト: IgNit3R/KokkoroBot-discord
async def whois(bot, ev: EventInterface):
    uid = ev.get_author_id
    if not lmt.check(uid):
        await bot.send(ev,
                       f'兰德索尔花名册冷却中(剩余 {int(lmt.left_time(uid)) + 1}秒)',
                       at_sender=True)
        return
    lmt.start_cd(uid)

    name = ev.get_param().remain
    if not name:
        await bot.send(ev, '请发送"谁是"+别称,如"谁是霸瞳"')
        return
    id_ = chara.name2id(name)
    confi = 100
    guess = False
    if id_ == chara.UNKNOWN:
        id_, guess_name, confi = chara.guess_id(name)
        guess = True
    c = chara.fromid(id_)

    if guess:
        lmt.start_cd(uid, 120)
        msg = f'兰德索尔似乎没有叫"{name}"的人...\n角色别称补全计划: github.com/Ice-Cirno/HoshinoBot/issues/5'
        await bot.send(ev, msg)
        msg = f'\n您有{confi}%的可能在找{guess_name} '
        await bot.send(ev, msg)

    if confi > 60:
        await bot.send(ev, c.icon)
        await bot.send(ev, c.name, at_sender=True)
コード例 #3
0
async def set_pool(bot: KokkoroBot, ev: EventInterface):
    if not priv.check_priv(ev, priv.ADMIN):
        await bot.send(ev, '只有群管理才能切换卡池', at_sender=True)
        return
    name = util.normalize_str(param.remain)
    if not name:
        await bot.send(ev, POOL_NAME_TIP)
        return
    elif name in ('国', '国服', 'cn'):
        await bot.send(ev, '请选择以下卡池\n> 选择卡池 b服\n> 选择卡池 台服', at_sender=True)
        return
    elif name in ('b', 'b服', 'bl', 'bilibili'):
        name = 'BL'
    elif name in ('台', '台服', 'tw', 'sonet'):
        name = 'TW'
    elif name in ('日', '日服', 'jp', 'cy', 'cygames'):
        name = 'JP'
    elif name in ('混', '混合', 'mix'):
        name = 'MIX'
    else:
        await bot.send(ev, f'未知服务器地区 {POOL_NAME_TIP}', at_sender=True)
        return
    gid = str(ev.get_group_id())
    _group_pool[gid] = name
    dump_pool_config()
    await bot.send(ev, f'卡池已切换为{name}池', at_sender=True)
コード例 #4
0
async def gacha_10(bot: KokkoroBot, ev: EventInterface):
    SUPER_LUCKY_LINE = 170

    gid = str(ev.get_group_id())
    gacha = Gacha(_group_pool[gid])
    result, hiishi = gacha.gacha_ten()
    silence_time = hiishi * 6 if hiishi < SUPER_LUCKY_LINE else hiishi * 60

    if sv.bot.config.ENABLE_IMAGE:
        res1 = chara.gen_team_pic(result[:5], star_slot_verbose=False)
        res2 = chara.gen_team_pic(result[5:], star_slot_verbose=False)
        img = concat_pic([res1, res2])
        img = discord_adaptor.pil_image(img, filename="gacha10.png")
        await bot.send(ev, img)
        result = [f'{c.name}{"★"*c.star}' for c in result]
        res1 = ' '.join(result[0:5])
        res2 = ' '.join(result[5:])
        res = f'{res1}\n{res2}'
    else:
        result = [f'{c.name}{"★"*c.star}' for c in result]
        res1 = ' '.join(result[0:5])
        res2 = ' '.join(result[5:])
        res = f'{res1}\n{res2}'

    if hiishi >= SUPER_LUCKY_LINE:
        await bot.send(ev, '恭喜海豹!おめでとうございます!')
    await bot.send(ev, f'素敵な仲間が増えますよ!\n{res}', at_sender=True)
コード例 #5
0
async def _arena_feedback(bot, ev: EventInterface, action: int):
    action_tip = '赞' if action > 0 else '踩'
    qkey = ev.get_param().remain
    if not qkey:
        await bot.send(ev,
                       f'请发送"点{action_tip}+作业id",如"点{action_tip}ABCDE",不分大小写',
                       at_sender=True)
        return
    if not rex_qkey.match(qkey):
        await bot.send(ev, f'您要点{action_tip}的作业id不合法', at_sender=True)
        return
    try:
        await arena.do_like(qkey, ev.get_author_id(), action)
    except KeyError:
        await bot.send(ev, '无法找到作业id!您只能评价您最近查询过的作业', at_sender=True)
    await bot.send(ev, '感谢您的反馈!', at_sender=True)
コード例 #6
0
async def rank_sheet(bot, ev:EventInterface):
    match = ev.get_param().match
    is_jp = match.group(2) == '日'
    is_tw = match.group(2) == '台'
    is_cn = match.group(2) and match.group(2) in '国陆b'
    if not is_jp and not is_tw and not is_cn:
        await bot.send(ev, '\n请问您要查询哪个服务器的rank表?\n*日rank表\n*台rank表\n*B服rank表\n', at_sender=True)
        return
    msg = [
        '\n※表格仅供参考,升r有风险,强化需谨慎\n※一切以会长要求为准——',
    ]
    if is_jp:
        msg.append('※不定期搬运自图中Q群\n※广告为原作者推广,与本bot无关\nR17-5 rank表:')
        pos = match.group(3)
        if not pos or '前' in pos:
            msg.append(str(p4))
        if not pos or '中' in pos:
            msg.append(str(p5))
        if not pos or '后' in pos:
            msg.append(str(p6))
        await bot.send(ev, '\n'.join(msg), at_sender=True)
    elif is_tw:
        msg.append(f'※不定期搬运自漪夢奈特\n※油管频道有介绍视频及原文档\nR16-5 rank表:\n{p1} {p2}')
        await bot.send(ev, '\n'.join(msg), at_sender=True)
    elif is_cn:
        msg.append(str(cn_rank))
        await bot.send(ev, '\n'.join(msg), at_sender=True)
コード例 #7
0
async def gacha_300(bot, ev: EventInterface):

    gid = str(ev.get_group_id())
    gacha = Gacha(_group_pool[gid])
    result = gacha.gacha_tenjou()
    up = len(result['up'])
    s3 = len(result['s3'])
    s2 = len(result['s2'])
    s1 = len(result['s1'])

    res = [*(result['up']), *(result['s3'])]
    random.shuffle(res)
    lenth = len(res)
    if lenth <= 0:
        res = "竟...竟然没有3★?!"
    else:
        step = 4
        pics = []
        for i in range(0, lenth, step):
            j = min(lenth, i + step)
            pics.append(chara.gen_team_pic(res[i:j], star_slot_verbose=False))
        img = concat_pic(pics)
        img = discord_adaptor.pil_image(img, filename="gacha300.png")
        await bot.send(ev, img)

    msg = [
        f"\n素敵な仲間が増えますよ!", f"★★★×{up+s3} ★★×{s2} ★×{s1}",
        f"获得记忆碎片×{100*up}与女神秘石×{50*(up+s3) + 10*s2 + s1}!\n第{result['first_up_pos']}抽首次获得up角色"
        if up else f"获得女神秘石{50*(up+s3) + 10*s2 + s1}个!"
    ]

    if up == 0 and s3 == 0:
        msg.append("太惨了,咱们还是退款删游吧...")
    elif up == 0 and s3 > 7:
        msg.append("up呢?我的up呢?")
    elif up == 0 and s3 <= 3:
        msg.append("这位酋长,梦幻包考虑一下?")
    elif up == 0:
        msg.append("据说天井的概率只有12.16%")
    elif up <= 2:
        if result['first_up_pos'] < 50:
            msg.append("你的喜悦我收到了,滚去喂鲨鱼吧!")
        elif result['first_up_pos'] < 100:
            msg.append("已经可以了,您已经很欧了")
        elif result['first_up_pos'] > 290:
            msg.append("标 准 结 局")
        elif result['first_up_pos'] > 250:
            msg.append("补井还是不补井,这是一个问题...")
        else:
            msg.append("期望之内,亚洲水平")
    elif up == 3:
        msg.append("抽井母五一气呵成!多出30等专武~")
    elif up >= 4:
        msg.append("记忆碎片一大堆!您是托吧?")

    await bot.send(ev, '\n'.join(msg), at_sender=True)
    silence_time = ((100 * up + 50 * (up + s3)) / 3) * 1  #+ 10*s2 + s1) * 1
    if silence_time >= 5 * 60:
        await silence(ev, 5 * 60)
コード例 #8
0
async def arena_miner(bot, ev: EventInterface):
    try:
        rank = int(ev.get_param().remain)
    except:
        return
    rank = np.clip(rank, 1, 15001)
    s_all = all_season[1:rank].sum()
    s_this = this_season[1:rank].sum()
    msg = f"最高排名奖励还剩{s_this}钻\n历届最高排名还剩{s_all}钻"
    await bot.send(ev, msg, at_sender=True)
コード例 #9
0
async def kakin(bot, ev: EventInterface):
    if ev.get_author_id not in bot.config.SUPERUSERS:
        return
    count = 0
    members = ev.get_mentions()
    for m in members:
        uid = m.id
        jewel_limit.reset(uid)
        tenjo_limit.reset(uid)
        count += 1
    if count:
        await bot.send(ev, f"已为{count}位用户充值完毕!谢谢惠顾~")
コード例 #10
0
async def gacha_info(bot: KokkoroBot, ev: EventInterface):
    gid = str(ev.get_group_id())
    gacha = Gacha(_group_pool[gid])
    up_chara = gacha.up
    if sv.bot.config.ENABLE_IMAGE:
        up_chara_imgs = map(lambda x: (chara.fromname(x, star=3).icon),
                            up_chara)
    for img in up_chara_imgs:
        await bot.send(ev, img)
    await bot.send(
        ev,
        f"本期卡池主打的角色:\n{up_chara}\nUP角色合计={(gacha.up_prob/10):.1f}% 3★出率={(gacha.s3_prob)/10:.1f}%"
    )
コード例 #11
0
async def give_okodokai(bot, ev: EventInterface):
    uid = ev.get_author_id()
    if not lmt.check(uid):
        await bot.send(ev, '明日はもう一つプレゼントをご用意してお待ちしますね', at_sender=True)
        return
    lmt.increase(uid)
    present = random.choice(login_presents)
    todo = random.choice(todo_list)
    await bot.send(ev, R.img("priconne/kokkoro_stamp.png"))
    await bot.send(
        ev,
        f'\nおかえりなさいませ、主さま\n{present}を獲得しました\n私からのプレゼントです\n主人今天要{todo}吗?',
        at_sender=True)
コード例 #12
0
async def gacha_1(bot: KokkoroBot, ev: EventInterface):
    gid = str(ev.get_group_id())
    gacha = Gacha(_group_pool[gid])
    chara, hiishi = gacha.gacha_one(gacha.up_prob, gacha.s3_prob,
                                    gacha.s2_prob)
    #silence_time = hiishi * 60

    res = f'{chara.name} {"★"*chara.star}'
    if sv.bot.config.ENABLE_IMAGE:
        img = chara.icon
        await bot.send(ev, img)
    if chara.star == 3:
        await silence(ev, 60)
    await bot.send(ev, f'素敵な仲間が増えますよ!\n{res}', at_sender=True)
コード例 #13
0
async def normal_map(bot, ev: EventInterface):
    try:
        number = int(ev.get_param().remain)
    except Exception as e:
        await bot.send(ev, '参数必须为数字。示例:`刷图 10`')
        return

    img = f'{NORMAL_MAP_PREFIX}-{number}.jpg'
    img = R.img(f'priconne/quick/{img}')
    if not img.exist:
        await bot.send(ev, f'{number} 图刷图攻略未找到呜呜呜 ┭┮﹏┭┮')
    else:
        await bot.send(ev, f'{number} 图刷图攻略:')
        await bot.send(ev, img)
コード例 #14
0
async def calendar(bot, ev: EventInterface):
    match = ev.get_param().match
    server = match.group(1)
    if server == '台':
        await bot.send(ev, "不好意思,台服日程表暂不支持┭┮﹏┭┮", at_sender=True)
        return
    elif server == '日':
        region = 'jp'
    elif server in ['国', 'b', 'B']:
        region = 'cn'

    yobot_url = f'https://tools.yobot.win/calender/#{region}'
    msg = f'{server}服日程表\nyobot: {yobot_url}'
    if region == 'cn':
        msg = f'{msg}\nbilibili: {cn_official_url}'
    await bot.send(ev, msg)
コード例 #15
0
async def _arena_query(bot, ev: EventInterface, region: int):

    arena.refresh_quick_key_dic()
    uid = ev.get_author_id()

    if not lmt.check(uid):
        await bot.send(ev, '您查询得过于频繁,请稍等片刻', at_sender=True)
        return
    lmt.start_cd(uid)

    # 处理输入数据
    defen = ev.get_param().remain
    defen = re.sub(r'[??,,_]', '', defen)
    defen, unknown = chara.roster.parse_team(defen)

    if unknown:
        _, name, score = chara.guess_id(unknown)
        if score < 70 and not defen:
            return  # 忽略无关对话
        msg = f'无法识别"{unknown}"' if score < 70 else f'无法识别"{unknown}" 您说的有{score}%可能是{name}'
        await bot.send(ev, msg)
        return
    if not defen:
        await bot.send(ev, '查询请发送"怎么拆+防守队伍",无需+号', at_sender=True)
        return
    if len(defen) > 5:
        await bot.send(ev, '编队不能多于5名角色', at_sender=True)
        return
    if len(defen) < 5:
        await bot.send(ev,
                       '由于数据库限制,少于5名角色的检索条件请移步pcrdfans.com进行查询',
                       at_sender=True)
        return
    if len(defen) != len(set(defen)):
        await bot.send(ev, '编队中含重复角色', at_sender=True)
        return
    if any(chara.is_npc(i) for i in defen):
        await bot.send(ev, '编队中含未实装角色', at_sender=True)
        return
    if 1004 in defen:
        await bot.send(ev,
                       '\n⚠️您正在查询普通版炸弹人\n※万圣版可用万圣炸弹人/瓜炸等别称',
                       at_sender=True)

    # 执行查询
    sv.logger.info('Doing query...')
    res = await arena.do_query(defen, uid, region)
    sv.logger.info('Got response!')

    # 处理查询结果
    if res is None:
        await bot.send(ev,
                       '查询出错,请联系维护组调教\n请先移步pcrdfans.com进行查询',
                       at_sender=True)
        return
    if not len(res):
        await bot.send(ev,
                       '抱歉没有查询到解法\n※没有作业说明随便拆 发挥你的想象力~★\n作业上传请前往pcrdfans.com',
                       at_sender=True)
        return
    res = res[:min(6, len(res))]  # 限制显示数量,截断结果

    # 发送回复
    if kokkoro.config.ENABLE_IMAGE:
        sv.logger.info('Arena generating picture...')
        atk_team = [chara.gen_team_pic(entry['atk']) for entry in res]
        atk_team = concat_pic(atk_team)
        sv.logger.info('Arena picture ready!')
        await bot.send(ev, atk_team)
    else:
        atk_team = '\n'.join(
            map(
                lambda entry: ' '.join(
                    map(
                        lambda x:
                        f"{x.name}{x.star if x.star else ''}{'专' if x.equip else ''}",
                        entry['atk'])), res))

    details = [
        " ".join([
            f"赞{e['up']}+{e['my_up']}" if e['my_up'] else f"赞{e['up']}",
            f"踩{e['down']}+{e['my_down']}"
            if e['my_down'] else f"踩{e['down']}", e['qkey'], "你赞过"
            if e['user_like'] > 0 else "你踩过" if e['user_like'] < 0 else ""
        ]) for e in res
    ]

    defen = [chara.fromid(x).name for x in defen]
    defen = f"防守方【{' '.join(defen)}】"

    msg = [defen, f'已为骑士查询到以上进攻方案:', f'作业评价:', *details, '※发送"点赞/点踩"可进行评价']
    if region == 1:
        msg.append('※使用"b怎么拆"或"台怎么拆"可按服过滤')
    msg.append('Support by pcrdfans_com')

    sv.logger.debug('Arena sending result...')
    await bot.send(ev, '\n'.join(msg))
    sv.logger.debug('Arena result sent!')
コード例 #16
0
 def _check_all(self, ev: EventInterface):
     gid = ev.get_group_id()
     return self.check_enabled(gid) and not priv.check_block_group(gid) and priv.check_priv(ev, self.use_priv)
コード例 #17
0
def get_user_priv(ev: EventInterface):
    if is_super_user(ev.get_author_id()):
        return SUPERUSER
    return NORMAL
コード例 #18
0
 async def wrapper(bot: KokkoroBot, ev: EventInterface):
     param = ev.get_param()
     if param.remain != '':
         self.logger.info(f'Message {ev.get_id()} is ignored by fullmatch condition.')
         return
     return await func(bot, ev)