async def signup_signup(session: CommandSession): code = session.get( 'code', prompt='你想报名的活动的活动码是?\n(如果不知道,请询问活动发起人)', ) event = await dao.get_event(code) if not event: session.finish('没有找到这个活动呢~') if event.end_time: session.finish('该活动报名已经结束啦,请下次再来吧~') signup = await dao.get_signup(session.ctx, event) if signup: session.finish('你已经报过名啦~') if 0 < event.max_signups <= await dao.get_signup_count(event): session.finish('该活动报名人数已达上限,请下次再来吧~') if 'fired' not in session.state: await session.send(f'欢迎报名参加活动「{event.title}」\n' f'下面我会问你一些问题,以采集必要信息') session.state['fired'] = True fields = event.fields field_values = session.state.get('field_values', []) for curr_idx in range(len(field_values), len(fields)): curr_field = fields[curr_idx] validator = curr_field.get('validator') if not validator: validator = {'type': 'allow-all', 'value': None} prompt = curr_field['question'] if validator['type'] == 'choice': choices = '\n'.join( [f'{i + 1}. {v}' for i, v in enumerate(validator['value'])]) prompt += f'\n(请输入序号)\n\n{choices}' value = session.get(f'field_{curr_idx}', prompt=prompt) valid = True if validator['type'] == 'regex': valid = re.fullmatch(validator['value'], value, re.IGNORECASE) elif validator['type'] == 'choice': try: choice_idx = int(value) - 1 value = validator['value'][choice_idx] except (ValueError, IndexError): valid = False if not valid: session.pause('输入不符合要求,请重新输入哦~') field_values.append(value) session.state['field_values'] = field_values # information collection done signup = await dao.create_signup(session.ctx, event, field_values) if not signup: session.finish('报名失败,请稍后重试~') else: msg = '恭喜你报名成功啦!' if event.qq_group_number: msg += f'请加入此活动官方群 {event.qq_group_number} ' \ f'及时获取活动通知哦(申请将自动通过)~' session.finish(msg)
async def _(session: CommandSession): h_user = session.event.user_id if 0 <= now_time() < 5.5: await session.send( choice( [ 'zzzz......', 'zzzzzzzz......', 'zzz...好涩哦..zzz....', '别...不要..zzz..那..zzz..', '嘻嘻..zzz..呐~..zzzz..' ] ) ) else: with open('ATRI/plugins/noobList/noobList.json', 'r') as f: data = json.load(f) if str(h_user) in data.keys(): pass else: with open('ATRI/plugins/switch/switch.json', 'r') as f: data = json.load(f) if data["hbook"] == 0: num = 1 tag = '' start = time.perf_counter() h_msg = str(session.event.message) info = re.findall(pattern, h_msg) if info: num = int(info[0][0] or 1) tag = str(info[0][1]) if num > 5: await session.send('你是不是涩批啊!要那么多干啥?!我最多发5份!') num = 5 h_type = session.event.detail_type try: header = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36'} keyword = {'show':'title,titleen,tags','keyboard':tag} print(keyword) res = await response.post_bytes('https://b-upp.com/search/', headers=header, data=keyword) res = res.decode() except: session.finish('貌似请求数据失败了...') if '没有搜索到相关的内容' in res: n_msg = '...似乎没有找到[{}]相关的本子呢'.format(tag) await session.send(message=n_msg) else: p = '<a href="(.*?)" target="_blank" title="(.*?)">' data = re.findall(p,res) n = len(data) limit = num if n > limit: # type: ignore n = limit # type: ignore msg = f'据提供信息,已查询到{n}本关键词为[{tag}]的本子:' if h_type == 'group': msg = f'[CQ:at,qq={h_user}]\n根据提供信息,已查询到{n}本关键词为[{tag}]的本子:' for i in range(n): msg0 = ('\n——————————\n本子链接:https://b-upp.com%s \n本子标题:%s '%(data[i])) msg += msg0 end = time.perf_counter() msg0 = f'\n——————————\n耗时: {round(end - start, 3)}s' msg += msg0 await session.send(msg) else: await session.send('该功能已禁用...')
async def Pull_Web(session: CommandSession): path = r'C:\Users\Administrator\Desktop\abn_crypt' info = call_cmd(path) session.finish(info)
async def todo_cancel(session: CommandSession): error = session.get('error') session.finish(error)
async def command_help(session: CommandSession): await session.send( f"======命令列表======\n自动签到:配置和更新超星自动签到有关设定。\n自动签到历史:查看超星自动签到插件执行历史\n\n===========" ) session.finish()
async def getGamePassPrice(session: CommandSession): session.finish("当前账号价格:" + repr(float(db.getprice('GamePass')) / 100) + '元')
async def setGamePassPrice(session: CommandSession): price = eval(session.current_arg_text.strip()) db.setprice('GamePass', int(price * 100)) session.finish('设置成功完成')
async def _(session: CommandSession): resp = await requests.get(API_URL) if not resp.ok: session.finish('获取一言失败,请稍后再试哦') session.finish(await resp.text)
async def random_choice(session: CommandSession): argv = shlex.split(session.current_arg_text) if not argv: session.finish('谁是那个被选召的孩子') await session.send(random.choice(argv) + " !")
async def rank(session: CommandSession): """ 复读排行榜 """ message = await get_rank(session) session.finish(message)
async def history(session: CommandSession): """ 复读排行榜历史 """ message = await get_history(session) session.finish(message)
async def sign(session: CommandSession): """ 复读打卡(电脑上没法看手机打卡内容) """ if session.event.group_id in session.bot.config.GROUP_ID: title = re.findall(r'title=(\w+\s?\w+)', session.state.get('message')) session.finish(f'今天的打卡是 {title[0]}', at_sender=True)
async def status(session: CommandSession): """ 状态 """ message = await get_status(session) session.finish(message)
async def group(session: CommandSession): """ 人类本质 """ message = session.state.get('message') if is_repeat(session, message): session.finish(message)
async def subscribe(session: CommandSession): message = session.get( 'message', prompt='你想订阅什么内容呢?', arg_filters=[ controllers.handle_cancellation(session), str.lstrip, validators.not_empty('请输入有效内容哦~'), ] ) hour = session.state.get('hour') minute = session.state.get('minute') if hour is None or minute is None: time = session.get( 'time', prompt='你希望我在每天的什么时候给你推送呢?\n' '(请使用24小时制,并使用阿拉伯数字表示小时和分钟)' ) m = re.match(r'(?P<hour>\d{1,2})[.::](?P<minute>\d{1,2})', time) if not m: m = re.match(r'(?P<hour>\d{1,2})\s*[点时]\s*' r'(?:(?P<minute>\d{1,2}|半|一刻)\s*[分]?)?', time) if m: hour = int(m.group('hour')) session.state['hour'] = hour try: minute = int(m.group('minute') or 0) except ValueError: if m.group('minute') == '半': minute = 30 elif m.group('minute') == '一刻': minute = 15 session.state['minute'] = minute else: del session.state['time'] session.pause('时间格式不对啦,请重新发送') repeat = session.get( 'repeat', prompt='是否希望我在推送消息的时候重复你上面发的消息内容呢?(请回答是或否)', arg_filters=[ extractors.extract_text, converters.simple_chinese_to_bool, validators.ensure_true(lambda x: x is not None, '我听不懂呀,请用是或否再回答一次呢') ] ) escaped_message = message.replace('\\', '\\\\').replace('"', '\\"') if repeat: switch_arg = f'--repeat "{escaped_message}"' else: switch_arg = f'"{escaped_message}"' try: job = await scheduler.add_scheduled_commands( ScheduledCommand('switch', switch_arg), job_id=scheduler.make_job_id( PLUGIN_NAME, context_id(session.ctx), (random_string(1, string.ascii_lowercase) + random_string(7, string.ascii_lowercase + string.digits)) ), ctx=session.ctx, trigger='cron', hour=hour, minute=minute, replace_existing=False ) session.finish(f'订阅成功啦,下次推送时间 ' f'{job.next_run_time.strftime("%Y-%m-%d %H:%M")}') except scheduler.JobIdConflictError: session.finish('订阅失败,有可能只是运气不好哦,请稍后重试~')
async def add_cmd(session: CommandSession): question = session.get('question') answer = session.get('answer') group_id = session.get('group_id') sender = session.ctx['sender'] user_id = sender['user_id'] user_nickname = sender['nickname'] user_card = sender.get('user_card') # **暂时停用** base_cmd = [ 'yyy', '嘤一下', '嘤一个', '来嘤', 'kusa', '草', 'robot', '机屑人', 'string', '五十弦', 'mua', 'mua~', 'zaima', 'nihao', 'wei,zaima', 'wei,zaima', 'nihao', '你好', '泥嚎', 'help', '怎么用', '怎么玩', '签到', '注册' ] name_list = ['五十弦', '弦', 'hello', 'Hello', 'hi', 'Hi'] if question in base_cmd: session.finish('与内置指令冲突🔧') elif question in name_list: session.finish(f'{question}不能作为指令,但是可以用{question}来叫我') sql_select = ('SELECT Q FROM cmd WHERE group_id=?;') q_list = sql_exe(sql_select, (group_id, )) if q_list: if (question, ) in q_list: sql_select_question = ( 'SELECT A FROM cmd WHERE Q=? AND group_id=?;') b_answer = sql_exe(sql_select_question, (question, group_id))[0] # msg = session.ctx.get('message') # msg = str(msg) # if b_group_id == 1 and msg[:2] == '全局': # user_id = session.ctx.get('sender').get('user_id') # if user_id == 2301583973 or user_id == 963949236: # sql_rewrite = ( # 'UPDATE cmd SET A=? WHERE Q=?;' # ) # sql_exe(sql_rewrite, (answer, question)) # # session.finish(f'已覆盖原全局指令回答<{b_answer}>\n当前指令:\n<Q>{question}</Q>\n<A>{answer}</A>') # else: # session.finish('与全局指令冲突') # elif b_group_id == 1: # user_id = session.ctx.get('sender').get('user_id') # if not user_id == 2301583973 or not user_id == 963949236: # session.finish('与全局指令冲突') sql_rewrite = ('UPDATE cmd SET A=? WHERE Q=? AND group_id=?;') sql_exe(sql_rewrite, (answer, question, group_id)) session.finish( f'已覆盖原指令回答<{b_answer[0]}>\n当前指令:\n<Q>{question}</Q>\n<A>{answer}</A>' ) sql_insert = ('INSERT INTO cmd VALUES (NULL, ?, ?, ?, ?, ?, ?);') sql_exe(sql_insert, (user_id, user_nickname, user_card, group_id, question, answer)) # if group_id == 1: # await session.send(f'⬈全局添加成功➾\n<Q>{question}</Q>\n<A>{answer}</A>') # else: await session.send(f'⬈添加成功➾\n<Q>{question}</Q>\n<A>{answer}</A>')
async def index(session: CommandSession): timeline_list = await get_timeline_list() if timeline_list is None: session.finish('查询失败了……') date = session.state.get('date') name = session.state.get('name') if date: timeline_list = filter(lambda x: x.get('pub_date', '').endswith(date), timeline_list) if name: name = name.strip() timeline_list = list(filter( lambda x: name.lower() in x.get('title', '').lower(), timeline_list )) if len(set(map(lambda x: x['title'], timeline_list))) > 1: timeline_list = filter( lambda x: len(name) > len(x['title']) / 4, timeline_list ) if not isinstance(timeline_list, list): timeline_list = list(timeline_list) if date and name: if not timeline_list: reply = '没更新' else: reply = '\n'.join( ('更新了' if item['is_published'] else f'将在{item["ontime"]}更新') + (f'第{item["ep_index"]}话' if item['ep_index'].isdigit() else item['ep_index']) for item in timeline_list ) session.finish(reply) if not timeline_list: session.finish('没有找到符合条件的时间表……') if date: month, day = [int(x) for x in date.split('-')] reply = f'在{month}月{day}日更新的番剧有:\n\n' reply += '\n'.join(f'{item["title"] or "未知动画"} ' f'{item["ontime"] or "未知时间"} ' + (f'第{item["ep_index"]}话' if item['ep_index'].isdigit() else item['ep_index']) for item in timeline_list) session.finish(reply) if name: anime_dict = defaultdict(list) for item in timeline_list: anime_dict[item['title']].append(item) for name, items in anime_dict.items(): reply = f'{name}\n' for item in items: _, month, day = [int(x) for x in item['pub_date'].split('-')] reply += '\n' + ('已' if item['is_published'] else '将') + \ f'在{month}月{day}日{item["ontime"]}更新' + \ (f'第{item["ep_index"]}话' if item['ep_index'].isdigit() else item['ep_index']) await session.send(reply)
async def empty_finish(session: CommandSession): question = session.get('question') answer = session.get('answer') session.finish(f'⭷添加失败⇲\n<Q>{question}</Q>\n<A>{answer}</A>\n参数不能为空')
async def checkGamePass(session: CommandSession): session.finish("当前账号余量:" + repr(db.checkgamepass()) + '个')
async def set_my_skill(session: CommandSession): group_id = session.event.group_id session_type = session.event.detail_type if session_type == 'group': if not has_command_permissions(group_id): await session.send('本群组没有执行命令的权限呢QAQ') log.logger.info(f'{__name__}: 群组: {group_id} 没有命令权限, 已中止命令执行') return elif session_type == 'private': await session.send('本命令不支持在私聊中使用QAQ') log.logger.info( f'{__name__}: 用户: {session.event.user_id} 在{session_type}中使用了命令, 已中止命令执行' ) return else: log.logger.info( f'{__name__}: 用户: {session.event.user_id} 在{session_type}环境中使用了命令, 已中止命令执行' ) return __user_qq = session.event.user_id try: # 清空技能列表 await clean_user_skill_in_db(__user_qq) except Exception as e: await session.send('发生了意外的错误QAQ') log.logger.warning( f'{__name__}: 群组: {group_id}, 用户: {__user_qq} 试图设置技能时发生了错误: {e}, 清空技能列表失败' ) return __skill_list = await query_skill_list() skill_name = session.get('skill_name', prompt='请输入你想设置的技能名称: ', arg_filters=[ controllers.handle_cancellation(session), validators.not_empty('输入不能为空') ]) if skill_name not in __skill_list: session.finish('没有这个技能哦, 请重新设置~') skill_level = session.get('skill_level', prompt='请输入你想设置的技能等级: \n可设置等级有"普通"、"熟练"、"专业"', arg_filters=[ controllers.handle_cancellation(session), validators.not_empty('输入不能为空'), validators.match_regex(r'^(普通|熟练|专业)$', '没有这个技能等级, 请重新输入~', fullmatch=True) ]) try: __result = await add_user_skill_in_db(user_qq=__user_qq, skill_name=skill_name, skill_level=skill_level) if __result: await session.send(f'为你设置了技能: 【{skill_name}/{skill_level}】') log.logger.info( f'{__name__}: 群组: {group_id}, 用户: {__user_qq} 成功设置了自己的技能') else: await session.send('添加失败, 发生了意外的错误QAQ') log.logger.info( f'{__name__}: 群组: {group_id}, 用户: {__user_qq} 设置技能失败, add_user_skill_in_db错误' ) except Exception as e: log.logger.warning( f'{__name__}: 群组: {group_id}, 用户: {__user_qq} 试图使用命令set_my_skill时发生了错误: {e}' )
async def addPrivateQuestion(session: CommandSession): c = re.split(r'(#[^#]+#)(.+)', session.current_arg, flags=re.M | re.S) question = c[1].strip('#') answer = c[2].strip() db.setvar('question_private_' + question, answer) session.finish('问题' + question + '设置成功!')
async def Write(session: CommandSession): session.state['message'] = session.current_arg_text.strip() message = session.get('message', prompt='请输入你要储存的信息') await Save(message) session.finish("已储存")
async def cls(session: CommandSession): await session.send('开始清屏') clswords = '-清屏指令-群主专用-非常拉风-再清两下-保证秩序-遵守群规-不说废话-不发广告-不煽动情绪-不威胁管理-' for k in clswords: await session.send(k) session.finish('清屏完成')
async def _(session: CommandSession): if session.event.user_id in master: with open(Path('.') / 'ATRI' / 'modules' / 'funcControl' / 'ALLswitch.json', 'r') as f: data = json.load(f) command = session.event.raw_message.split(' ', 1) switch = command[0] com = command[1] print(command) if switch == 'on': if com == 'PixivSearchIMG': data["pixiv_seach_img"] = "on" elif com == 'PixivSearchAuthor': data["pixiv_seach_author"] = "on" elif com == 'PixivRank': data["pixiv_daily_rank"] = "on" elif com == 'Setu': data["setu"] = "on" elif com == 'SetuIMG': data["setu_img"] = "on" elif com == "AnimeSearch": data["anime_search"] = "on" elif com == 'AIchFace': data["change_face"] = "on" elif com == 'Kyaru': data["chouYou"] = "on" elif com == 'SauceNAO': data["saucenao_search"] = "on" else: session.finish('未找到此功能...请检查拼写奥...') elif switch == 'off': if com == 'PixivSearchIMG': data["pixiv_seach_img"] = "off" elif com == 'PixivSearchAuthor': data["pixiv_seach_author"] = "off" elif com == 'PixivRank': data["pixiv_daily_rank"] = "off" elif com == 'Setu': data["setu"] = "off" elif com == 'SetuIMG': data["setu_img"] = "off" elif com == "AnimeSearch": data["anime_search"] = "off" elif com == 'AIchFace': data["change_face"] = "off" elif com == 'Kyaru': data["chouYou"] = "off" elif com == 'SauceNAO': data["saucenao_search"] = "off" else: session.finish('未找到此功能...请检查拼写奥...') f2 = open(Path('.') / 'ATRI' / 'modules' / 'funcControl' / 'ALLswitch.json', 'w') f2.write(json.dumps(data)) f2.close() await session.send('Success!')
async def _(session: CommandSession): # 检查是否允许在群组内运行 group_id = session.event.group_id session_type = session.event.detail_type if session_type == 'group': if not has_command_permissions(group_id): return elif session_type == 'private': pass else: return # 去掉消息首尾的空白符 stripped_arg = session.current_arg_text.strip() if session.is_first_run: # 该命令第一次运行(第一次进入命令会话) if stripped_arg: # 第一次运行参数不为空, 意味着用户直接将PID跟在命令名后面, 作为参数传入 try: if stripped_arg == '周榜': __payload = {'key': API_KEY, 'rank_mode': 'weekly'} __res = await fetch(url=RANK_API_URL, paras=__payload) if 'error' in __res.keys(): session.state['pixiv'] = 'error' else: session.state['pixiv'] = (await fetch( url=RANK_API_URL, paras=__payload))['pid'] elif stripped_arg == '日榜': __payload = {'key': API_KEY, 'rank_mode': 'daily'} __res = await fetch(url=RANK_API_URL, paras=__payload) if 'error' in __res.keys(): session.state['pixiv'] = 'error' else: session.state['pixiv'] = (await fetch( url=RANK_API_URL, paras=__payload))['pid'] elif stripped_arg == '月榜': __payload = {'key': API_KEY, 'rank_mode': 'monthly'} __res = await fetch(url=RANK_API_URL, paras=__payload) if 'error' in __res.keys(): session.state['pixiv'] = 'error' else: session.state['pixiv'] = (await fetch( url=RANK_API_URL, paras=__payload))['pid'] elif re.match(r'^\d+$', stripped_arg): session.state['pixiv'] = stripped_arg else: session.finish( '你输入的命令好像不对呢……请输入"月榜"、"周榜"、"日榜"或者PixivID试试吧~') except Exception as e: log.logger.error( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 试图使用命令pixiv时发生了错误: {e}' ) session.finish() return if not stripped_arg: # 用户没有发送有效的PID(而是发送了空白字符), 则提示重新输入 # 这里 session.pause() 将会发送消息并暂停当前会话(该行后面的代码不会被运行) session.pause('你还没告诉我你想看什么呢~') # 如果当前正在向用户询问更多信息, 且用户输入有效, 则放入会话状态 if stripped_arg == '周榜': try: __payload = {'key': API_KEY, 'rank_mode': 'weekly'} __res = await fetch(url=RANK_API_URL, paras=__payload) if 'error' in __res.keys(): session.state[session.current_key] = 'error' else: session.state[session.current_key] = (await fetch( url=RANK_API_URL, paras=__payload))['pid'] except Exception as e: log.logger.error( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 试图使用命令pixiv时发生了错误: {e}' ) session.finish() elif stripped_arg == '月榜': try: __payload = {'key': API_KEY, 'rank_mode': 'monthly'} __res = await fetch(url=RANK_API_URL, paras=__payload) if 'error' in __res.keys(): session.state[session.current_key] = 'error' else: session.state[session.current_key] = (await fetch( url=RANK_API_URL, paras=__payload))['pid'] except Exception as e: log.logger.error( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 试图使用命令pixiv时发生了错误: {e}' ) session.finish() elif stripped_arg == '日榜': try: __payload = {'key': API_KEY, 'rank_mode': 'daily'} __res = await fetch(url=RANK_API_URL, paras=__payload) if 'error' in __res.keys(): session.state[session.current_key] = 'error' else: session.state[session.current_key] = (await fetch( url=RANK_API_URL, paras=__payload))['pid'] except Exception as e: log.logger.error( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 试图使用命令pixiv时发生了错误: {e}' ) session.finish() elif re.match(r'^\d+$', stripped_arg): session.state[session.current_key] = stripped_arg else: session.finish('你输入的命令好像不对呢……请输入"月榜"、"周榜"、"日榜"或者PixivID试试吧~')
async def _(session: CommandSession): group = session.event.group_id try: with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'switch.json', 'r') as f: data = json.load(f) except: try: os.mkdir(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}') except: pass data = {} data["pixiv_seach_img"] = "on" data["pixiv_seach_author"] = "on" data["pixiv_daily_rank"] = "on" data["setu"] = "on" data["setu_img"] = "on" data["anime_search"] = "on" data["change_face"] = "on" data["chouYou"] = "on" data["saucenao_search"] = "on" with open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'switch.json', 'w') as f: f.write(json.dumps(data)) f.close() command = session.event.raw_message.split(' ', 1) switch = command[0] com = command[1] print(command) if switch == 'on': if com == 'PixivSearchIMG': data["pixiv_seach_img"] = "on" elif com == 'PixivSearchAuthor': data["pixiv_seach_author"] = "on" elif com == 'PixivRank': data["pixiv_daily_rank"] = "on" elif com == 'Setu': data["setu"] = "on" elif com == 'SetuIMG': data["setu_img"] = "on" elif com == "AnimeSearch": data["anime_search"] = "on" elif com == 'AIchFace': data["change_face"] = "on" elif com == 'Kyaru': data["chouYou"] = "on" elif com == 'SauceNAO': data["saucenao_search"] = "on" else: session.finish('未找到此功能...请检查拼写奥...') elif switch == 'off': if com == 'PixivSearchIMG': data["pixiv_seach_img"] = "off" elif com == 'PixivSearchAuthor': data["pixiv_seach_author"] = "off" elif com == 'PixivRank': data["pixiv_daily_rank"] = "off" elif com == 'Setu': data["setu"] = "off" elif com == 'SetuIMG': data["setu_img"] = "off" elif com == "AnimeSearch": data["anime_search"] = "off" elif com == 'AIchFace': data["change_face"] = "off" elif com == 'Kyaru': data["chouYou"] = "off" elif com == 'SauceNAO': data["saucenao_search"] = "off" else: session.finish('未找到此功能...请检查拼写奥...') f2 = open(Path('.') / 'ATRI' / 'data' / 'groupData' / f'{group}' / 'switch.json', 'w') f2.write(json.dumps(data)) f2.close() await session.send('Success!')
async def _arena_query(session: CommandSession, region: int): arena.refresh_quick_key_dic() uid = session.ctx['user_id'] if not lmt.check(uid): session.finish('您查询得过于频繁,请稍等片刻', at_sender=True) lmt.start_cd(uid) # 处理输入数据 argv = session.current_arg_text.strip() argv = re.sub(r'[??,,_]', ' ', argv) argv = argv.split() if 0 >= len(argv): session.finish('请输入防守方角色,用空格隔开', at_sender=True) if 5 < len(argv): session.finish('编队不能多于5名角色', at_sender=True) defen = [Chara.name2id(name) for name in argv] for i, id_ in enumerate(defen): if Chara.UNKNOWN == id_: await session.finish( f'编队中含未知角色"{argv[i]}",请尝试使用官方译名\n您可@bot来杯咖啡+反馈未收录别称\n或前往 github.com/Ice-Cirno/HoshinoBot/issues/5 回帖补充', at_sender=True) if len(defen) != len(set(defen)): await session.finish('编队中出现重复角色', at_sender=True) if 1004 in defen: await session.send('\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: session.finish('查询出错,请联系维护组调教\n请先移步pcrdfans.com进行查询', at_sender=True) if not len(res): session.finish('抱歉没有查询到解法\n※没有作业说明随便拆 发挥你的想象力~★\n作业上传请前往pcrdfans.com', at_sender=True) res = res[:min(6, len(res))] # 限制显示数量,截断结果 # 发送回复 if get_bot().config.IS_CQPRO: sv.logger.info('Arena generating picture...') atk_team = [Chara.gen_team_pic(entry['atk']) for entry in res] atk_team = concat_pic(atk_team) atk_team = pic2b64(atk_team) atk_team = str(MessageSegment.image(atk_team)) sv.logger.info('Arena picture ready!') 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'] ]) for e in res ] defen = [Chara.fromid(x).name for x in defen] defen = f"防守方【{' '.join(defen)}】" at = str(MessageSegment.at(session.ctx["user_id"])) msg = [ defen, f'已为骑士{at}查询到以下进攻方案:', str(atk_team), f'作业评价:', *details, '※发送"点赞/点踩"可进行评价', '※请升级手Q至8.3.5以查看图片', ] if region == 1: msg.append('※使用"b怎么拆"或"台怎么拆"可按服过滤') msg.append('Support by pcrdfans_com') sv.logger.debug('Arena sending result...') await session.send('\n'.join(msg)) sv.logger.debug('Arena result sent!')
async def random_choice(session: CommandSession): argv = shlex.split(session.current_arg_text) if not argv: session.finish('用法不对啦,需要给我提供要抽签的内容哦') await session.send(random.choice(argv))
async def Pull_Bot(session: CommandSession): path = os.path.abspath(os.curdir) info = call_cmd(path) session.finish(info)
async def anonymous_check(session: CommandSession): if session.ctx['anonymous'] is not None: session.finish("匿名是不能干这些事情的哦~")