Ejemplo n.º 1
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    img = state["img_url"]
    img = re.findall(r"(http://.*?)]", img)

    if len(img):
        pass
    else:
        await SaucenaoSearch.reject("请发送一张目标图片,而非文字或其他非图片成分(")

    await bot.send(event, "别急!正在搜索!")
    req = None

    URL = f'https://trace.moe/api/search?url={img[0]}'
    try:
        req = await aio_get_bytes(URL)
    except:
        await AnimeSearch.finish(errorRepo("请求数据失败"))

    d = {}
    data = json.loads(req.decode())

    try:
        for i in range(len(data['docs'])):
            if data['docs'][i]['title_chinese'] in d:
                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:
        await AnimeSearch.finish(errorRepo("处理数据失败"))

    result = sorted(d.items(), key=lambda x: x[1], reverse=True)

    t = 0
    msg0 = f'[CQ:at,qq={state["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 AnimeSearch.finish(msg0)
Ejemplo n.º 2
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    pid = state["pid"]
    pid = re.findall(r"\d+", pid)

    if len(pid):
        pass
    else:
        await pixivSearchIMG.reject("请发送纯阿拉伯数字的pid")

    await bot.send(event, "别急!在搜索了!")

    URL = f"https://api.imjad.cn/pixiv/v1/?type=illust&id={pid[0]}"
    data = {}

    try:
        data = json.loads(await aio_get_bytes(URL))
    except:
        await pixivSearchIMG.finish(errorRepo("请求数据失败"))

    IMG = data["response"][0]["image_urls"]["large"]
    IMG = IMG.replace("i.pximg.net", "i.pixiv.cat")

    msg0 = f'[CQ:at,qq={state["user"]}]\n'
    msg0 += "Search result:\n"
    msg0 += f"Pid: {pid[0]}\n"
    msg0 += f'Title {data["response"][0]["title"]}\n'
    msg0 += f'W&H: {data["response"][0]["width"]}x{data["response"][0]["height"]}\n'
    msg0 += f'Tags: {data["response"][0]["tags"]}\n'
    msg0 += f'Account Name: {data["response"][0]["user"]["account"]}\n'
    msg0 += f'Author Name: {data["response"][0]["user"]["name"]}\n'
    msg0 += f'Link: https://www.pixiv.net/users/{data["response"][0]["user"]["id"]}\n'
    msg0 += IMG.replace('https://', '')

    await pixivSearchIMG.finish(msg0)
Ejemplo n.º 3
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    args = str(event.message).strip()

    if not args:

        await delDriftingBottle.finish("请查看文档获取帮助(")

    if not DRIFTING_BOTTLE_PATH.is_file():
        with open(DRIFTING_BOTTLE_PATH, 'w') as f:
            f.write(json.dumps({}))

        await delDriftingBottle.finish('清除了个寂寞...')

    with open(DRIFTING_BOTTLE_PATH, 'r') as f:
        data = json.load(f)

    if args[0] == 'delall':
        os.remove(os.path.abspath(DRIFTING_BOTTLE_PATH))

    elif args[0] == 'del':
        try:
            del data[args[1]]
        except:
            await delDriftingBottle.finish(errorRepo('清除失败了...'))

    with open(DRIFTING_BOTTLE_PATH, 'w') as f:
        f.write(json.dumps(data))
        f.close()

    result = args[1] if args[0] == 'del' else "ALL"
    await delDriftingBottle.finish(
        f'完成啦!成功清除漂流瓶[{result}],目前还剩余[{len(data)}]个~')
Ejemplo n.º 4
0
def resultRepo(user: str, key: str, img_url: str):
    try:
        task = SauceNAO(key)
        data = task.search(img_url)
        print(data)
    except Exception:
        return errorRepo('请求数据失败')

    data = json.loads(data)['results'][0]
    msg0 = ''
    print(data)

    msg0 += f'[CQ:at,qq={user}]\n'
    msg0 += "SauceNAO INFO:\n"
    msg0 += f"[CQ:image,file={data['header'].get('thumbnail', None)}]\n"
    msg0 += f"Like:{data['header'].get('similarity', 0)}%\n"
    msg0 += f"Title:{data['data'].get('title', None)}\n"
    msg0 += f"Pixiv ID:{data['data'].get('pixiv_id', None)}\n"
    msg0 += f"Author:{data['data'].get('member_name', None)}\n"
    msg0 += f"Autoor ID:{data['data'].get('member_id', None)}\n"
    msg0 += f"Pixiv URL: https://www.pixiv.net/artworks/{data['data'].get('pixiv_id', None)}\n"
    msg0 += f"Pic URL: https://pixiv.cat/{data['data'].get('pixiv_id', None)}.jpg"

    if float(data['header'].get('similarity', 0)) < 65:
        msg0 += '\n注:相似率小于65%不一定正确'

    return msg0
Ejemplo n.º 5
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    group = str(event.group_id)
    msg = str(event.message)

    if "[CQ:reply" in msg:
        if "搜图" in msg or "识图" in msg:
            if group == "None":
                await SaucenaoSearch_repo.finish("ごめんなさい...\n该功能只对群聊开放哦~~")

            try:
                repo_info = re.findall(r"CQ:reply,id=([0-9]\S+)]", msg)
                msg_id = repo_info[0]
            except Exception:
                logger.error("Get message_id ERROR!")
                await SaucenaoSearch_repo.finish(errorRepo('定位消息内容失败'))
                return

            aim = getMessage(msg_id)[f"{msg_id}"]["message"]
            img = img = re.findall(r"(http://.*?)]", aim)

            if len(img):
                pass
            else:
                await SaucenaoSearch_repo.finish('这消息内貌似没图片呢...')

            await bot.send(event, "别急!正在找图!")

            await SaucenaoSearch.finish(
                resultRepo(state['user'], key_SauceNAO, img[0]))
Ejemplo n.º 6
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    author_id = state["author_id"]
    author_id = re.findall(r"\d+", author_id)

    if len(author_id):
        pass
    else:
        await pixivSearchAuthor.reject("请发送纯阿拉伯数字的画师id")

    await bot.send(event, f"别急!在搜索了!\n将展示画师[{author_id[0]}]的前三项作品")

    URL = f"https://api.imjad.cn/pixiv/v1/?type=member_illust&id={author_id[0]}"
    data = {}

    try:
        data = json.loads(await aio_get_bytes(URL))
    except:
        await pixivSearchAuthor.finish(errorRepo("请求网络失败"))

    d = {}

    for i in range(0, 3):
        pid = data["response"][i]["id"]
        title = data["response"][i]["title"]
        IMG = data["response"][i]["image_urls"]["large"]
        IMG = IMG.replace("i.pximg.net", "i.pixiv.cat")
        d[i] = [f"{pid}", f"{title}", f"{IMG}"]

    msg = f'[CQ:at,qq={state["user"]}]'

    result = sorted(d.items(), key=lambda x: x[1], reverse=True)

    t = 0

    for i in result:
        t += 1
        msg += "\n————————————\n"
        msg += f"({t})\n"
        msg += f"Title: {i[1][1]}\n"
        msg += f"Pid: {i[1][0]}\n"
        msg += f"{i[1][2].replace('https://', '')}"

    await pixivSearchAuthor.finish(msg)
Ejemplo n.º 7
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    uid = str(state['uid'])

    if (len(uid) == 9):
        await bot.send(event, '别急,在搜索了!')
        uid_info = ''

        try:
            uid_info = Genshin().JsonAnalysis(Genshin().GetInfo(uid))
        except:
            await genshinInfo.finish(
                errorRepo("数据请求错误,原因可能为ID输入错误或不存在\n暂时只支持国服查询("))

        msg0 = f'{uid} Genshin Info:\n'
        msg0 += uid_info
        print(uid_info)
        await genshinInfo.finish(msg0)

    else:
        await genshinInfo.finish('UID检查未通过,请确保此ID为9位数或者是否为国服ID~!')
Ejemplo n.º 8
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    track_id = state['track_id']

    data = {}

    try:
        with open(file_error, 'r') as f:
            data = json.load(f)
    except FileNotFoundError:
        await trackError.finish(errorRepo("读取文件时错误"))

    if track_id in data:
        info_error = data[track_id]

        msg0 = f"trackID: {track_id}\n"
        msg0 += info_error

        await trackError.finish(msg0)

    else:
        await trackError.finish("未发现该ID")
Ejemplo n.º 9
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    user = str(event.user_id)
    global list_Y

    if countX(list_Y, user) == 3:
        list_Y.append(user)
        await bot.send(event, "额......需要咱安慰一下嘛~?")

    elif countX(list_Y, user) == 6:
        await bot.send(event, "如果心里感到难受就赶快去睡觉奥!别再憋自己了!")
        list_Y = list(set(list_Y))

    else:
        list_Y.append(user)
        URL = "https://api.imjad.cn/hitokoto/?cat=a&charset=utf-8&length=50&encode=json&fun=sync&source="
        info = {}

        try:
            info = json.loads(request_api_text(URL))
        except:
            await hitokoto.finish(errorRepo("请求错误"))

        await hitokoto.finish(info["hitokoto"])
Ejemplo n.º 10
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    user = str(event.user_id)

    await bot.send(event, "正在获取P站每日排行榜前三作品")

    URL = "https://api.imjad.cn/pixiv/v1/?type=rank"
    data = {}

    try:
        data = json.loads(await aio_get_bytes(URL))
    except:
        await pixivRank.finish(errorRepo("网络请求失败"))

    d = {}
    for i in range(0, 3):
        pid = data["response"][0]["works"][i]["work"]["id"]
        title = data["response"][0]["works"][i]["work"]["title"]
        IMG = data["response"][0]["works"][i]["work"]["image_urls"]["large"]
        IMG = IMG.replace("i.pximg.net", "i.pixiv.cat")
        d[i] = [f"{pid}", f"{title}", f"{IMG}"]

    msg = f"[CQ:at,qq={user}]"

    result = sorted(d.items(), key=lambda x: x[1], reverse=True)

    t = 0

    for i in result:
        t += 1
        msg += "\n————————————\n"
        msg += f"({t})\n"
        msg += f"Title: {i[1][1]}\n"
        msg += f"Pid: {i[1][0]}\n"
        msg += f"{i[1][2].replace('https://', '')}"

    print(msg)
    await pixivRank.finish(msg)
Ejemplo n.º 11
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    user = str(event.user_id)
    global list_M

    if countX(list_M, user) == 3:
        list_M.append(user)
        await bot.send(event,
                       "不是??你这么想被咱骂的嘛??被咱骂就这么舒服的吗?!该......你该不会是.....M吧!")

    elif countX(list_M, user) == 6:
        await bot.send(event, "给我适可而止阿!?")
        list_M = list(set(list_M))

    else:
        list_M.append(user)
        URL = "https://nmsl.shadiao.app/api.php?level=min&lang=zh_cn"
        msg = ""

        try:
            msg = request_api_text(URL)
        except exceptions:
            await fxxkMe.finish(errorRepo("请求错误"))

        await fxxkMe.finish(msg)
Ejemplo n.º 12
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    msg = str(event.message).strip()

    if not msg:
        await status_info.finish("请查看文档获取帮助(")

    if msg == "info":
        try:
            cpu = psutil.cpu_percent(interval=1)
            memory = psutil.virtual_memory().percent
            disk = psutil.disk_usage('/').percent
            inteSENT = psutil.net_io_counters().bytes_sent  # type: ignore
            inteRECV = psutil.net_io_counters().bytes_recv  # type: ignore
        except:
            await status_info.finish(errorRepo("读取系统状态失败"))

        status = "アトリは、高性能ですから!"

        if cpu > 80:  # type: ignore
            status = 'ATRI感觉头有点晕...'
            if memory > 80:  # type: ignore
                status = 'ATRI感觉有点头晕并且有点累...'
        elif disk > 80:  # type: ignore
            status = 'ATRI感觉身体要被塞满了...'

        msg0 = "ATRI status-info:\n"
        msg0 += f"* CPU: {cpu}%\n"  # type: ignore
        msg0 += f"* MEM: {memory}%\n"  # type: ignore
        msg0 += f"* Disk {disk}%\n"  # type: ignore
        msg0 += f"* BytesSENT: {inteSENT}\n"  # type: ignore
        msg0 += f"* BytesRECV: {inteRECV}\n"  # type: ignore
        msg0 += status

        await status_info.finish(msg0)

    elif msg == "sqlite":
        con = sqlite3.connect(
            Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' /
            'normal.db')  # setu-normal
        cur = con.cursor()
        cur.execute("select * from normal")
        data_normal = len(cur.fetchall())
        con.close()

        con = sqlite3.connect(
            Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' /
            'nearR18.db')  # setu-nearR18
        cur = con.cursor()
        cur.execute("select * from nearR18")
        data_nearR18 = len(cur.fetchall())
        con.close()

        con = sqlite3.connect(
            Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' /
            'r18.db')  # setu-r18
        cur = con.cursor()
        cur.execute("select * from r18")
        data_r18 = len(cur.fetchall())
        con.close()

        msg0 = "ATRI status-sqlite:\n"
        msg0 += "Setu:\n"
        msg0 += f"├normal: {data_normal}\n"
        msg0 += f"├nearR18: {data_nearR18}\n"
        msg0 += f"└R18: {data_r18}"

        await status_info.finish(msg0)
Ejemplo n.º 13
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    msg = str(event.message).strip().split(' ')

    if not msg[0] and not msg[1]:
        msg0 = "请检查格式奥~!\n"
        msg0 += "setu-upload [type] [pid]\n"
        msg0 += "type: normal, nearR18, r18"
        await UploadSetu.finish(msg0)

    if msg[0] not in ["normal", "nearR18", "nearr18", "r18", "R18"]:
        msg0 = "请检查类型~!\n"
        msg0 += "type: normal, nearR18, r18"
        await UploadSetu.finish(msg0)

    s_type = msg[0]
    pid = msg[1]

    URL = f'https://api.imjad.cn/pixiv/v1/?type=illust&id={pid}'
    info = {}

    try:
        info = json.loads(await aio_get_bytes(URL))
    except client_exceptions:
        await UploadSetu.finish(errorRepo("网络请求出错"))

    info = info["response"][0]
    title = info["title"]
    tags = info["tags"]
    account = info["user"]["account"]
    name = info["user"]["name"]
    u_id = info["user"]["id"]
    user_link = f'https://www.pixiv.net/users/{u_id}'
    IMG = info["iamge_urls"]["large"]
    IMG = IMG.replace("i.pximg.net", "i.pixiv.cat")

    data_setu = (f'{pid}', f'{title}', f'{tags}', f'{account}', f'{name}',
                 f'{u_id}', f'{user_link}', f'{IMG}')

    if s_type == "nearr18":
        s_type = "nearR18"
    elif s_type == "R18":
        s_type = "r18"
    else:
        pass

    os.makedirs('ATRI/data/data_Sqlite/setu', exist_ok=True)

    if os.path.exists(f'ATRI/data/data_Sqlite/setu/{s_type}.db'):
        print('数据文件存在!')
    else:
        await DeleteSetu.finish("数据库都不在添加🔨!?罢了我现创一个")
        con = sqlite3.connect(
            Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' /
            f'{s_type}.db')
        cur = con.cursor()
        cur.execute(
            f'CREATE TABLE {s_type}(pid PID, title TITLE, tags TAGS, account ACCOUNT, name NAME, u_id UID, user_link USERLINK, img IMG, UNIQUE(pid, title, tags, account, name, u_id, user_link, img))'
        )
        con.commit()
        cur.close()
        await bot.send(event, '完成')

    con = sqlite3.connect(
        Path('.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / f'{s_type}.db')
    cur = con.cursor()
    cur.execute(
        f'INSERT INTO {s_type}(pid, title, tags, account, name, u_id, user_link, img) VALUES(?, ?, ?, ?, ?, ?, ?, ?)',
        data_setu)
    con.commit()
    cur.close()

    await UploadSetu.finish(f"数据上传完成~!\n涩图库[{s_type}]涩图 +1")
Ejemplo n.º 14
0
async def _(bot: Bot, event: Event, state: dict) -> None:
    global SP_temp_list
    user = event.user_id
    group = event.group_id
    res = randint(1, 5)

    check_sepi()

    if countX(SP_temp_list, user) == 5:
        add_sepi(user)  # type: ignore
        SP_temp_list = list(set(SP_temp_list))
        delta = timedelta(hours=1)
        trigger = DateTrigger(run_date=datetime.now() + delta)
        scheduler.add_job(func=del_sepi,
                          trigger=trigger,
                          args=(user, ),
                          misfire_grace_time=60)
        return

    if setu_type == 1:

        DATA_PATH = Path(
            '.') / 'ATRI' / 'data' / 'data_Sqlite' / 'setu' / 'nearR18.db'

        if not DATA_PATH.is_file():
            await setu.finish("数据库...她是空的!!!")

        con = sqlite3.connect(DATA_PATH)
        cur = con.cursor()
        msg = cur.execute('SELECT * FROM nearR18 ORDER BY RANDOM() limit 1;')

        for i in msg:
            pid = i[0]
            title = i[1]
            img = i[7]

            msg0 = "setu info:\n"
            msg0 += f"Title: {title}\n"
            msg0 += f"Pid: {pid}\n"
            msg0 += f"[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]"

            if 1 <= res < 5:
                SP_temp_list.append(user)
                await setu.finish(msg0)

            elif res == 5:
                await bot.send(event, "我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆")

                for sup in config['bot']['superusers']:
                    await bot.send_private_msg(
                        user_id=sup,
                        message=
                        f"主人,从群{group}来的涩图!热乎着!\nTitle: {title}\nPid: {pid}\n[CQ:image,file=file:///{compress_image(await aio_download_pics(img))}]"
                    )

    else:
        params = {"apikey": key_LoliconAPI, "r18": "0", "num": "1"}

        data = {}

        try:
            data = json.loads(
                request_get('https://api.lolicon.app/setu/', params))
        except Exception:
            await setu.finish(errorRepo("请求数据失败,也可能为接口调用次数达上限"))

        msg0 = "setu info:\n"
        msg0 += f'Title: {data["data"][0]["title"]}\n'
        msg0 += f'Pid: {data["data"][0]["pid"]}\n'
        msg0 += f'[CQ:image,file=file:///{compress_image(await aio_download_pics(data["data"][0]["url"]))}]'

        if 1 <= res < 5:
            SP_temp_list.append(user)
            await setu.finish(msg0)

        elif res == 5:
            await bot.send(event, "我找到涩图了!但我发给主人了\nο(=•ω<=)ρ⌒☆")

            for sup in config['bot']['superusers']:
                await bot.send_private_msg(
                    user_id=sup,
                    message=
                    f'主人,从群{group}来的涩图!热乎着!\nTitle: {data["data"][0]["title"]}\nPid: {data["data"][0]["pid"]}\n[CQ:image,file=file:///{compress_image(await aio_download_pics(data["data"][0]["url"]))}]'
                )