def _(session: NLPSession): groupRate = PluginManager.settings(__plugin_name__, ctx=session.ctx).settings[ "rate" ] randomNum, msgID = randint(0, groupRate - 1), session.ctx["message_id"] groupID = session.ctx.get("group_id") if not groupID: return logger.debug( f"Chat {groupID} has a repeat probability of {1/groupRate:.3%}." + f"The random number of the current session {msgID} is {randomNum}." ) if not randomNum: return session.msg, False
def searchImage(session: CommandSession): enableR18 = PluginManager.settings(SEARCH_IMAGE_METHOD, session.ctx).settings[ "r-18" ] keywords = session.get("keyword") page = session.get_optional("page", 1) session.send(f'开始搜索"{keywords}"的第{page}页') apiGet = pixiv.searchIllust(keyword=keywords, page=page) apiParse = parseMultiImage(apiGet, mosaicR18=not enableR18) sortResult = sorted(apiParse["result"], key=lambda x: x["ratio"], reverse=True) messageRepeat = [ str(Config.customize.search_repeat).format(**data) for data in sortResult ] fullMessage = ( str(Config.customize.search_prefix).format(**apiParse) + "".join(messageRepeat[: Config.customize.size]) + str(Config.customize.search_suffix).format(**apiParse) ) return fullMessage
def memberImage(session: CommandSession): memberID = session.get("id") enableR18 = PluginManager.settings(MEMBER_IMAGE_METHOD, session.ctx).settings[ "r-18" ] page = session.get_optional("page", 1) session.send(f"开始获取Pixiv用户ID为{memberID}的作品第{page}页") apiGet = pixiv.getMemberIllust(memberID, page) apiParse = parseMultiImage(apiGet, mosaicR18=not enableR18) sortResult = sorted(apiParse["result"], key=lambda x: x["ratio"], reverse=True) messageRepeat = [ str(Config.customize.member_repeat).format(**data) for data in sortResult ] fullMessage = ( str(Config.customize.member_prefix).format(**apiParse) + "".join(messageRepeat[: Config.customize.size]) + str(Config.customize.member_suffix).format(**apiParse) ) return fullMessage
def getImage(session: CommandSession): allowR18: bool = PluginManager.settings(GET_IMAGE_METHOD, ctx=session.ctx).settings["r-18"] imageID: int = session.get("id") imageResloution: str = session.get_optional("res", "large") session.send(f"开始获取Pixiv ID为{imageID}的{imageResloution}") apiGet = pixiv.getImageDetail(imageID) apiParse = parseSingleImage(apiGet, mosaicR18=not allowR18) imageURLs = [p[imageResloution] for p in apiParse["download"]][:Config.customize.size] imageDownloaded = downloadMutliImage(imageURLs, mosaic=((not allowR18) and apiParse["r-18"])) images = [str(MessageSegment.image(imageDownloaded[i])) for i in imageURLs] repeatMessage = "\n".join(images) finalMessage = (str(Config.customize.image_prefix).format(**apiParse) + f"{repeatMessage}\n" + str(Config.customize.image_suffix).format(**apiParse)) return finalMessage
def _(session: NLPSession): status = PluginManager.settings(__plugin_name__, session.ctx).status if not status: return avResult = MATCH_AV.search(session.msg) bvResult = MATCH_BV.search(session.msg) if avResult: return IntentCommand(100, name="bilibili_info", args={ "id": int(avResult.group(1)), "auto": True }) elif bvResult: return IntentCommand( 100, name="bilibili_info", args={ "id": IDCoverter.bv2av(bvResult.group()), "auto": True }, ) else: return
def _(session: CommandSession): PluginManager.settings(__plugin_name__, session.ctx).status = False return "视频信息捕捉已关闭"
def _(session: CommandSession): PluginManager.settings(__plugin_name__, session.ctx).status = True return "每日问好已启用"
def _(session: CommandSession): PluginManager.settings(pluginName=__plugin_name__, ctx=session.ctx).status = False return "涩图功能已禁用"
def _(session: CommandSession): key = token_hex(8).upper() PluginManager.settings(pluginName=OPERATING_METHOD, ctx=session.ctx).settings = { "key": key } return f"涩图密钥已经生成,为{key}"
def r18KeyGen(session: CommandSession): key = token_hex(8).upper() PluginManager.settings(OPERATING_METHOD, ctx=session.ctx).settings = {"key": key} return f"密钥生成完毕,为{key}"
def _(session: CommandSession): session: CommandSession = SyncWrapper(session) groupID = session.ctx["group_id"] getSettings = PluginManager.settings(__plugin_name__, ctx=session.ctx) getSettings.status = False session.send(f"群{groupID}复读已经关闭")
def _(session: CommandSession): nowBlacklist: list = PluginManager.settings(__plugin_name__, session.event).settings return ("目前" + "".join(map(lambda x: str(MessageSegment.at(x)), nowBlacklist)) + "在黑名单上")
def _(session: CommandSession): PluginManager.settings(__plugin_name__, ctx=session.ctx).status = True return "群聊广播已被启用,您将会收到来自开发者的广播"
def _(session: CommandSession): PluginManager.settings(__plugin_name__, ctx=session.ctx).status = False return "群聊广播已被屏蔽,您将不会再收到来自开发者的广播"
def _(session: CommandSession): PluginManager.settings(__plugin_name__, ctx=session.ctx).status = True return "搜图功能已启用", False