예제 #1
0
async def eventChecker60():
    if Universe.get_value("dailyMession")[0] is 1:
        sender = Universe.get_value("dailyMession")[1]
        if type(sender) is Group:
            await app.sendGroupMessage(
                sender,
                MessageChain.create([Plain(f"今日色图更新成功,发送 色图 或者 好图 进行查看")]))
        elif type(sender) is Friend:
            await app.sendFriendMessage(
                sender,
                MessageChain.create([Plain(f"今日色图更新成功,发送 色图 或者 好图 进行查看")]))
        elif type(sender) is list:  # 只会是自动更新
            for ls in sender:
                await app.sendGroupMessage(
                    ls,
                    MessageChain.create([Plain(f"今日色图更新成功,发送 色图 或者 好图 进行查看")]))
                await app.sendGroupMessage(
                    ls,
                    MessageChain.create([
                        Plain("色图一览"),
                        Image.fromLocalFile(Universe.get_value("setuScan"))
                    ]))
                await app.sendGroupMessage(
                    ls,
                    MessageChain.create([
                        Plain("好图一览"),
                        Image.fromLocalFile(Universe.get_value("haotuScan"))
                    ]))

        Universe.set_value("dailyMession", [0, None])
    elif Universe.get_value("dailyMession")[0] is -1:
        sender = Universe.get_value("dailyMession")[1]
        if type(sender) is Group:
            await app.sendGroupMessage(
                sender, MessageChain.create([Plain(f"今日色图更新失败")]))
        elif type(sender) is Friend:
            await app.sendFriendMessage(
                sender, MessageChain.create([Plain(f"今日色图更新失败")]))
        await app.sendFriendMessage(
            775086089, MessageChain.create([Plain(f"今日色图更新失败,请检查网络设置")]))
        Universe.set_value("dailyMession", [0, None])

    global isFresh
    if not isFresh:
        if extraEvent.getDate("%H") == "08":
            isFresh = True
            await app.sendFriendMessage(775086089,
                                        MessageChain.create([Plain(f"开始更新")]))
            for ls in await app.groupList():
                if ls.id in schedulepermission:
                    await app.sendGroupMessage(
                        ls, MessageChain.create([Plain("开始更新每日色图......")]))
            await app.sendFriendMessage(
                775086089, MessageChain.create([Plain(f"群消息发送成功")]))
            threadDaily = threading.Thread(target=extraEvent.DayilyMission,
                                           args=(schedulepermission, 0))
            threadDaily.start()
예제 #2
0
async def command_ygg_client_refresh(app: GraiaMiraiApplication, group: Group):
    await app.sendGroupMessage(
        group,
        MessageChain.create([
            Image.fromLocalFile('./images/ygg-client-refresh.png'),
            Plain(tF.client_refresh)
        ]))
예제 #3
0
async def sleep_time(app: GraiaMiraiApplication):
    group_list = await app.groupList()
    for group in group_list:
        await app.sendGroupMessage(
            group.id,
            MessageChain.create([
                Plain("到点了到点了,好孩子该睡觉了!"),
                Image.fromLocalFile(_go_to_sleep_img_path)
            ]))
예제 #4
0
async def command_ot(app: GraiaMiraiApplication, group: Group,
                     _gm: GroupMessage):
    M = MessagePro(_gm)
    atList: List[Optional[At]] = [At(t.target)
                                  for t in M.at] if M.at != [] else []
    await app.sendGroupMessage(
        group,
        MessageChain.create([
            Image.fromLocalFile('./images/off-topic.png'),
            *atList,
            # 仅在 LittleSkin 主群中启用此文本消息
            *([Plain(tF.ot)] if group.id == qq.littleskin_main else [])
        ]))
예제 #5
0
파일: main.py 프로젝트: xfl03/commspt-bot
async def command_ot(app: GraiaMiraiApplication, group: Group,
                     _gm: GroupMessage):
    CP = CommandParser(_gm, settings.commandSymbol)
    atList: List[Optional[At]] = [At(t.target)
                                  for t in CP.at] if CP.at != [] else []
    await app.sendGroupMessage(
        group,
        MessageChain.create([
            *atList,
            Image.fromLocalFile('./images/off-topic.png'),
            *([Plain(tF.ot)] if group.id == settings.specialqq.littleskin_main
              else [])  # 仅在 LittleSkin 主群中启用此文本消息
        ]))
예제 #6
0
app = GraiaMiraiApplication(
    broadcast=bcc, connect_info=settings.Connection, enable_chat_log=False)


def SimpleReply(command: str, reply_content: List[GraiaMessageElementType]):
    async def srr_wrapper(app: GraiaMiraiApplication, group: Group):
        await app.sendGroupMessage(group, MessageChain.create(reply_content))
    bcc.receiver(GroupMessage, dispatchers=[Kanata(
        [CommandMatch(command, False)])])(srr_wrapper)


SimpleReply('ping', [Plain('Pong!')])

SimpleReply('help', [Plain(tF.help)])
SimpleReply('ot', [
    Image.fromLocalFile('./images/off-topic.png'),
    Plain(tF.ot)
])
SimpleReply('manual', [
    Image.fromLocalFile('./images/rtfm.png'),
    Plain(tF.manual)
])
SimpleReply('ygg.server.jvm', [Plain(tF.ygg_server_jvm)])
SimpleReply('csl.gui', [Plain(tF.csl_gui)])
SimpleReply('domain', [
    Image.fromLocalFile('./images/r-search.jpg'),
    Plain(tF.domain)
])
SimpleReply('mail', [Plain(tF.mail)])
SimpleReply('csl.log', [Plain(tF.csl_log)])
SimpleReply('ygg.nsis', [Plain(tF.ygg_nsis)])
예제 #7
0
async def command_faq(app: GraiaMiraiApplication, group: Group):
    await app.sendGroupMessage(
        group,
        MessageChain.create(
            [Image.fromLocalFile('./images/rtfm.png'),
             Plain(tF.faq)]))
예제 #8
0
async def command_ygg_url(app: GraiaMiraiApplication, group: Group):
    await app.sendGroupMessage(
        group,
        MessageChain.create([Image.fromLocalFile('./images/ygg-url.png')]))
예제 #9
0
async def friend_message_listener(app: GraiaMiraiApplication,
                                  message: MessageChain, friend: Friend):
    if friend.id in _MANAGER:
        if message.asDisplay() == "UpdateToday":
            await app.sendFriendMessage(
                friend, message.create([Plain("开始更新今日色图......")]))
            thread = threading.Thread(target=extraEvent.DayilyMission,
                                      args=(friend, 0))
            thread.start()
        elif message.asDisplay() == "Init":
            await app.sendFriendMessage(friend,
                                        message.create([Plain("初始化......")]))
            extraEvent.initNow(app, message, friend, loop)
        elif message.asDisplay() == "图裂了":
            await app.sendFriendMessage(
                friend, message.create([Plain("正在想办法处理......")]))
            extraEvent.fixPics(app, message, friend, loop)
        '''if message.asDisplay() == "今日色图":
            try:
                print(Universe.get_value("setuScan"))
                print(os.path.abspath(Universe.get_value("setuScan")))
                await app.sendFriendMessage(friend,
                                            message.create([Image.fromUnsafePath("Pixiv/2020-09-12/day_r18_scan.jpg")]))
            except:
                extraEvent.initNow(app, message, friend, loop)
                await app.sendFriendMessage(friend,
                                            message.create([Image.fromUnsafePath("Pixiv/2020-09-12/day_r18_scan.jpg")]))
        elif message.asDisplay() == "今日好图":
            try:
                await app.sendFriendMessage(friend,
                                            message.create([Image.fromLocalFile(Universe.get_value("haotuScan"))]))
            except:
                extraEvent.initNow(app, message, friend, loop)
                await app.sendFriendMessage(friend,
                                            message.create([Image.fromLocalFile(Universe.get_value("haotuScan"))]))'''  # 错误待解决
        if re.search("色图$", message.asDisplay()):
            setuInd = Universe.get_value("setuInd")
            imgid = await app.sendFriendMessage(
                friend,
                message.create([
                    Image.fromLocalFile(
                        extraEvent.setuList[setuInd %
                                            len(extraEvent.setuList)])
                ]))
            print(imgid)
            await app.sendFriendMessage(
                friend, message.create([Plain("今日发送的第{}份色图".format(setuInd))]))
            setuInd += 1
            Universe.set_value("setuInd", setuInd)
        elif re.search("好图$", message.asDisplay()):
            haotuInd = Universe.get_value("haotuInd")
            await app.sendFriendMessage(
                friend,
                message.create([
                    Image.fromLocalFile(
                        extraEvent.haotuList[haotuInd %
                                             len(extraEvent.haotuList)])
                ]))
            await app.sendFriendMessage(
                friend,
                message.create([Plain("今日发送的第{}份好图".format(haotuInd))]))
            print(extraEvent.haotuList[haotuInd % len(extraEvent.haotuList)])
            haotuInd += 1
            Universe.set_value("haotuInd", haotuInd)
        if message.has(Image):
            savePicLs = message[Image]
            counter = len(savePicLs)
            await app.sendFriendMessage(
                friend, message.create([Plain("{}张".format(counter))]))
            threadPic = threading.Thread(target=extraEvent.savePic,
                                         args=(savePicLs, 3))
            threadPic.start()
예제 #10
0
async def group_message_handler(app: GraiaMiraiApplication,
                                message: MessageChain, group: Group,
                                member: Member):
    if message.asDisplay().startswith("复读"):
        await app.sendGroupMessage(
            group,
            message.create(
                [At(member.id),
                 Plain(message.exclude(Image).asDisplay())]),
            quote=message.__root__[0].id)

    if re.search(r"色图 \d", message.asDisplay()) and (group.id
                                                     in schedulepermission):
        setuInd = Universe.get_value("setuInd")
        setuId = message.asDisplay().split(" ")[1]
        setuId = eval(setuId) - 1
        await app.sendGroupMessage(
            group,
            message.create([
                Image.fromLocalFile(
                    extraEvent.setuList[setuId % len(extraEvent.setuList)])
            ]))
        await app.sendGroupMessage(
            group, message.create([Plain("今日发送的第{}份色图".format(setuInd))]))
        print(extraEvent.setuList[setuInd % len(extraEvent.setuList)])
        setuInd += 1
        Universe.set_value("setuInd", setuInd)
    elif re.search(r"好图 \d", message.asDisplay()) and (group.id
                                                       in schedulepermission):
        haotuInd = Universe.get_value("haotuInd")
        haotuId = message.asDisplay().split(" ")[1]
        haotuId = eval(haotuId) - 1
        await app.sendGroupMessage(
            group,
            message.create([
                Image.fromLocalFile(
                    extraEvent.haotuList[haotuId % len(extraEvent.haotuList)])
            ]))
        await app.sendGroupMessage(
            group, message.create([Plain("今日发送的第{}份好图".format(haotuInd))]))
        print(extraEvent.haotuList[haotuInd % len(extraEvent.haotuList)])
        haotuInd += 1
        Universe.set_value("haotuInd", haotuInd)

    if message.asDisplay() == "色图一览":
        print(Universe.get_value("setuScan"))
        print(os.path.abspath(Universe.get_value("setuScan")))
        await app.sendGroupMessage(
            group,
            message.create(
                [Image.fromLocalFile(Universe.get_value("setuScan"))]))
    elif message.asDisplay() == "好图一览":
        await app.sendGroupMessage(
            group,
            message.create(
                [Image.fromLocalFile(Universe.get_value("haotuScan"))]))

    if member.permission is MemberPerm.Owner:
        if message.asDisplay().startswith("Update"):
            await app.sendGroupMessage(
                group, message.create([Plain("开始更新今日色图......")]))
            threadDaily = threading.Thread(target=extraEvent.DayilyMission,
                                           args=(group, 0))
            threadDaily.start()
        elif message.asDisplay().startswith("Init"):
            await app.sendGroupMessage(group,
                                       message.create([Plain("初始化......")]))
            extraEvent.initNow(app, message, group, loop)
        elif message.asDisplay() == "图裂了":
            await app.sendFriendMessage(
                group, message.create([Plain("正在想办法处理......")]))
            extraEvent.fixPics(app, message, group, loop)

    if message.has(Image):  #图片保存
        # 日常收集图片
        savePicLs = message[Image]
        counter = len(savePicLs)
        sourceid = message.__root__[0].id
        #await app.sendGroupMessage(group, message.create([Plain("{}张".format(counter))]))
        threadPic = threading.Thread(target=extraEvent.savePic,
                                     args=(savePicLs, counter, app, sourceid,
                                           group, loop))
        threadPic.start()
예제 #11
0
async def sendstick(bot, group, source, msg_par, id=None):
    # 这该死的路径居然是取的main的路径,草了
    if msg_par.asDisplay() == "报时":
        time_24 = time.strftime("%H:%M", time.localtime(time.time()))
        send_ask = ask(int(time.strftime("%H", time.localtime(time.time()))))
        draw_text_img(time_24, send_ask)

        await bot.sendGroupMessage(
            group,
            msg_par.create([
                Image.fromLocalFile('img/time_cache.jpg'),
                Plain(
                    text=
                    f'\n现在是北京时间=>{time.strftime("%H点%M分%S秒", time.localtime(time.time()))}'
                )
            ]),
            quote=source)
    elif msg_par.asDisplay() == '随机涩图':
        # TODO :偶尔会出现index out,等以后学会py了再修复,下 次 一 定
        # 别问,问就是lambda真好
        # 判定次数
        if id not in SendImgCount.keys():
            # 初次直接发送然后添加
            SendImgCount[id] = []
            SendImgCount[id].append(1)
            imgname = stick_name['随机涩图']()
            await bot.sendGroupMessage(
                group.id,
                msg_par.create([
                    Image.fromLocalFile(f'{AcgImgPath}/%s' %
                                        imgname).asFlash()
                ]))
            await bot.sendGroupMessage(
                group.id,
                msg_par.create([
                    Plain('图片链接:https://www.pixiv.net/artworks/%s' %
                          imgname[0:-7])
                ]))

        elif SendImgCount[id][0] < 3 and len(SendImgCount[id]) == 1:
            # 如果次数少于三次
            SendImgCount[id][0] += 1
            imgname = stick_name['随机涩图']()
            await bot.sendGroupMessage(
                group.id,
                msg_par.create([
                    # 发!
                    Image.fromLocalFile(f'{AcgImgPath}/%s' % imgname
                                        ).asFlash()
                ]))

            await bot.sendGroupMessage(
                group.id,
                msg_par.create([
                    Plain('图片链接:https://www.pixiv.net/artworks/%s' %
                          imgname[0:-7])
                ]))

            # 记一次
        elif len(SendImgCount[id]) == 1 and SendImgCount[id][0] >= 3:
            # 如果超过三次就加上时间
            SendImgCount[id].append(time.time())
            await bot.sendGroupMessage(
                group.id,
                msg_par.create([Plain(text='做人不要太贪心哦,每获取三次需要等待一分钟')]))
        else:
            # 在这里提醒冲过头了
            if int(time.time() - SendImgCount[id][1]) < 60:
                await bot.sendGroupMessage(
                    group.id,
                    msg_par.create([
                        Plain(text='才过去%0.1fs呢' %
                              int(abs(SendImgCount[id][1] - time.time())))
                    ]))
            else:
                del SendImgCount[id]
    elif msg_par.asDisplay() == '贴贴':
        i = random.randrange(0, 2)
        if i:
            await bot.sendGroupMessage(
                group, msg_par.create([Image.fromLocalFile('img/yes.jpg')]))
        else:
            await bot.sendGroupMessage(
                group, msg_par.create([Image.fromLocalFile('img/no.jpg')]))
    else:  # msg_par.asDisplay() in stick_name.keys() and msg_par.asDisplay() != '随机涩图':
        await bot.sendGroupMessage(
            group.id,
            msg_par.create([
                Image.fromLocalFile(f'img/%s' %
                                    stick_name[msg_par.asDisplay()])
            ]))