async def translate_youdao(session: CommandSession): content = session.get('content', prompt='你想翻译什么?') # app_key msg = await get_translate(content, app_key='BK8bAiTcKH1BsMoW') await session.send(msg)
async def speak_to_me(session: CommandSession): content = session.get('content', prompt='跟你说啥?') session.finish(content, at_sender=True)
async def translate(session: CommandSession): words = session.get('words', prompt='你想翻译什么句子呢?') report = await get_translate(words) await session.send(MessageSegment.text(report))
async def search_bing(session: CommandSession): content = session.get('content', prompt='你想bing什么?') msg = await get_bing_url(content) await session.send(str(msg))
async def new_live_sub(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 # 从会话状态(session.state)中获取sub_id, 如果当前不存在, 则询问用户 __sub_id = session.get('sub_id', prompt='请输入直播间房间号: ', arg_filters=[controllers.handle_cancellation(session), validators.not_empty('输入不能为空'), validators.match_regex(r'^\d+$', '房间号格式不对哦, 请重新输入~', fullmatch=True)]) # 获取直播间信息 __live_info = await get_live_info(__sub_id) if __live_info['status'] == 'error': await session.send('似乎并没有这个直播间QAQ') log.logger.info(f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 添加直播间订阅失败, ' f'没有找到该房间号: {__sub_id} 对应的直播间') return else: __up_info = await get_user_info(__live_info['uid']) __up_name = __up_info['name'] __sub_check = session.get('check', prompt=f'即将订阅【{__up_name}】的直播间!\n确认吗?\n\n【是/否】', arg_filters=[controllers.handle_cancellation(session), validators.not_empty('输入不能为空'), validators.match_regex(r'^[是否]$', '输入不对哦, 请重新输入~', fullmatch=True)]) if __sub_check == '否': await session.send('那就不订阅好了QAQ') log.logger.info(f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 已取消添加直播间订阅, 操作中止') return elif __sub_check == '是': try: # 首先更新直播间信息 __is_success = await add_live_sub_to_db(sub_id=__sub_id, up_name=__up_name) if not __is_success: await session.send('发生了意料之外的错误OvO') log.logger.warning(f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} ' f'试图订阅直播间{__sub_id}时发生了错误, 更新直播间信息数据库操作失败, 错误信息见日志.') return # 然后添加群组订阅 __is_success = await add_group_live_sub_to_db(sub_id=__sub_id, group_id=group_id) if not __is_success: await session.send('发生了意料之外的错误OvO') log.logger.warning(f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} ' f'试图订阅直播间{__sub_id}时发生了错误, 添加群组订阅数据库操作失败, 错误信息见日志.') return # 添加直播间时需要刷新全局监控列表 global live_status global live_title for __room_id in query_live_sub_list(): # 直播状态放入live_status全局变量中 live_status[__room_id] = await init_live_status(__room_id) for __room_id in query_live_sub_list(): # 直播间标题放入live_title全局变量中 live_title[__room_id] = await init_live_title(__room_id) await session.send(f'已成功的订阅【{__up_name}】的直播间!') log.logger.info(f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 已成功添加: {__up_name} 的直播间订阅') except Exception as e: log.logger.warning(f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} ' f'试图添加: {__sub_id} 直播间订阅时发生了错误: {e}') session.finish('发生了未知的错误QAQ')
async def _(session: CommandSession): user = session.event.user_id group = session.event.group_id try: with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: data = json.load(f) except: data = {} try: with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: data1 = json.load(f) except: data1 = {} if str(group) in data.keys(): pass else: if str(user) in data1.keys(): pass else: if 0 <= now_time() < 5.5: await session.send( choice( [ 'zzzz......', 'zzzzzzzz......', 'zzz...好涩哦..zzz....', '别...不要..zzz..那..zzz..', '嘻嘻..zzz..呐~..zzzz..' ] ) ) else: with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: data = json.load(f) if data["pixiv_seach_img"] == "on": pid = session.current_arg.strip() if not pid: pid = session.get('message', prompt = '请告诉ATRI需要查询的Pid码') start =time.perf_counter() await session.send('开始P站搜图\n如搜索时间过长或许为图片过大上传较慢') URL = URL_1 + pid dc = json.loads(response.request_api(URL)) if not dc: session.finish('ATRI在网络上走散了...请重试...') img = f'https://pixiv.cat/{pid}.jpg' end = time.perf_counter() await session.send( IMG_SEACH_REPLY.format( user = user, pid = pid, title = dc["response"][0]["title"], width = dc["response"][0]["width"], height = dc["response"][0]["height"], tags = dc["response"][0]["tags"], account = dc["response"][0]["user"]["account"], name = dc["response"][0]["user"]["name"], user_link = f'https://www.pixiv.net/users/' + f'{dc["response"][0]["user"]["id"]}', img = img, time = round(end - start, 3) ) ) else: await session.send('该功能已被禁用...')
async def weather(session: CommandSession): city = session.get('city', prompt='你想查询哪个城市的天气呢?') weather_report = await get_weather(city) await session.send(weather_report, at_sender=True)
async def gameres(session: CommandSession): name = session.get('name', prompt='输入用户id') res = await get_gamedata(name) await session.send(res)
async def apply(session: CommandSession): group_id = session.ctx['group_id'] if group_id not in config.group_id_dict['thwiki_live']: return global l begin = session.get('begin') end = session.get('end') float_end = session.get('float_end') qq = session.get('qq') card = session.get('card') name = session.get('name') tz = session.get('tz') if qq in blacklist: return if begin == False or (float_end == False and end == False): await session.send('时间格式不正确,请使用' '(\\d+年)?(\\d+月)?(\\d+(日|号))?' '(' '(\\d+(时|点))' '(\\d+分)?' '|' '\\d+:\\d+' '),且保证时间有效' '\n开始可用now,结束可用float') return if not float_end: if begin > end: await session.send('结束需要比开始晚!') return if begin < datetime.now() - timedelta(minutes=1): await session.send('开始需要比现在晚!') return if len(name) < 1: await session.send('不能没有名字') return if '\n' in name: await session.send('名字不能含有换行符') return t = list(filter(lambda x: x.name == name, l)) if len(t) != 0: await session.send('已有重名,请换名字') return e = Event(begin, end, qq, card, name, float_end) for i in l: if i.overlap(e): await session.send( '这个时间段已经有人了\n' + (str(i) if tz is None else f"时区:{tz.tzname(datetime.now())}\n{i.str_tz(tz)}"), auto_escape=True) return l.append(e) l.sort(key=lambda x: x.begin) l = polish(l) await _save(l) check = find_or_new(qq=qq) await session.send(f'成功申请,id为{e.id},您还在试用期,请等待管理员监视,敬请谅解w' if check['trail'] else f'成功申请,id为{e.id}') ret = await change_des_to_list() if json.loads(ret)['code'] != 0: await session.send('更新到直播间失败') if check['trail']: for group in config.group_id_dict['thwiki_supervise']: await get_bot().send_group_msg(group_id=group, message=f'{e}\n等待管理员监视')
async def translate(session: CommandSession): message = session.get('message', prompt='舰长想要查询什么圣痕呢?') # 获取待查询的圣痕 translate_send = await get_translate(message) # 将待查询的圣痕传给查询函数 await session.send(translate_send) # 发送翻译后的语句
async def AtoQ(session: CommandSession): Que = session.get('Que', prompt='请输入问题') if (question.count(Que) != 0): index = question.index(Que) await session.send(answer[index])
async def landsol_distrust(session: CommandSession): global CACHE, DATA, FLAG message = '' uid = str(session.event.user_id) if session.event.detail_type != 'group': await session.finish(GROUP_ONLY) if session.current_arg != 'y': INPUT = session.current_arg CACHE = INPUT if INPUT == '': await session.finish(FORMAT) L_INPUT = INPUT.split(' ', 3) if L_INPUT[0] == '-a': try: if L_INPUT[1] == 'CN' or L_INPUT[1] == 'Cn' or L_INPUT[ 1] == 'cN' or L_INPUT[1] == 'cn': sid = 'CN' if L_INPUT[1] == 'JP' or L_INPUT[1] == 'Jp' or L_INPUT[ 1] == 'jP' or L_INPUT[1] == 'jp': sid = 'JP' if L_INPUT[1] == 'KR' or L_INPUT[1] == 'Kr' or L_INPUT[ 1] == 'kR' or L_INPUT[1] == 'kr': sid = 'KR' if L_INPUT[1] == 'QQ' or L_INPUT[1] == 'Qq' or L_INPUT[ 1] == 'qQ' or L_INPUT[1] == 'qq': sid = 'QQ' if L_INPUT[1] == 'TW' or L_INPUT[1] == 'Tw' or L_INPUT[ 1] == 'tW' or L_INPUT[1] == 'tw': sid = 'TW' id, notes = L_INPUT[2], L_INPUT[3] except IndexError: if FLAG == True: FLAG = False return await session.finish(A_FORMAT) with open(DISTRUST, 'r', encoding='utf-8') as file: DATA = json.load(file) if id in DATA[sid]: FLAG = True confirm = session.get( 'message', prompt= f'ID {id} 已存在于兰德索尔失信人员名单~\n{DATA[sid][id]}\n※ 回复 y 更新此 ID 的不良行为~\n※ 回复其他内容取消操作~' ) if L_INPUT[0] == '-f': try: if L_INPUT[1] == 'CN' or L_INPUT[1] == 'Cn' or L_INPUT[ 1] == 'cN' or L_INPUT[1] == 'cn': sid = 'CN' if L_INPUT[1] == 'JP' or L_INPUT[1] == 'Jp' or L_INPUT[ 1] == 'jP' or L_INPUT[1] == 'jp': sid = 'JP' if L_INPUT[1] == 'KR' or L_INPUT[1] == 'Kr' or L_INPUT[ 1] == 'kR' or L_INPUT[1] == 'kr': sid = 'KR' if L_INPUT[1] == 'QQ' or L_INPUT[1] == 'Qq' or L_INPUT[ 1] == 'qQ' or L_INPUT[1] == 'qq': sid = 'QQ' if L_INPUT[1] == 'TW' or L_INPUT[1] == 'Tw' or L_INPUT[ 1] == 'tW' or L_INPUT[1] == 'tw': sid = 'TW' id = L_INPUT[2] except IndexError: await session.finish(F_FORMAT) with open(DISTRUST, 'r', encoding='utf-8') as file: DATA = json.load(file) if id in DATA[sid]: await session.finish(DATA[sid][id]) else: await session.finish(f'没有找到 ID {id} 的记录~') INPUT = CACHE L_INPUT = INPUT.split(' ', 3) if L_INPUT[1] == 'CN' or L_INPUT[1] == 'Cn' or L_INPUT[ 1] == 'cN' or L_INPUT[1] == 'cn': sid = 'CN' if L_INPUT[1] == 'JP' or L_INPUT[1] == 'Jp' or L_INPUT[ 1] == 'jP' or L_INPUT[1] == 'jp': sid = 'JP' if L_INPUT[1] == 'KR' or L_INPUT[1] == 'Kr' or L_INPUT[ 1] == 'kR' or L_INPUT[1] == 'kr': sid = 'KR' if L_INPUT[1] == 'QQ' or L_INPUT[1] == 'Qq' or L_INPUT[ 1] == 'qQ' or L_INPUT[1] == 'qq': sid = 'QQ' if L_INPUT[1] == 'TW' or L_INPUT[1] == 'Tw' or L_INPUT[ 1] == 'tW' or L_INPUT[1] == 'tw': sid = 'TW' id, notes = L_INPUT[2], L_INPUT[3] year = int(datetime.datetime.now().strftime('%Y')) # 未使用,可酌情删除 month = int(datetime.datetime.now().strftime('%m')) - 1 day = int(datetime.datetime.now().strftime('%d')) - 1 hour = int(datetime.datetime.now().strftime('%H')) minute = int(datetime.datetime.now().strftime('%M')) time = f'{MONTH_NAME[month]}{DATE_NAME[day]} · {NUM_NAME[hour]}{NUM_NAME[minute]}' DATA[sid][id] = f'(待审核){time}\n{notes}' if sid == 'QQ': message += f'{time}\n(待审核)\n失信人员 QQ {id}\n上报事由 {notes}' else: message += f'{time}\n(待审核)\n失信人员 ID {id}\n区服 {sid}\n上报事由 {notes}' with open(DISTRUST, 'w', encoding='utf-8') as file: json.dump(DATA, file, ensure_ascii=False, indent=4) info = await bot.get_stranger_info(user_id=uid) # 获取个人资料 username = info['nickname'] # 获取昵称 message += f'\n※ 申诉请前往 https://github.com/Lancercmd/Landsol-Distrust 或使用优妮来杯咖啡' # 来杯咖啡,联动 IceCirno / HoshinoBot https://github.com/Ice-Cirno/HoshinoBot if sid == 'QQ': await session.bot.send_private_msg( user_id=SUPERUSERS, message= f'有新的失信人员进入审核~\n(待审核){time}\n失信人员 QQ {id}\n上报事由 {notes}\n※ 本条记录由 {username}({uid}) 上报~' ) else: await session.bot.send_private_msg( user_id=SUPERUSERS, message= f'有新的失信人员进入审核~\n(待审核){time}\n失信人员 ID {id}\n区服 {sid}\n上报事由 {notes}\n※ 本条记录由 {username}({uid}) 上报~' ) # 向主人发送私聊记录,仅向主人展示上报者的身份以保密 ##################################################### #============此处可以向审核们推送message============# ##################################################### await session.finish( f'ID {id} 已进入公开审核~\n※ 待审核通过即会正式进入兰德索尔失信人员名单~\n※ 恶意上报将不会被收入,同时您将会进入兰德索尔失信人员名单!' )
async def pixiv(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': log.logger.info( f'{__name__}: 用户: {session.event.user_id} 在{session_type}中使用了命令') else: log.logger.info( f'{__name__}: 用户: {session.event.user_id} 在{session_type}环境中使用了命令, 已中止命令执行' ) return # 从会话状态(session.state)中获取pid, 如果当前不存在, 则询问用户 pid = session.get('pixiv', prompt='你是想看周榜, 还是日榜, 还是作品呢?想看特定作品的话请输入PixivID~') if pid == 'error': await session.send('似乎不能访问Pixiv呢QAQ') log.logger.warning( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 获取Pixiv资源被失败, 网络错误' ) return try: await session.send('稍等, 正在加载图片资源~') # 获取illust信息 __payload = {'key': API_KEY, 'pid': pid} illustinfo = await fetch(url=SEARCH_API_URL, paras=__payload) except Exception as e: log.logger.warning( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 试图使用命令pixiv时发生了错误: {e}' ) return try: # 检查图片状态 if 'error' in illustinfo.keys(): await session.send('加载失败, 网络超时或没有这张图QAQ') log.logger.info( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 获取Pixiv资源被失败, 网络超时或 {pid} 不存在' ) return else: # 检查R18 if illustinfo['is_r18']: await session.send('不准开车车!!') log.logger.info( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 获取Pixiv资源被中止, {pid} 为R-18资源' ) return # 正常情况 else: img_seg = MessageSegment.image(illustinfo['pic_b64']) # 发送图片 await session.send(img_seg) # 发送图片信息 await session.send(illustinfo['illust_info']) log.logger.info( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 成功获取Pixiv资源: {pid}' ) # 有问题的话大概率都是网络问题, 不是也要推锅给网络OvO except Exception as e: await session.send('发生了未知的错误QAQ') log.logger.warning( f'{__name__}: 群组: {group_id}, 用户: {session.event.user_id} 试图使用命令pixiv时发生了错误: {e}' ) '''不使用web api的版本
async def light_brightness(session: CommandSession): bright = session.get('bright', prompt='请输入亮度(1-100)') event = await light_bright(bright) await session.send(event)
async def weather(session: CommandSession): city = session.get('city', prompt=__(e.WHICH_CITY)) await session.send(__(e.REPORT, city=city))
async def push(session: CommandSession): message = session.get( "message", prompt="你想让我提醒什么内容呢?语句命令都可,输入 `取消、不` 等来取消", arg_filters=[ controllers.handle_cancellation(session), str.lstrip, validators.not_empty("请输入有效内容哦~"), ], ) tn = TimeNormalizer() hour = session.state.get("hour") minute = session.state.get("minute") if hour is None or minute is None: time = session.get( "time", prompt="你希望我在每天的什么时候给你提醒呢?", arg_filters=[ controllers.handle_cancellation(session), str.lstrip, validators.not_empty("请输入有效内容哦~"), ], ) m = re.match(r"(\d{1,2})[.::](\d{1,2})", time) if m: hour = int(m.group(1)) minute = int(m.group(2) or 0) else: time_json = tn.parse(time) if time_json["type"] == "error": del session.state["time"] session.pause("时间格式不对啦,请重新发送") elif time_json["type"] == "timedelta": time_diff = time_json["timedelta"] hour = time_diff["hour"] minute = time_diff["minute"] elif time_json["type"] == "timestamp": time_target = datetime.strptime(time_json["timestamp"], "%Y-%m-%d %H:%M:%S") # 默认时间点为中午12点 if (not re.search(r"[\d+一二两三四五六七八九十]+点", time) and time_target.hour == 0 and time_target.minute == 0 and time_target.second == 0): time_target.replace(hour=12) hour = time_target.hour minute = time_target.minute session.state["hour"] = hour session.state["minute"] = minute escaped_message = message.replace("\\", "\\\\").replace('"', '\\"') switch_arg = f'--repeat "{escaped_message}"' try: job = await add_scheduled_commands( ScheduledCommand("switch", switch_arg), job_id=make_job_id( PLUGIN_NAME, session.ctx, (random_string(1, string.ascii_lowercase) + random_string(7, string.ascii_lowercase + string.digits)), ), event=session.event, trigger="cron", hour=hour, minute=minute, replace_existing=False, ) session.finish(f"添加提醒成功啦,下次提醒时间 " f'{job.next_run_time.strftime("%Y-%m-%d %H:%M")}') except JobIdConflictError: session.finish("添加提醒失败,有可能只是运气不好哦,请稍后重试~")
async def _(session: CommandSession): user = session.event.user_id group = session.event.group_id try: with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobGroup.json', 'r') as f: data = json.load(f) except: data = {} try: with open(Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json', 'r') as f: data1 = json.load(f) except: data1 = {} if str(group) in data.keys(): pass else: if str(user) in data1.keys(): pass else: if 0 <= now_time() < 5.5: await session.send( choice( [ 'zzzz......', 'zzzzzzzz......', 'zzz...好涩哦..zzz....', '别...不要..zzz..那..zzz..', '嘻嘻..zzz..呐~..zzzz..' ] ) ) else: with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: data = json.load(f) if data["pixiv_seach_author"] == "on": author_id = session.current_arg.strip() if not author_id: author_id = session.get('message', prompt = '请告诉ATRI需要查询的画师ID') start =time.perf_counter() await session.send(f'开始获取画师{author_id}的前三项作品\n如获取时间过长或许为图片过大上传较慢') URL = URL_2 + author_id dc = json.loads(response.request_api(URL)) if not dc: session.finish('ATRI在网络上走散了...请重试...') d ={} for i in range(0,3): pid = dc["response"][i]["id"] pidURL = f'https://pixiv.cat/{pid}.jpg' d[i] = [f'{pid}',f'{pidURL}'] msg0 = (f'[CQ:at,qq={user}]\n画师id:{author_id},接下来展示前三作品') result = sorted( d.items(), key = lambda x:x[1], reverse = True ) t = 0 for i in result: t += 1 msg = (f'\n---------------\n({t})\nPid: {i[1][0]}\n{i[1][1]}') msg0 += msg end = time.perf_counter() msg1 = (f'\n---------------\n完成时间:{round(end - start, 3)}s') msg0 += msg1 await session.send(msg0) else: await session.send('该功能已被禁用...')
async def cancel_order(session: CommandSession): order_id = session.get('order_id', prompt='请输入需要撤单的订单号') if not kIntPattern.match(order_id): session.send('无效订单号') return await send_command(f'cancel_order {order_id}')
async def kuaidi(session: CommandSession): code = session.get('code', prompt='输入单号') code_info = await recognise(code) await session.send(code_info)
async def unsubscribe_market_depth(session: CommandSession): contract_id = session.get('contract_id', prompt='请输入股票id') if not kIntPattern.match(contract_id): session.send('无效股票id') return await send_command(f'unsubscribe_market_depth {contract_id}')
async def weather(session: CommandSession): city = session.get('city', prompt='你想查询哪个城市?') weather_report = await get_weather_of_city(city) await session.send(weather_report)
async def stop_strategy(session: CommandSession): strategy_id = session.get('strategy_id', prompt='请输入需要停止的策略号') if not kIntPattern.match(strategy_id): session.send('无效的策略号') return await send_command(f'stop_strategy {strategy_id}')
async def search_buhuibaidume(session: CommandSession): content = session.get('content', prompt='你想百度什么?') msg = await get_buhuibaidume_url(content) await session.send(str(msg))
async def yxh(session: CommandSession): body = session.get('body', prompt='请输入主体') thing = session.get('thing', prompt='请输入事件') another = session.get('another', prompt='请输入事件的另一种说法') res = await get_phrase(body, thing, another) await session.send(res)
async def speak_to_me(session: CommandSession): content = session.get('content', prompt='跟大家说啥?') session.finish(content)
async def add(session: CommandSession): # 从会话状态(session.state)中获取订阅信息链接(link),如果当前不存在,则询问用户 user_id = session.ctx['user_id'] try: group_id = session.ctx['group_id'] except: group_id = None if group_id: rss_dy_link = session.get( 'add', prompt= '要订阅的信息不能为空呢,请重新输入\n输入样例:\ntest /twitter/user/xx \n关于插件:http://ii1.fun/7byIVb' ) else: rss_dy_link = session.get( 'add', prompt= '要订阅的信息不能为空呢,请重新输入\n输入样例:\ntest /twitter/user/xx 11,11 -1 5 1 0 \n订阅名 订阅地址 qq(,分隔,为空-1) 群号(,分隔,为空-1) 更新时间(分钟,可选) 1/0(代理,可选) 1/0(翻译,可选) 1/0(仅标题,可选) 1/0(仅图片,可选)' ) # 获取、处理信息 dy = rss_dy_link.split(' ') # await session.send('')#反馈 # print('\n\n\n'+str(len(dy)),dy[0]+'\n\n\n') try: name = dy[0] name = re.sub(r'\?|\*|\:|\"|\<|\>|\\|/|\|', '_', name) if name == 'rss': name = 'rss_' try: url = dy[1] except: url = None flag = 0 try: list_rss = RWlist.readRss() for old in list_rss: if old.name == name and not url: old_rss = old flag = 1 elif str(old.url).lower() in str(url).lower(): old_rss = old flag = 2 elif old.name == name: flag = 3 except: print("error") if group_id: if flag == 0 and url: if len(dy) > 2: only_title = bool(int(dy[2])) else: only_title = False if len(dy) > 3: only_pic = bool(int(dy[3])) else: only_pic = False translation = False times = int(config.add_uptime) proxy = config.add_proxy if user_id in config.SUPERUSERS and len(dy) > 4: proxy = bool(int(dy[4])) if user_id in config.SUPERUSERS and len(dy) > 5: times = int(dy[5]) user_id = -1 else: if flag == 1 or flag == 2: if str(group_id) not in str(old_rss.group_id): list_rss.remove(old_rss) old_rss.group_id.append(str(group_id)) list_rss.append(old_rss) RWlist.writeRss(list_rss) if flag == 1: await session.send( str(name) + '订阅名已存在,自动加入现有订阅,订阅地址为:' + str(old_rss.url)) else: await session.send( str(url) + '订阅链接已存在,订阅名使用已有的订阅名"' + str(old_rss.name) + '",订阅成功!') else: await session.send('订阅链接已经存在!') elif not url: await session.send('订阅名不存在!') else: await session.send('订阅名已存在,请更换个订阅名订阅') return elif user_id and flag == 0: user_id = dy[2] group_id = dy[3] if len(dy) > 4: times = int(dy[4]) else: times = 5 if len(dy) > 5: proxy = bool(int(dy[5])) else: proxy = False if len(dy) > 6: notrsshub = bool(int(dy[6])) else: notrsshub = False if len(dy) > 7: translation = bool(int(dy[6])) else: translation = False if len(dy) > 8: only_title = bool(int(dy[7])) else: only_title = False if len(dy) > 9: only_pic = bool(int(dy[8])) else: only_pic = False else: # 向用户发送失败信息 logger.info('添加' + rss.name + '失败,已存在') await session.send('订阅名或订阅链接已经存在!') return rss = RSS_class.rss(name, url, str(user_id), str(group_id), times, proxy, notrsshub, translation, only_title, only_pic) # 写入订阅配置文件 bot = nonebot.get_bot() try: list_rss.append(rss) RWlist.writeRss(list_rss) except: list_rss = [] list_rss.append(rss) RWlist.writeRss(list_rss) if flag == 0: # 加入订阅任务队列 TR.rss_trigger(times, rss) logger.info('添加' + rss.name + '成功') # 向用户发送成功信息 await session.send(rss.name + '订阅成功!') except BaseException as e: logger.info(e) await session.send('参数不对哟!\n关于插件:http://ii1.fun/7byIVb')
async def AnimeSearch(session: CommandSession): user = session.event.user_id group = session.event.group_id msg = session.current_arg.strip() if checkNoob(user, group): if sleepTime(): await session.send(sleepTime()) else: if checkSwitch(__plugin_name__, group): if not msg: msg = session.get('message', prompt="请发送一张图片") await session.send("开始以图搜番\n(如搜索时间过长或无反应则为图片格式有问题)") p = '\\[CQ\\:image\\,file\\=.*?\\,url\\=(.*?)\\]' img = re.findall(p, msg) if img: URL = f'https://trace.moe/api/search?url={img[0]}' try: req = await get_bytes(URL) except: session.finish(errorBack('请求数据失败')) data = json.loads(req.decode()) try: d = {} for i in range(len(data['docs'])): if data['docs'][i]['title_chinese'] in d.keys(): d[data['docs'][i]['title_chinese']][0] += data[ 'docs'][i]['similarity'] else: m = data['docs'][i]['at'] / 60 s = data['docs'][i]['at'] % 60 if data['docs'][i]['episode'] == '': n = 1 else: n = data['docs'][i]['episode'] d[toSimpleString( data['docs'][i]['title_chinese'])] = [ data['docs'][i]['similarity'], f'第{n}集', f'{int(m)}分{int(s)}秒处' ] except: session.finish(errorBack('处理数据失败')) result = sorted(d.items(), key=lambda x: x[1], reverse=True) t = 0 msg0 = f'[CQ:at,qq={user}]\n根据所提供的图片按照相似度找到{len(d)}个结果:' for i in result: t += 1 lk = ('%.2f%%' % (i[1][0] * 100)) msg = ( f'\n——————————\n({t})\n相似度:{lk}\n动漫名:《{i[0]}》\n时间点:{i[1][1]} {i[1][2]}' ) msg0 += msg await session.send(msg0) else: session.finish('该功能已关闭...')
async def bartending(session: CommandSession): formula = session.get('formula', prompt='请输入配方.') desc = await get_drink(formula) await session.send(desc)
async def channel(session: CommandSession): if session.event.detail_type != 'private': session.finish("channel命令仅适用于私聊使用") content = session.get('content', prompt='要发布的内容')
async def addname(session: CommandSession): if not check_usage(): return name = session.get('name', prompt='你想D谁?倒是告诉我名字啊').strip() if name: add_result = await add_vtb(1, name) await session.send(add_result)