示例#1
0
def initNow(app: GraiaMiraiApplication, message: MessageChain, friend, loop):
    global setuList, haotuList
    getPicList()
    if type(friend) is Friend:
        asyncio.run_coroutine_threadsafe(app.sendFriendMessage(friend, message.create(
            [Plain("今日色图:{}份\n今日好图:{}份".format(len(setuList), len(haotuList)))])), loop)
    elif type(friend) is Group:
        asyncio.run_coroutine_threadsafe(app.sendGroupMessage(friend, message.create(
            [Plain("今日色图:{}份\n今日好图:{}份".format(len(setuList), len(haotuList)))])), loop)
示例#2
0
def fixPics(app: GraiaMiraiApplication, message: MessageChain, friend, loop):
    """
    修复图片感叹号

    :param app:
    :param message:
    :param friend: 这里表示friend或者group
    :param loop:
    :return:
    """
    dirs = pivixDownloader._ROOTDIC + "/" + getDate()
    for ls in pivixDownloader._MODE:
        dir = dirs + "/" + ls
        pivixDownloader.PicTransfer(dir)
    if type(friend) is Friend:
        asyncio.run_coroutine_threadsafe(app.sendFriendMessage(friend, message.create(
            [Plain("修好啦!没修好的就没救了".format(len(setuList), len(haotuList)))])), loop)
    elif type(friend) is Group:
        asyncio.run_coroutine_threadsafe(app.sendGroupMessage(friend, message.create(
            [Plain("修好啦!没修好的就没救了".format(len(setuList), len(haotuList)))])), loop)
示例#3
0
async def RequsetBotMaster(
    app: GraiaMiraiApplication,
    target: Union[Friend, int],
    event: BotInvitedJoinGroupRequestEvent,
):
    botMessage = None
    try:
        await asyncio.sleep(randint(1, 10))
        botMessage = app.sendFriendMessage(
            target,
            MessageChain.create([
                Plain("有人邀请加群。\n"),
                Plain(f"请求事件ID: {event.requestId}\n"),
                Plain(f"邀请人为: {event.supplicant}\n"),
                Plain(f"邀请人称呼为: {event.nickname}\n"),
                Plain(f"群号为: {event.groupId}\n"),
                Plain(f"群名称为: {event.groupName}\n"),
                Plain(f"附加消息: {event.message}"),
            ]),
        )

        @Waiter.create_using_function([FriendMessage])
        async def wait(
                wait_event: FriendMessage,
                regexResult=regexPlain(r"^#(同意|拒绝)(?:\s*(?<=\s)(.*)|)$"),
        ):
            quote = wait_event.messageChain.get(Quote)
            if (not quote or wait_event.sender.id != target
                    or quote[0].id == botMessage.messageId):
                return None
            return regexResult

        raise ReturnValue([
            await Interrupt.interruptcontrol.wait(wait), target,
            botMessage.messageId
        ])
    except asyncio.CancelledError:
        await asyncio.sleep(randint(1, 10))
        await app.sendFriendMessage(target,
                                    MessageChain.create([Plain("已由其他人处理")]),
                                    quote=botMessage.messageId)