Exemple #1
0
async def hitokoto(session: CommandSession):
    rep = response.request_api(url)
    
    if not rep:
        session.finish('获取失败')
    
    dc = json.loads(response.request_api(url))

    await session.send(
        HITOKOTO_REPLY.format(
            hitokoto = dc["hitokoto"],
            author = dc["author"]
        )
    )
Exemple #2
0
async def Fuck_CloudMusic(context):
    user = str(context["user_id"])
    group = context["group_id"]
    if checkNoob(user, group):
        if 0 <= now_time() < 5.5:
            pass
        else:
            msg = str(context["message"])
            pattern = re.compile(r"song\S+\/|id=\S+\&")
            music_id = re.findall(pattern, msg)
            if 'music.163.com' in msg:
                if music_id:
                    music_id = str(music_id[0])
                    music_id = re.findall(r"-?[1-9]\d*", music_id)
                    URL = f'https://api.imjad.cn/cloudmusic/?type=song&id={music_id[0]}&br=320000'
                    print(URL)

                    try:
                        res = request_api(URL)
                        mg = json.loads(res)

                        msg = REPORT_FORMAT.format(
                            status = mg["code"],
                            id = mg["data"][0]["id"],
                            br = mg["data"][0]["br"],
                            url = mg["data"][0]["url"],
                            md5 = mg["data"][0]["md5"],
                            )
                        await bot.send_msg(
                            group_id = group,
                            message = msg
                            ) # type: ignore
                    except:
                        pass
Exemple #3
0
async def _(session: CommandSession):
    user = session.event.user_id
    group = session.event.group_id
    if checkNoob(user, group):
        if 0 <= now_time() < 5.5:
            await session.send(
                choice(
                    [
                        'zzzz......',
                        'zzzzzzzz......',
                        'zzz...好涩哦..zzz....',
                        '别...不要..zzz..那..zzz..',
                        '嘻嘻..zzz..呐~..zzzz..'
                    ]
                )
            )
        else:
            if checkSwitch(__plugin_name__, group):
                await session.send('ATRI正在获取P站每日排行榜前五作品...')

                start =time.perf_counter()

                try:
                    dc = json.loads(request_api(URL_3))
                except:
                    session.finish(errorBack('请求数据失败'))

                d = {}

                try:
                    for i in range(0,5):
                        pid = dc["response"][0]["works"][i]["work"]["id"]
                        pidURL = f'https://pixiv.cat/{pid}.jpg'
                        d[i] = [f'{pid}',f'{pidURL}']
                except:
                    session.finish('处理数据失败')

                msg0 = (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 = (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('该功能已关闭...')
Exemple #4
0
async def _(session: CommandSession):
    user = session.event.user_id
    group = session.event.group_id
    if checkNoob(user, group):
        if 0 <= now_time() < 5.5:
            await session.send(
                choice(
                    [
                        'zzzz......',
                        'zzzzzzzz......',
                        'zzz...好涩哦..zzz....',
                        '别...不要..zzz..那..zzz..',
                        '嘻嘻..zzz..呐~..zzzz..'
                    ]
                )
            )
        else:
            if checkSwitch(__plugin_name1__, group):
                pid = session.current_arg.strip()

                if not pid:
                    pid = session.get('message', prompt = '请告诉ATRI需要查询的Pid码')
                
                start =time.perf_counter()
                await session.send('开始P站搜图')

                URL = URL_1 + pid

                try:
                    dc = json.loads(request_api(URL))
                except:
                    session.finish(errorBack('请求数据失败'))

                img = f'https://pixiv.cat/{pid}.jpg'
                

                end = time.perf_counter()

                try:
                    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)
                        )
                    )
                except:
                    session.finish(errorBack('处理数据失败'))
            
            else:
                await session.send('该功能已关闭...')
Exemple #5
0
async def Fuck_bili_rich(context):
    user = str(context["user_id"])
    group = context["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 user in data1.keys():
            pass
        else:
            if 0 <= now_time() < 5.5:
                pass
            else:
                msg = str(context["message"])
                pattern = re.compile(r"BV\S+\?")
                bv = re.findall(pattern, msg)
                if bv:
                    bv = bv[0]
                    bv = bv.replace('?', '')

                    aid = str(dec(bv))
                    ad = 'av' + aid
                    URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}'

                    try:
                        res = response.request_api(URL)
                        mg = json.loads(res)
                        msg = BILI_REPORT_FORMAT.format(
                            title = mg["data"]["title"],

                            view = mg["data"]["stat"]["view"],
                            coin = mg["data"]["stat"]["coin"],
                            share = mg["data"]["stat"]["share"],
                            like = mg["data"]["stat"]["like"],

                            bid = mg["data"]["bvid"],
                            bid_link = mg["data"]["short_link"],

                            aid = ad,
                            aid_link = f'https://b23.tv/{ad}'
                            )

                        await bot.send_msg( # type: ignore
                            group_id = group,
                            message = msg
                            )
                    except:
                        pass
Exemple #6
0
async def _(session: CommandSession):
    user = session.event.user_id
    group = session.event.group_id
    if checkNoob(user, group):
        if 0 <= now_time() < 5.5:
            await session.send(
                choice([
                    'zzzz......', 'zzzzzzzz......', 'zzz...好涩哦..zzz....',
                    '别...不要..zzz..那..zzz..', '嘻嘻..zzz..呐~..zzzz..'
                ]))
        else:
            if checkSwitch(__plugin_name2__):
                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('该功能已关闭...')
Exemple #7
0
async def hitokoto(session: CommandSession):
    user = session.event.user_id
    group = session.event.group_id
    if checkNoob(user, group):
        if 0 <= now_time() < 5.5:
            await session.send(
                choice([
                    'zzzz......', 'zzzzzzzz......', 'zzz...好涩哦..zzz....',
                    '别...不要..zzz..那..zzz..', '嘻嘻..zzz..呐~..zzzz..'
                ]))
        else:
            rep = response.request_api(url)

            if not rep:
                session.finish('获取失败')

            dc = json.loads(response.request_api(url))

            await session.send(dc["hitokoto"])
Exemple #8
0
async def _(session: CommandSession):
    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(user) in data.keys():
            pass
        else:
            with open('ATRI/plugins/switch/switch.json', 'r') as f:
                data = json.load(f)

            if data["pixiv_seach_img"] == 0:
                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('该功能已被禁用...')
Exemple #9
0
async def hitokoto(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:
                rep = response.request_api(url)
                
                if not rep:
                    session.finish('获取失败')
                
                dc = json.loads(response.request_api(url))

                await session.send(dc["hitokoto"])
Exemple #10
0
async def _(session: CommandSession):
    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(user) in data.keys():
            pass
        else:
            with open('ATRI/plugins/switch/switch.json', 'r') as f:
                data = json.load(f)

            if data["pixiv_daily_rank"] == 0:

                await session.send('ATRI正在获取P站每日排行榜前五作品...')

                start = time.perf_counter()
                dc = json.loads(response.request_api(URL_3))

                d = {}

                for i in range(0, 5):
                    pid = dc["response"][0]["works"][i]["work"]["id"]
                    pidURL = f'https://pixiv.cat/{pid}.jpg'
                    d[i] = [f'{pid}', f'{pidURL}']

                msg0 = (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 = (
                        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('该功能已被禁用...')
Exemple #11
0
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:
                pass
            else:
                if randint(1, 2) == 1:
                    res = randint(1, 3)
                    if res == 1:
                        img = choice([
                            'WQ.jpg', 'WQ.png', 'WQ1.jpg', 'WQ2.jpg', 'FN.jpg'
                        ])
                        img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
                        img = os.path.abspath(img)
                        await session.send(f'[CQ:image,file=file:///{img}]')

                    elif res == 2:
                        res = randint(1, 3)
                        if res == 1:
                            await session.send('对嘴臭人以火箭组合必杀拳,来让他好好喝一壶!哼!')

                        elif res == 2:
                            await session.send(
                                '鱼雷组合拳——————————————————啊————!!!')

                        elif res == 3:
                            await session.send(
                                '火箭拳——————————————————————————!!!')

                    elif res == 3:
                        await session.send(response.request_api(KC_URL))
Exemple #12
0
async def _(session: CommandSession):
    global noobList1
    user = session.event.user_id
    group = session.event.group_id
    if checkNoob(user, group):
        if 0 <= now_time() < 5.5:
            pass
        else:
            msg = str(session.event.message)
            try:
                with open(
                        Path('.') / 'ATRI' / 'plugins' / 'noobList' /
                        'noobList.json', 'r') as f:
                    bL = json.load(f)
            except:
                bL = {}
            pattern = r"[nNηиɴИ][tT][rR]|[牛🐂🐮]头人"
            if re.findall(pattern, msg):
                noobList1.append(user)
                if countX(noobList1, user) == 5:
                    if user == master:
                        await session.send(
                            '是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......')
                        noobList1 = list(set(noobList1))
                        pass

                    else:
                        await session.send(
                            f'[CQ:at,qq={user}]哼!接下来30分钟别想让我理你!\n(好感度-2)')
                        DelFavoIMP(user, 2, False)
                        bL[f"{user}"] = f"{user}"
                        file = Path(
                            '.'
                        ) / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json'
                        f = open(file, 'w')
                        f.write(json.dumps(bL))
                        f.close()
                        noobList1 = list(set(noobList1))
                        print(noobList1)
                        delta = timedelta(minutes=30)
                        trigger = DateTrigger(run_date=datetime.now() + delta)

                        scheduler.add_job(  #type: ignore
                            func=rmQQfromNoobLIST,
                            trigger=trigger,
                            args=(session.event.user_id, ),
                            misfire_grace_time=60,
                        )

                else:
                    await session.send('你妈的,牛头人,' + request_api(KC_URL))
Exemple #13
0
async def Fuck_CloudMusic(context):
    user = str(context["user_id"])
    group = context["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 user in data1.keys():
            pass
        else:
            if 0 <= now_time() < 5.5:
                pass
            else:
                msg = str(context["message"])
                pattern = re.compile(r"song\S+\/|id=\S+\&")
                music_id = re.findall(pattern, msg)
                if 'music.163.com' in msg:
                    if music_id:
                        music_id = str(music_id[0])
                        music_id = re.findall(r"-?[1-9]\d*", music_id)
                        URL = f'https://api.imjad.cn/cloudmusic/?type=song&id={music_id[0]}&br=320000'
                        print(URL)

                        try:
                            res = response.request_api(URL)
                            mg = json.loads(res)

                            msg = REPORT_FORMAT.format(
                                status = mg["code"],
                                id = mg["data"][0]["id"],
                                br = mg["data"][0]["br"],
                                url = mg["data"][0]["url"],
                                md5 = mg["data"][0]["md5"],
                                )
                            await bot.send_msg(
                                group_id = group,
                                message = msg
                                ) # type: ignore
                        except:
                            pass
Exemple #14
0
async def hitokoto(session: CommandSession):
    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(user) in data.keys():
            pass
        else:
            rep = response.request_api(url)

            if not rep:
                session.finish('获取失败')

            dc = json.loads(response.request_api(url))

            await session.send(dc["hitokoto"])
Exemple #15
0
async def _(session: CommandSession):
    global noobList
    user = session.event.user_id
    with open('ATRI/plugins/noobList/noobList.json', 'r') as f:
        data = json.load(f)

    if str(user) in data.keys():
        pass
    else:
        if 0 <= now_time() < 5.5:
            pass
        else:
            msg = str(session.event.message)
            bL = {}
            pattern = r"[nNηиɴИ][tT][rR]|[牛🐂]头人"
            if re.findall(pattern, msg):
                await session.send('你妈的,牛头人,' + response.request_api(KC_URL))
                noobList.append(user)
                print(noobList)
                print(countX(noobList, user))
                if countX(noobList, user) == 5:
                    if user == master:
                        await session.send('是主人的话...那算了...呜呜\n即使到达了ATRI的最低忍耐限度......')
                        noobList = list(set(noobList))
                        pass

                    else:
                        await session.send(f'[CQ:at,qq={user}]哼!接下来10分钟别想让我理你!')
                        bL[f"{user}"] = f"{user}"
                        file = Path('.') / 'ATRI' / 'plugins' / 'noobList' / 'noobList.json'
                        f = open(file, 'w')
                        f.write(json.dumps(bL))
                        f.close()
                        noobList = list(set(noobList))
                        print(noobList)
                        delta = timedelta(minutes = 10)
                        trigger = DateTrigger(
                            run_date = datetime.now() + delta
                        )

                        scheduler.add_job( #type: ignore
                            func = rmQQfromNoobLIST,
                            trigger = trigger,
                            args = (user),
                            misfire_grace_time = 60,
                        )

                else:
                    pass
Exemple #16
0
async def _(session: CommandSession):
    with open('ATRI/plugins/switch/switch.json', 'r') as f:
        data = json.load(f)

    if data["pixiv_seach_author"] == 0:
        user = session.event.user_id
        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('该功能已被禁用...')
Exemple #17
0
async def Fuck_bili_rich(context):
    user = str(context["user_id"])
    group = context["group_id"]
    if checkNoob(user, group):
        if 0 <= now_time() < 5.5:
            pass
        else:
            msg = str(context["message"])
            pattern = re.compile(r"BV\S+\?")
            bv = re.findall(pattern, msg)
            if bv:
                bv = bv[0]
                bv = bv.replace('?', '')
                print(bv)

                aid = str(dec(bv))
                ad = 'av' + aid
                URL = f'https://api.imjad.cn/bilibili/v2/?aid={aid}'

                try:
                    res = request_api(URL)
                    mg = json.loads(res)
                    msg = BILI_REPORT_FORMAT.format(
                        title = mg["data"]["title"],

                        view = mg["data"]["stat"]["view"],
                        coin = mg["data"]["stat"]["coin"],
                        share = mg["data"]["stat"]["share"],
                        like = mg["data"]["stat"]["like"],

                        bid = mg["data"]["bvid"],
                        bid_link = mg["data"]["short_link"],

                        aid = ad,
                        aid_link = f'https://b23.tv/{ad}'
                        )

                    await bot.send_msg( # type: ignore
                        group_id = group,
                        message = msg
                        )
                except:
                    pass
Exemple #18
0
async def _(session: CommandSession):
    user = session.event.user_id
    group = session.event.group_id
    if checkNoob(user, group):
        if 0 <= now_time() < 5.5:
            pass
        else:
            if randint(1, 2) == 1:
                DelFavoIMP(u, 5, True)
                res = randint(1, 3)
                if res == 1:
                    img = choice(
                        ['WQ.jpg', 'WQ.png', 'WQ1.jpg', 'WQ2.jpg', 'FN.jpg'])
                    img = Path('.') / 'ATRI' / 'data' / 'emoji' / f'{img}'
                    img = os.path.abspath(img)
                    await session.send(f'[CQ:image,file=file:///{img}]')

                elif res == 2:
                    res = randint(1, 3)
                    if res == 1:
                        await session.send('对嘴臭人以火箭组合必杀拳,来让他好好喝一壶!哼!')
                        voice = os.path.abspath(
                            Path('.') / 'ATRI' / 'data' / 'voice' /
                            'ATR_b402_027.amr')
                        await session.send(f'[CQ:record,file=file:///{voice}]')

                    elif res == 2:
                        await session.send('鱼雷组合拳——————————————————啊————!!!')
                        voice = os.path.abspath(
                            Path('.') / 'ATRI' / 'data' / 'voice' /
                            'CombinationTorpedoFist.amr')
                        await session.send(f'[CQ:record,file=file:///{voice}]')

                    elif res == 3:
                        await session.send('火箭拳——————————————————————————!!!')
                        voice = os.path.abspath(
                            Path('.') / 'ATRI' / 'data' / 'voice' /
                            'RocketPunch.amr')
                        await session.send(f'[CQ:record,file=file:///{voice}]')

                elif res == 3:
                    await session.send(request_api(KC_URL))
Exemple #19
0
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('该功能已被禁用...')
Exemple #20
0
async def _(session: CommandSession):
    if session.event.user_id in master:
        start = time.perf_counter()
        msg = session.event.raw_message.split(' ', 2)
        print(msg)
        i_tpye = msg[1]
        pid = msg[2]

        URL = url + pid

        dc = json.loads(response.request_api(URL))
        if not dc:
            session.finish('ATRI在尝试解析数据时出问题...等会再试试吧...')
        title = dc["response"][0]["title"]
        tags = dc["response"][0]["tags"]
        account = dc["response"][0]["user"]["account"]
        name = dc["response"][0]["user"]["name"]
        u_id = dc["response"][0]["user"]["id"]
        user_link = f'https://www.pixiv.net/users/' + f'{u_id}'
        img = f'https://pixiv.cat/{pid}.jpg'

        if i_tpye == '正常':
            if os.path.exists('ATRI/sqlite/setu/normal.db'):
                print('数据文件存在!')
            else:
                await session.send('数据库不存在,将在3秒后开始构建...')
                time.sleep(3)
                await session.send('开始构建数据库!')
                con = sqlite3.connect(
                    Path('.') / 'ATRI' / 'sqlite' / 'setu' / 'normal.db')
                cur = con.cursor()
                cur.execute(
                    'CREATE TABLE normal(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()
                con.close()
                await session.send('完成')

            con = sqlite3.connect(
                Path('.') / 'ATRI' / 'sqlite' / 'setu' / 'normal.db')
            cur = con.cursor()
            cur.execute(
                'INSERT INTO normal VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")'
                % (pid, title, tags, account, name, u_id, user_link, img))
            con.commit()
            con.close()

        elif i_tpye == '擦边球':
            if os.path.exists('ATRI/sqlite/setu/nearR18.db'):
                print('数据文件存在!')
            else:
                await session.send('数据库不存在,将在3秒后开始构建...')
                time.sleep(3)
                await session.send('开始构建数据库!')
                con = sqlite3.connect(
                    Path('.') / 'ATRI' / 'sqlite' / 'setu' / 'nearR18.db')
                cur = con.cursor()
                cur.execute(
                    'CREATE TABLE nearR18(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()
                con.close()
                await session.send('完成')

            con = sqlite3.connect(
                Path('.') / 'ATRI' / 'sqlite' / 'setu' / 'nearR18.db')
            cur = con.cursor()
            cur.execute(
                'INSERT INTO nearR18 VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")'
                % (pid, title, tags, account, name, u_id, user_link, img))
            con.commit()
            con.close()

        elif i_tpye == 'r18':
            if os.path.exists('ATRI/sqlite/cloudmusic/cloudmusic.db'):
                print('数据文件存在!')
            else:
                await session.send('数据库不存在,将在3秒后开始构建...')
                time.sleep(3)
                await session.send('开始构建数据库!')
                con = sqlite3.connect(
                    Path('.') / 'ATRI' / 'sqlite' / 'setu' / 'r18.db')
                cur = con.cursor()
                cur.execute(
                    'CREATE TABLE r18(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()
                con.close()
                await session.send('完成')

            con = sqlite3.connect(
                Path('.') / 'ATRI' / 'sqlite' / 'setu' / 'r18.db')
            cur = con.cursor()
            cur.execute(
                'INSERT INTO r18 VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s", "%s")'
                % (pid, title, tags, account, name, u_id, user_link, img))
            con.commit()
            con.close()

        end = time.perf_counter()

        await session.send(f'数据上传完成!\n耗时: {round(end - start, 3)}s')