예제 #1
0
async def Lunar(some,*member):
    send_message = MessageChain.create([Plain(huangli.get())])
    if member[0] == ():
        await app.sendFriendMessage(some,send_message)
    else:
        at = MessageChain.create([At(member[0][0].id)])
        await app.sendGroupMessage(some,MessageChain.join(at,send_message))
예제 #2
0
async def hot_weibo(some,rmsg,*member):
    m = rmsg.split(' ')
    if len(m) == 2:
        serial = int(m[1]) - 1
        reso_data = weibo.reso()[1]
        if serial >= len(reso_data):
            send_message = MessageChain.create([Plain("查找数值不正确,数值应为1~{}".format(len(reso_data)))])
        else:
            send_message = MessageChain.create([
                Plain("序号:{}\n"
                      "标题:{}\n"
                      "链接:{}"
                      .format(
                    reso_data[serial]['id'] + 1,
                    reso_data[serial]['name'],
                    reso_data[serial]['url']))])
    elif len(m) == 1:
        send_message = MessageChain.create([Plain('\n{}\n输入 微博热搜 [序号] 来获取访问链接'.format(weibo.reso()[0]))])
    else:
        send_message = MessageChain.create([Plain("你输入的参数有误")])
    if member[0] == ():
        await app.sendFriendMessage(some, send_message)
    else:
        at = MessageChain.create([At(member[0][0].id)])
        await app.sendGroupMessage(some,MessageChain.join(at,send_message))
예제 #3
0
async def netease_cloud_music_hot(some,*member):
    send_message = MessageChain.create([Plain(wangyiyun.reping())])
    if member[0] == ():
        await app.sendFriendMessage(some, send_message)
    else:
        at = MessageChain.create([At(member[0][0].id)])
        await app.sendGroupMessage(some,MessageChain.join(at,send_message))
예제 #4
0
파일: bot.py 프로젝트: PekoBot/PekoBot
async def reminder():
    global Global_group
    while True:
        await asyncio.sleep(3)
        result = Bot.need_at()
        if result is not None:
            await app.sendGroupMessage(Global_group,
                                       MessageChain.join([Plain(result[1])], [At(target=int(m[0])) for m in result[0]]))
예제 #5
0
async def blhx(app, group):
    url = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?visitor_uid=33091201&host_uid=233114659&offset_dynamic_id=0&need_top=1&platform=web"
    Information = requests.get(url, headers=headers).json()
    judge = Information['data']['cards'][1]

    if judge['desc']['type'] == 1:
        needInformation = Information['data']['cards'][1]['card']
        dictInformation = eval(needInformation)
        msg = dictInformation['item']['content']
        message = MessageChain.create(
            [Plain("碧蓝航线b服动态更新\n================\n"),
             Plain(msg)])
        await app.sendGroupMessage(group, message)

    elif judge['desc']['type'] == 2:
        needInformation = Information['data']['cards'][1]['card']
        dictInformation = eval(needInformation)
        try:
            if (dictInformation['item']['pictures_count'] == 1):
                pictures = dictInformation['item']['pictures'][0]['img_src']
                flag = 0
            else:
                pictures = dictInformation['item']['pictures']
                flag = 1
                count = dictInformation['item']['pictures_count']
        except:
            pictures = " "
        msgDict = {
            "information": dictInformation['item']['description'],
            "picture_url": pictures
        }
        if msgDict['picture_url'] != ' ':
            if flag == 0:
                msgDict['picture_url'] = eval(
                    repr(msgDict['picture_url']).replace('\\', ''))
                await app.sendGroupMessage(
                    group,
                    MessageChain.create([
                        Plain("碧蓝航线b服动态更新\n================\n"),
                        Plain(msgDict['information']),
                        Image.fromNetworkAddress(msgDict['picture_url'])
                    ]))
            elif flag == 1:
                message1 = MessageChain.create([
                    Plain("碧蓝航线b服动态更新\n================\n"),
                    Plain(msgDict['information'])
                ])
                for i in range(count):
                    msg = MessageChain.join(
                        [Image.fromNetworkAddress(pictures[i]['img_src'])])
                #Msg = MessageChain.join(message1, msg)
                #await app.sendGroupMessage(group, Msg)
        else:
            await app.sendGroupMessage(
                group,
                MessageChain.create([
                    Plain("碧蓝航线b服动态更新\n================\n"),
                    Plain(msgDict['information'])
                ]))

    elif judge['desc']['type'] == 4:
        needInformation = Information['data']['cards'][1]['card']
        dictInformation = eval(needInformation)
        pictures = " "
        msgDict = {
            "information": dictInformation['item']['content'],
            "picture_url": pictures
        }
        for group in groups:
            if msgDict['picture_url'] != ' ':
                msgDict['picture_url'] = eval(
                    repr(msgDict['picture_url']).replace('\\', ''))
                await app.sendGroupMessage(
                    group,
                    MessageChain.create([
                        Plain("碧蓝航线b服动态更新\n================\n"),
                        Plain(msgDict['information']),
                        Image.fromNetworkAddress(msgDict['picture_url'])
                    ]))
            else:
                await app.sendGroupMessage(
                    group,
                    MessageChain.create([
                        Plain("碧蓝航线b服动态更新\n================\n"),
                        Plain(msgDict['information'])
                    ]))
예제 #6
0
async def blhxpush(app, preTimestamp):
    await asyncio.sleep(10)
    url = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?visitor_uid=33091201&host_uid=233114659&offset_dynamic_id=0&need_top=1&platform=web"
    Information = requests.get(url, headers=headers).json()
    while (True):
        t = time.time()
        t = int(t)
        url = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history?visitor_uid=33091201&host_uid=233114659&offset_dynamic_id=0&need_top=1&platform=web"
        Information = requests.get(url, headers=headers).json()
        try:
            timestamp = Information['data']['cards'][1]['desc']['timestamp']
        except:
            timestamp = 0
        print("当前时间戳为:")
        print(t)
        print("上一个动态的时间戳为:")
        print(preTimestamp)
        print("当前动态的时间戳为:")
        print(timestamp)
        if preTimestamp != timestamp:
            preTimestamp = timestamp
            judge = Information['data']['cards'][1]

            if judge['desc']['type'] == 1:
                needInformation = Information['data']['cards'][1]['card']
                dictInformation = eval(needInformation)
                msg = dictInformation['item']['content']
                for group in groups:
                    message = MessageChain.create(
                        [Plain("碧蓝航线b服动态更新\n================\n"),
                         Plain(msg)])
                    await app.sendGroupMessage(group, message)

            elif judge['desc']['type'] == 2:
                needInformation = Information['data']['cards'][1]['card']
                dictInformation = eval(needInformation)
                try:
                    if (dictInformation['item']['pictures_count'] == 1):
                        pictures = dictInformation['item']['pictures'][0][
                            'img_src']
                        flag = 0
                    else:
                        pictures = dictInformation['item']['pictures']
                        flag = 1
                        count = dictInformation['item']['pictures_count']
                except:
                    pictures = " "
                msgDict = {
                    "information": dictInformation['item']['description'],
                    "picture_url": pictures
                }
                for group in groups:
                    if msgDict['picture_url'] != ' ':
                        if flag == 0:
                            msgDict['picture_url'] = eval(
                                repr(msgDict['picture_url']).replace('\\', ''))
                            await app.sendGroupMessage(
                                group,
                                MessageChain.create([
                                    Plain("碧蓝航线b服动态更新\n================\n"),
                                    Plain(msgDict['information']),
                                    Image.fromNetworkAddress(
                                        msgDict['picture_url'])
                                ]))
                        elif flag == 1:
                            message1 = MessageChain.create([
                                Plain("碧蓝航线b服动态更新\n================\n"),
                                Plain(msgDict['information'])
                            ])
                            for i in count:
                                pictures[i]['img_src'] = eval(
                                    repr(pictures[i]['img_src']).replace(
                                        '\\', ''))
                                msg = MessageChain.join([
                                    Image.fromNetworkAddress(
                                        pictures[i]['img_src'])
                                ])
                            Msg = MessageChain.join(message1, msg)
                            await app.sendGroupMessage(group, Msg)
                    else:
                        await app.sendGroupMessage(
                            group,
                            MessageChain.create([
                                Plain("碧蓝航线b服动态更新\n================\n"),
                                Plain(msgDict['information'])
                            ]))

            elif judge['desc']['type'] == 4:
                needInformation = Information['data']['cards'][1]['card']
                dictInformation = eval(needInformation)
                pictures = " "
                msgDict = {
                    "information": dictInformation['item']['content'],
                    "picture_url": pictures
                }
                for group in groups:
                    if msgDict['picture_url'] != ' ':
                        msgDict['picture_url'] = eval(
                            repr(msgDict['picture_url']).replace('\\', ''))
                        await app.sendGroupMessage(
                            group,
                            MessageChain.create([
                                Plain("碧蓝航线b服动态更新\n================\n"),
                                Plain(msgDict['information']),
                                Image.fromNetworkAddress(
                                    msgDict['picture_url'])
                            ]))
                    else:
                        await app.sendGroupMessage(
                            group,
                            MessageChain.create([
                                Plain("碧蓝航线b服动态更新\n================\n"),
                                Plain(msgDict['information'])
                            ]))

            await asyncio.sleep(60)

        else:
            await asyncio.sleep(60)
            continue