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))
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)
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)
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)
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)
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)
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)
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!')
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)