async def handle(app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if message.asDisplay().startswith("/抽象 "):
         return await AbstractMessageTransformHandler.transform_abstract_message(
             message.asDisplay()[4:])
     else:
         return None
Exemplo n.º 2
0
async def friend_message_listener(message: MessageChain,
                                  app: GraiaMiraiApplication, friend: Friend):
    if message.asDisplay().startswith("/天气" or "/weather"):
        msg = message.asDisplay()
        msg = re.split(r' +', msg)
        if (msg.__len__() != 2):
            await app.sendFriendMessage(
                friend,
                MessageChain.create([
                    Plain("不要捣乱哦,要遵守输入格式 : '/天气 城市', 请您重新输入~"),
                ]))
        else:
            city = msg[1]
            city_code = city_code_dict[city]
            wea_list = await getWeather.get_weather(city, city_code)
            wea_dict = wea_list[1]
            string = ""
            for date in wea_dict:
                string += date + "  ".join(wea_dict[date]) + "\n"
            await app.sendFriendMessage(
                friend,
                MessageChain.create([
                    Plain("[" + city + "]  近七日天气情况如下:  \n"),
                    Plain(string),
                    Plain("From: " + wea_list[0])
                ]))
Exemplo n.º 3
0
    async def waiter(event: GroupMessage, waiter_group: Group,
                     waiter_member: Member, waiter_message: MessageChain):
        if waiter_group.id == group.id and waiter_member.id == member.id:
            if is_int(waiter_message.asDisplay()):
                location = int(waiter_message.asDisplay()) - 1
                print(location)
                if location >= data_json['result'][
                        'songCount'] or location < 0 or location >= 10:
                    await app.sendGroupMessage(
                        group,
                        MessageChain.create([Plain('没有该歌曲'),
                                             Face(faceId=107)]))
                    return event
                msg = MessageChain.create([
                    Plain("https://y.music.163.com/m/song/" +
                          str(data_json['result']['songs'][location]['id']) +
                          "/?userid=335141010&app_version=8.1.80")
                ])
                print(msg)
                await app.sendGroupMessage(group, msg)

            else:
                await app.sendGroupMessage(
                    group,
                    MessageChain.create([Plain('没有该歌曲'),
                                         Face(faceId=107)]))
            return event
Exemplo n.º 4
0
async def voice(app: GraiaMiraiApplication, group: Group,
                message: MessageChain, member: Member):
    message_raw = message.asDisplay()
    if message_raw[:2] == "语音" and len(message_raw) > 4:
        sp_m = message_raw.split(" ")

        if not sp_m[1] in data.keys():
            await app.sendGroupMessage(
                group, MessageChain.create([At(member.id),
                                            Plain(" 发音人选择错误!")]))
            return

        if len(message.asDisplay()) > 200:
            await app.sendGroupMessage(
                group, MessageChain.create([At(member.id),
                                            Plain(" 字数过多!")]))
            return

        if len(sp_m) < 3:
            await app.sendGroupMessage(
                group,
                MessageChain.create(
                    [At(member.id),
                     Plain(" 请按照格式发送!格式如下:\n语音 发音人 文本")]),
            )
            return
        await app.sendGroupMessage(group, MessageChain.create([Plain("请稍后")]))
        text = "".join(sp_m[2:])
        # text为文本,sp_m[1]为发音人的名字
        informant = data[sp_m[1]]
        voice_raw = await azure.get_speech(text, informant)
        # 转码
        silk: bytes = await silkcoder.encode(voice_raw)
        voice_m = await app.uploadVoice(silk)
        await app.sendGroupMessage(group, MessageChain.create([voice_m]))
Exemplo n.º 5
0
 async def waiter(event: GroupMessage, waiter_group: Group, waiter_member: Member, waiter_message: MessageChain):
     if waiter_group.id == group.id and waiter_member.id == member.id:
         if is_int(waiter_message.asDisplay()):
             id = int(waiter_message.asDisplay()) - 1
             if id >= len(lit) or id < 0:
                 await app.sendGroupMessage(group, MessageChain.create([Plain('查询被取消了切噜噜——')]))
                 return event
             text = lit[id].split(', ')
             if len(text) == 2:
                 text.append('')
             if msg.startswith("天气") or msg.startswith("今日天气") or msg.startswith("1日天气"):
                 await report(app, group, text)
             elif msg.startswith("昨日天气"):
                 await reporttomorrow(app, group, text, 0)
             elif msg.startswith("明日天气"):
                 await reporttomorrow(app, group, text, 2)
             elif msg.startswith("后日天气"):
                 await reporttomorrow(app, group, text, 3)
             elif is_int(msg[0]):
                 day = int(msg[0])
                 if day < 0 or day > 7:
                     return
                 await reporttomorrow(app, group, text, day)
         else:
             await app.sendGroupMessage(group, MessageChain.create([Plain('查询被取消了切噜噜——')]))
         return event
Exemplo n.º 6
0
async def AutoReply_Group_listener(message: MessageChain,
                                   app: GraiaMiraiApplication, group: Group,
                                   member: Member):
    if SearchSetting(group.id)["function"]["AutoReply"]:
        if member.id not in BlackId:
            MessageGet = AutoReply(message.asDisplay())
            if MessageGet.startswith("./Menhera/"):
                await app.sendGroupMessage(
                    group,
                    MessageChain.create([Image.fromLocalFile(MessageGet)]))
            elif MessageGet == "":
                pass
            else:
                await app.sendGroupMessage(
                    group, MessageChain.create([Plain(MessageGet)]))
            MessageGet = AutoVoice(message.asDisplay())
            if MessageGet.startswith("./voice/"):
                await app.sendGroupMessage(
                    group,
                    MessageChain.create([Voice().fromLocalFile(MessageGet)]))
            elif MessageGet == "":
                pass

            slogan = re.findall('(.*)\n(.*).jpg', message.asDisplay())  # 在线P图
            if slogan:
                upper = slogan[0][0]
                lower = slogan[0][1]
                await app.sendGroupMessage(
                    group,
                    MessageChain.create([
                        Image.fromNetworkAddress(
                            "https://api.dihe.moe/5000choyen?upper=" + upper +
                            "&lower=" + lower)
                    ]))
Exemplo n.º 7
0
async def dd_monitor(app: GraiaMiraiApplication, group: Group, member: Member,
                     tag: MessageChain):
    dd_data = yaml.safe_load(
        (Path(__file__).parent / 'dd_info.yml').read_text(encoding='UTF-8'))
    if name := tag.asDisplay().strip() not in dd_data:
        await app.sendGroupMessage(group,
                                   MessageChain.create([Plain('未发现你要D的组织')]))
        return
Exemplo n.º 8
0
 async def handle(self, app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if re.match(r"lol .* .*", message.asDisplay()):
         pass
     elif re.match(r"lol .*", message.asDisplay()):
         pass
     else:
         return await super().handle(app, message, group, member)
Exemplo n.º 9
0
 async def handle(self, app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member):
     if re.match("营销号#.*#.*#.*", message.asDisplay()):
         await update_user_call_count_plus1(group, member, UserCalledCount.functions, "functions")
         _, somebody, something, other_word = message.asDisplay().split("#")
         content = f"""{somebody}{something}是怎么回事呢?{somebody}相信大家都很熟悉,但是{somebody}{something}是怎么回事呢,下面就让小编带大家一起了解下吧。\n{somebody}{something},其实就是{somebody}{other_word},大家可能会很惊讶{somebody}怎么会{something}呢?但事实就是这样,小编也感到非常惊讶。\n这就是关于{somebody}{something}的事情了,大家有什么想法呢,欢迎在评论区告诉小编一起讨论哦!"""
         set_result(message, MessageItem(MessageChain.create([Plain(text=content)]), QuoteSource(GroupStrategy())))
     else:
         return None
Exemplo n.º 10
0
 async def handle(app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if re.match(r"/cp \w+ \w+", message.asDisplay()):
         await update_user_call_count_plus1(group, member,
                                            UserCalledCount.functions,
                                            "functions")
         _, attack, defence = message.asDisplay().split(" ")
         return await CPGeneratorHandler.generate_article(attack, defence)
Exemplo n.º 11
0
async def group_message_handler(
    message: MessageChain,
    app: GraiaMiraiApplication,
    group: Group, member: Member,
    server: ServerInterface
):
    if message.asDisplay().startswith('!!mc'):
        msg = '[QQ][{}]{}'.format(member.id, message.asDisplay()[5:])
        server.say(msg)
Exemplo n.º 12
0
 def reply_definition_message(self, message: MessageChain):
     if message.asDisplay() in self.define_data:
         if type(self.define_data[message.asDisplay()]) == list:
             Msg = self.define_data[message.asDisplay()][0]
             is_image = True
         else:
             Msg = self.define_data[message.asDisplay()]
             is_image = False
         return [is_image, Msg]
Exemplo n.º 13
0
async def priv_handler(app, message: MessageChain):
    if (message.asDisplay() == 'get'):
        await priv_get(app)
    if (message.asDisplay().startswith('se')):
        await priv_se(app, message)
    if (message.asDisplay().startswith('mute')):
        await priv_mute(app, message)
    if (message.asDisplay().startswith('toQQ')):
        await priv_toqq(app, message)
Exemplo n.º 14
0
async def group_message_handler(app: GraiaMiraiApplication, msgchain: MessageChain, group: Group, member: Member):
    if msgchain.asDisplay().startswith("#G"):
        await app.sendGroupMessage(group, MessageChain.create(
            [At(member.id), Plain(await getRepositoryInfo(msgchain.asDisplay().replace('#G','').lstrip().rstrip()))]))
    elif msgchain.asDisplay().startswith("#I"):
        repository = msgchain.asDisplay().replace('#I', '').lstrip().rstrip().split(' ')[0]
        issue_number = int(msgchain.asDisplay().replace('#I', '').lstrip().rstrip().split(' ')[1].replace('#',''))
        await app.sendGroupMessage(group, MessageChain.create(
            [At(member.id), Plain(await getIssueInfo(repository,issue_number))]))
Exemplo n.º 15
0
        async def group_message_handler(app: GraiaMiraiApplication,
                                        message: MessageChain, group: Group,
                                        member: Member):
            if message.asDisplay().startswith("对刀"):
                if group.id in GroupTokens:
                    t = GroupTokens[group.id]
                    bf = self.token_client[t]
                    data = bf.fetch_clan_status()
                    day_report = bf.fetch_day_report()

                    total_number = sum([x['number'] for x in day_report])
                    est_number = len(day_report) * 3

                    msg = "今日出刀 (%s/%s)" % (total_number, est_number)
                    for row in day_report:
                        msg += "\n({}) {} [{:,}]".format(
                            row['number'], row['name'], row['damage'])

                    x = [
                        Plain("%s #%d\n进度:L%d-%s (%d/%d)\n" % (
                            data['clan_info']['name'],
                            data['clan_info']['last_ranking'],
                            data['boss_info']['lap_num'],
                            data['boss_info']['name'],
                            data['boss_info']['current_life'],
                            data['boss_info']['total_life'],
                        )),
                        Plain(msg)
                    ]

                    await app.sendGroupMessage(group, MessageChain(__root__=x))
            if message.asDisplay().startswith("进度"):
                if group.id in GroupTokens:
                    t = GroupTokens[group.id]
                    bf = self.token_client[t]
                    data = bf.fetch_clan_status()
                    day_report = bf.fetch_day_report()

                    total_number = sum([x['number'] for x in day_report])
                    est_number = len(day_report) * 3

                    msg = "今日出刀 (%s/%s)" % (total_number, est_number)

                    x = [
                        Plain("%s #%d\n进度:L%d-%s (%d/%d)\n" % (
                            data['clan_info']['name'],
                            data['clan_info']['last_ranking'],
                            data['boss_info']['lap_num'],
                            data['boss_info']['name'],
                            data['boss_info']['current_life'],
                            data['boss_info']['total_life'],
                        )),
                        Plain(msg)
                    ]

                    await app.sendGroupMessage(group, MessageChain(__root__=x))
Exemplo n.º 16
0
 async def handle(app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if message.asDisplay().startswith("pdf "):
         await update_user_call_count_plus1(group, member,
                                            UserCalledCount.search,
                                            "search")
         keyword = message.asDisplay()[4:]
         return await PDFSearchHandler.search_pdf(group, member, keyword)
     else:
         return None
 async def handle(self, app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if re.match(r"[1-7]日内新番", message.asDisplay()):
         await update_user_call_count_plus1(group, member,
                                            UserCalledCount.search,
                                            "search")
         days = int(message.asDisplay()[0])
         return await self.formatted_output_bangumi(days)
     else:
         return await super().handle(app, message, group, member)
Exemplo n.º 18
0
 async def handle(app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member):
     if re.match(r"qrcode .+", message.asDisplay()):
         await update_user_call_count_plus1(group, member, UserCalledCount.functions, "functions")
         content = message.asDisplay()[7:]
         qrcode_img = qrcode.make(content)
         bytes_io = BytesIO()
         qrcode_img.save(bytes_io)
         return MessageItem(MessageChain.create([Image.fromUnsafeBytes(bytes_io.getvalue())]), QuoteSource(GroupStrategy()))
     else:
         return None
Exemplo n.º 19
0
 def confirm_waiter(waiter_group: Group, waiter_member: Member,
                    waiter_message: MessageChain):
     if all([
             waiter_group.id == group.id,
             waiter_member.id == member.id
     ]):
         if re.match(r"[是否]", waiter_message.asDisplay()):
             return waiter_message.asDisplay()
         else:
             return ""
Exemplo n.º 20
0
async def group_message_listener(app: GraiaMiraiApplication, group: Group,
                                 message: MessageChain, member: Member):
    if message.asDisplay() == "单抽":
        times = user.get_times(member.id)
        rarity, char = await gacha(times=times)
        await user.change(member.id, member.name, rarity, char)
        await app.sendGroupMessage(
            group,
            MessageChain.create([
                Image.fromLocalFile("chars/{}/{}".format(rarity, char)),
                Plain(
                    text="{}: {}".format(rarity_text_dict[rarity], char[:-4]))
            ]))
    elif message.asDisplay() == "十连":
        rarity_list, char_list = [], []
        for i in range(10):
            times = user.get_times(member.id)
            rarity, char = await gacha(times=times)
            await user.change(member.id, member.name, rarity, char)
            rarity_list.append(rarity)
            char_list.append(char)
        result_file, result_str = await ten_img_make(rarity_list, char_list)
        await app.sendGroupMessage(
            group,
            MessageChain.create(
                [Image.fromUnsafeBytes(result_file),
                 Plain(text=result_str)]))
        if "浊心斯卡蒂.png" in char_list:
            await app.sendGroupMessage(
                group,
                MessageChain.create(
                    [Voice_LocalFile(filepath="浊心斯卡蒂_干员报到.amr")]))
            await app.sendGroupMessage(
                group,
                MessageChain.create([
                    Plain(
                        text=
                        "我在等你,博士。我等你太久,太久了,我甚至已经忘了为什么要在这里等你......不过这些都不重要了。不再那么重要了。"
                    )
                ]))
    elif message.asDisplay().startswith("查询"):
        await app.sendGroupMessage(
            group,
            MessageChain.create(
                [Plain(text=user.query(member.id, member.name))]))

    elif message.asDisplay() == "清除":
        user.delete(member.id)
        await app.sendGroupMessage(
            group,
            MessageChain.create([
                Plain(
                    text="号码: {}\n昵称: {}\n清除完成".format(member.id, member.name))
            ]))
Exemplo n.º 21
0
async def group_message_handler(app: GraiaMiraiApplication, message: MessageChain, group: Group, member: Member):
    if group.id == Global_group:
        for i in ['状态', '查', '绑定', '预约', '总查刀']:
            if message.asDisplay().startswith(i):
                result, type = Bot.run(message.asDisplay() + ' ' + str(member.name) + ' ' + str(member.id))
                if type == 'STR':
                    await app.sendGroupMessage(group,
                                               MessageChain.create([At(target=member.id), Plain('\n' + result)]))
                elif type == 'IMG':
                    await app.sendGroupMessage(group,
                                               MessageChain.create([At(target=member.id), Image.fromLocalFile(result)]))
 async def handle(app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if message.asDisplay().startswith("番剧 "):
         await update_user_call_count_plus1(group, member,
                                            UserCalledCount.search,
                                            "search")
         return await BangumiInfoSearchHandler.get_bangumi_info(
             group, member,
             message.asDisplay()[3:])
     else:
         return None
Exemplo n.º 23
0
async def bar_music(app: GraiaMiraiApplication, group: Group, member: Member, tag: MessageChain):
	if tag.asDisplay().strip() == '':
		await app.sendGroupMessage(group, Template('点啥歌?').render())
		return
	search_data = await Netease.search(tag.asDisplay().strip())
	try:
		download = await Netease.download_song(search_data[0]['id'])
	except Exception as e:
		await app.sendGroupMessage(group, Template('不知道为什么,但是我就是放不了').render())
		return
	music_b = await silkcoder.encode(download, rate=80000, ss=0, t=60)
	await app.sendGroupMessage(group, MessageChain.create([await app.uploadVoice(music_b)]))
 async def handle(self, app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if message.asDisplay().startswith("steam "):
         await update_user_call_count_plus1(group, member,
                                            UserCalledCount.search,
                                            "search")
         set_result(
             message, await
             self.get_steam_game_search(group, member,
                                        message.asDisplay()[6:]))
     else:
         return None
async def abbreviated_prediction(app: GraiaMiraiApplication,
                                 message: MessageChain, group: Group):
    if abbreviation := message.asDisplay()[2:]:
        try:
            if abbreviation.isalnum():
                await app.sendGroupMessage(
                    group, await get_abbreviation_explain(abbreviation))
            else:
                await app.sendGroupMessage(
                    group, MessageChain.create([Plain(text="缩写部分只能为英文/数字!")]))
        except AccountMuted:
            pass
Exemplo n.º 26
0
 async def handle(app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if re.match(r"来点.+[色涩瑟]图", message.asDisplay()):
         # await update_user_call_count_plus1(group, member, UserCalledCount.functions, "functions")
         await update_user_call_count_plus1(group, member,
                                            UserCalledCount.setu, "setu")
         keyword = re.findall(r"来点(.*?)[色涩瑟]图", message.asDisplay(),
                              re.S)[0]
         return await LoliconKeywordSearchHandler.get_image(
             group, member, keyword)
     else:
         return None
Exemplo n.º 27
0
 def number_waiter(waiter_group: Group, waiter_member: Member,
                   waiter_message: MessageChain):
     if all([
             waiter_group.id == group.id,
             waiter_member.id == member.id,
             waiter_message.asDisplay().isnumeric()
             and 0 < int(waiter_message.asDisplay()) <= len(replies)
     ]):
         return int(waiter_message.asDisplay())
     elif all([
             waiter_group.id == group.id,
             waiter_member.id == member.id
     ]):
         return -1
Exemplo n.º 28
0
async def Games(app: GraiaMiraiApplication, group: Group, mesg: MessageChain):
    # print(mesg.asDisplay())
    global game, chengyu_now, chengyu_next
    if game == 0 and mesg.asDisplay() == "开始":
        game = 1
        chengyu_now = chengyuku[random.randint(0, number - 1)]
        await app.sendGroupMessage(group, MessageChain.create([
            Plain(text='从:"' + chengyu_now[0] + '"开始')
        ]))
        pass
    if mesg.asDisplay() == '结束' and game != 0:
        await app.sendGroupMessage(group, MessageChain.create([
            Plain(text='已结束')
        ]))
        game = 0
        pass
    if game == 1 and mesg.asDisplay() == '不会':
        chengyu_list = []
        for _ in chengyuku:
            if chengyu_compar(chengyu_now, _):
                chengyu_list.append(_)
        chengyu_now = chengyu_list[random.randint(0, len(chengyu_list) - 1)]
        await app.sendGroupMessage(group, MessageChain.create([
            Plain(text='我接:' + chengyu_now[0])
        ]))
        pass
    if game == 1 and mesg.asDisplay() == '解释':
        await app.sendGroupMessage(group, MessageChain.create([
            Plain(text=chengyu_now[0] + '(' + "'".join(chengyu_now[1]) + '):' + chengyu_now[2])
        ]))
        pass
    if game == 1:
        chengyu = mesg.asDisplay()
        for word in chengyuku:
            if chengyu == word[0]:
                chengyu_next = word
                if chengyu_compar(chengyu_now, chengyu_next):
                    if chengyu_next[0] == '一个顶俩':
                        await app.sendGroupMessage(group, MessageChain.create([
                            Plain(text='不要一个顶俩!')
                        ]))
                        game = 0
                        pass
                    await app.sendGroupMessage(group, MessageChain.create([
                        Plain(text=chengyu_next[0] + ' 正确!')
                    ]))
                    chengyu_now = chengyu_next
                    pass
                break
    pass
Exemplo n.º 29
0
async def genshin(
    app: GraiaMiraiApplication, group: Group, message: MessageChain, member: Member
):
    if message.asDisplay().startswith("!genshin "):
        uid = message.asDisplay().split(" ")[1]
        if len(uid) != 9:
            await app.sendGroupMessage(
                group, MessageChain.create([At(member.id), Plain(" Invalid uid!")])
            )
            return
        _s = await query(config["cookie"], uid)
        await app.sendGroupMessage(
            group, MessageChain.create([At(member.id), Plain(f" {_s}")])
        )
Exemplo n.º 30
0
 async def handle(app: GraiaMiraiApplication, message: MessageChain,
                  group: Group, member: Member):
     if re.match(r"来点.+笑话", message.asDisplay()):
         keyword = message.asDisplay()[2:-2]
         if keyword in joke_non_replace.keys():
             return MessageItem(
                 MessageChain.create([
                     Plain(text=random.choice(joke_non_replace[keyword]))
                 ]), Normal(GroupStrategy()))
         else:
             return MessageItem(
                 MessageChain.create([
                     Plain(text=random.choice(jokes).replace(
                         "%name%", keyword))
                 ]), QuoteSource(GroupStrategy()))