async def RDL(bot: Bot, event: Event):
    args = str(event.get_message()).split()
    if isinstance(event, MessageEvent):
        if args:
            if args[0] == 'random':
                await Random_Gal.send('Senrin折寿中......')
                async with AsyncClient() as Client:
                    mg = await get_random_game(Client=Client, event=event)
                await Random_Gal.finish(Message(mg))
            elif args[0] == 'tag':
                try:
                    tag = args[1]
                except:
                    await Random_Gal.finish(
                        Message(
                            f"[CQ:at,qq={event.user_id}]传入了不正确的参数......\n然后指令坏掉了,Senrin处理了个寂寞"
                        ))
                else:
                    await Random_Gal.send('Senrin折寿中......')
                    async with AsyncClient() as Client:
                        mg = await get_tag_game(Client=Client,
                                                tag=tag,
                                                event=event)
                    await Random_Gal.finish(Message(mg))
            else:
                await Random_Gal.finish(
                    Message(
                        f"[CQ:at,qq={event.user_id}]传入了不正确的参数......\n然后指令坏掉了,Senrin处理了个寂寞"
                    ))
        else:
            await Random_Gal.finish(
                Message(
                    f"[CQ:at,qq={event.user_id}]传入了不正确的参数......\n然后指令坏掉了,Senrin处理了个寂寞"
                ))
Esempio n. 2
0
async def search_handle(bot: Bot, event: Event, state: T_State):

    if event.user_id not in bot.config.master:
        search.finish()
    msg = str(event.get_message())
    if 'CQ:image' in msg:
        state["url"] = msg.split('url=')[-1][:-1]
Esempio n. 3
0
async def maimaidx(bot: Bot, event: Event, state: T_State):

    #获取关键词,数量 并处理
    comman = str(event.get_message()).strip().split(' ')
    keyword = ''
    num = 1

    try:
        if len(comman) == 2:
            num = int(comman[1])
            if num > 4:
                await bot.send(message=f'您搁这抽卡呢?')
                return 0
        Rlist = {'红': 2, '紫': 3, '白': 4}  #数组的index
        if comman[0][0] in Rlist.keys():
            rank = Rlist[comman[0][0]]
            lv = comman[0][1:]
            list = dxbot.random_song([lv], num=num, rank=rank)

        else:
            lv = comman[0].split('-')

            list = dxbot.random_song(lv, num=num)
    except:
        print('err')
        return

    msg = ''
    for i in list:
        if msg:
            msg += '\n----------------\n'
        msg += i
    await bot.send(event, message=msg)
Esempio n. 4
0
async def setp_handle(bot: Bot, event: Event, state: T_State):

    comman = str(event.get_message()).split()
    if comman:
        print(comman)
        state["key"] = comman[0]
        if len(comman) > 1:
            state["value"] = comman[1:]
Esempio n. 5
0
async def setp_got(bot: Bot, event: Event, state: T_State):
    try:

        state["value"] = str(event.get_message()).split()

        #录入库
        save_json(state["key"], state["value"])
        await bot.send(event, message=f'ok~')
    except:
        await bot.send(event, message=f'失败了QAQ')
Esempio n. 6
0
async def _Reply_SearchPic(bot: Bot, event: Event):
    send_except_msg = (Message(
        f"[CQ:at,qq={event.get_user_id()}]你确定你给我的是一张图片?\n"
        "若持续出此报错,请按照以下步骤搜图:\n"
        '1.将图片逐张转发至Senrin\n'
        '2.回复需要搜索的图片并附上“搜图”'))
    if '搜图' in str(event.get_message()):
        search_list = []
        result_list = []
        send_msg_result = '搜图结果如下:\n'
        for _msg in event.reply.message:  # type:ignore    初步处理数据
            if _msg.type == 'image':
                search_list.append(_msg.data['url'])
            else:
                pass
        if search_list:  # 有图
            await Reply_SearchPic.send('ちょっと待ってください......')
            for numst in range(len(search_list)):
                msg_url = search_list[numst]
                # 获取搜索结果
                try:
                    search_result = await SauceNAO(numst=numst,
                                                   pic_url=msg_url)
                except:
                    await Reply_SearchPic.finish(
                        '似乎出现了蜜汁错误......图搜到了但没完全搜到......')
                    return
                if search_result:
                    result_list.append(search_result)
            if result_list:  # 存在搜索结果
                for result_send in result_list:
                    _add_result = (f"第{result_send[0]}张图片:\n"
                                   f"{result_send[1]}\n")
                    send_msg_result += _add_result
                if isinstance(event, GroupMessageEvent):
                    await Reply_SearchPic.send(
                        Message(
                            f'[CQ:at,qq={event.get_user_id()}] Senrin从SauceNAO获得了搜图结果,并将以私聊方式发送!\nPS:若持续未收到图片,请添加Senrin为好友!'
                        ))
                    await bot.send_private_msg(
                        user_id=event.user_id,
                        message=Message(send_msg_result))
                elif isinstance(event, PrivateMessageEvent):
                    await Reply_SearchPic.send(
                        Message('好耶!找到图咯!\n' + send_msg_result))
            else:  # 不存在搜索结果
                await Reply_SearchPic.send(
                    Message(
                        f'[CQ:at,qq={event.get_user_id()}] 暂无相关信息,Senrin搜了个寂寞')
                )
        else:  # 无图
            await Reply_SearchPic.finish(send_except_msg)
    await Reply_SearchPic.finish()
Esempio n. 7
0
async def search_got(bot: Bot, event: Event, state: T_State):

    if event.user_id not in bot.config.master:
        await search.finish("不是Master不行的哦~")

    msg = str(event.get_message())

    if 'CQ:image' in msg:
        state["url"] = msg.split('url=')[-1][:-1]

    data = await tool.get_image_data(state["url"])
    await search.finish(data)
Esempio n. 8
0
async def setp_got(bot: Bot, event: Event, state: T_State):
    try:

        comman = str(event.get_message()).split()
        state["key"] = comman[0]
        if ",url=" in state["key"]:
            state["key"] = state["key"].split(",url=")[0]

        if len(comman) > 1:

            state["value"] = comman[1:]
            #录入库
            save_json(state["key"], state["value"])
            await bot.send(event, message=f'ok~')
    except:
        await bot.send(event, message=f'失败了QAQ')
Esempio n. 9
0
async def add(bot: Bot, event: Event, state: T_State):
    '''
    >> 添加关注 bid nickname
    '''
    user_id = event.user_id
    msg = str(event.get_message()).split()
    if(user_id in master):
        if msg[0].isdigit:
            id = msg[0]
            nickname = msg[1]
        elif msg[1].isdigit:
            id = msg[1]
            nickname = msg[0]
        else:
            await bot.send(event, message = f'添加失败勒')
            return
        to_add(id, nickname)
        with open(path, 'w+') as f :
            tojson = json.dumps(liveroom,sort_keys=True, ensure_ascii=False, indent=4,separators=(',',': '))
            f.write(tojson)
        await bot.send(event, message = f'添加成功~')
Esempio n. 10
0
async def _command_setu(bot: Bot, event: Event, state: dict):
    global last_time_command

    def check_tpye(arg):  # 检查命令格式
        if arg:
            if arg[0] == 'random':
                try:
                    level = int(arg[1])
                    num = int(arg[2])
                except:
                    check_type = False
                else:
                    if level in [1, 2, 0] and num <= 10:
                        check_type = True
                    else:
                        check_type = False
            elif arg[0] == 'search':
                try:
                    num = int(arg[2])
                except:
                    check_type = False
                else:
                    check_type = True if num <= 10 else False
            else:
                check_type = False
        else:
            check_type = False
        return check_type

    if isinstance(event, GroupMessageEvent):
        if event.group_id in [
                get_driver().config.GroupList['last'],
                get_driver().config.GroupList['test']
        ]:
            arg = str(event.get_message()).split()
            checked_type = check_tpye(arg)
            if checked_type == False:
                setu = None
                await command_setu.finish(
                    Message(
                        f"[CQ:at,qq={event.user_id}]传入了不正确的参数......\n然后指令坏掉了,Senrin处理了个寂寞"
                    ))
            else:
                if arg[0] == 'random':
                    level, num = arg[1], int(arg[2])
                    start_time = datetime.datetime.now()  # 取现在时间
                    # 用于判定程序是否为初次启动,检测last_time是否被赋值
                    if isinstance(last_time_command, datetime.datetime):
                        if (start_time - last_time_command).seconds <= 60:
                            if str(event.user_id) not in masterList:
                                await command_setu.finish(
                                    "我球球你了让Senrin歇一会儿吧......爪巴涩图很累的说......")
                                return
                            else:
                                await command_setu.send("我爪巴爪巴......这就去......")
                    level_zh = level_zh_dic[str(level)]
                    handle_msg = (f"[CQ:at,qq={event.user_id}]随机涩图触发\n"
                                  "触发方式:command\n"
                                  f"图片分级:{level_zh}\n"
                                  f"图片数量:{num}\n"
                                  "Loading......(约15秒钟)")
                    await command_setu.send(Message(handle_msg))
                    setu = await random_setu(Rmodle='random',
                                             level=level,
                                             num=num)
                elif arg[0] == 'search':
                    keywords, num = arg[1], int(arg[2])
                    start_time = datetime.datetime.now()  # 取现在时间
                    # 用于判定程序是否为初次启动,检测last_time是否被赋值
                    if isinstance(last_time_command, datetime.datetime):
                        if (start_time - last_time_command).seconds <= 60:
                            if str(event.user_id) not in masterList:
                                await command_setu.finish(
                                    "我球球你了让Senrin歇一会儿吧......爪巴涩图很累的说......")
                                return
                            else:
                                await command_setu.send("我爪巴爪巴......这就去......")
                    handle_msg = ("定向涩图触发\n"
                                  "触发方式:command\n"
                                  f"关键词:{keywords}\n"
                                  f"图片数量:{num}\n"
                                  "Loading......(约15秒钟)")
                    await command_setu.send(Message(handle_msg))
                    setu = await search_setu(Keywords=keywords, num=num)
                else:
                    setu = None
        else:
            setu = None
    elif isinstance(event, PrivateMessageEvent):
        if str(event.user_id) in masterList:
            arg = str(event.get_message()).split()
            checked_type = check_tpye(arg)
            if checked_type == False:
                setu = None
                await command_setu.finish(
                    "传入了不正确的参数......\n然后指令坏掉了,Senrin处理了个寂寞")
            else:
                if arg[0] == 'random':
                    level, num = arg[1], arg[2]
                    level_zh = level_zh_dic[str(level)]
                    handle_msg = (f"[CQ:at,qq={event.user_id}]随机涩图触发\n"
                                  "触发方式:command\n"
                                  f"图片分级:{level_zh}\n"
                                  f"图片数量:{num}\n"
                                  "Loading......(约15秒钟)")
                    await command_setu.send(Message(handle_msg))
                    setu = await random_setu(Rmodle='random',
                                             level=level,
                                             num=num)
                elif arg[0] == 'search':
                    keywords, num = arg[1], int(arg[2])
                    handle_msg = ("定向涩图触发\n"
                                  "触发方式:command\n"
                                  f"关键词:{keywords}\n"
                                  f"图片数量:{num}\n"
                                  "Loading......(约15秒钟)")
                    await command_setu.send(Message(handle_msg))
                    setu = await search_setu(Keywords=keywords, num=num)
                else:
                    setu = None
        else:
            setu = None
    else:
        setu = None
    if setu:
        await command_setu.send('Active!!!')
        for msg in setu:
            await command_setu.send(Message(msg))
            await asyncio.sleep(0.1)
    if event.get_user_id() not in masterList and resetTime == True:
        last_time_command = datetime.datetime.now()
    download_urls.clear()
    await command_setu.finish()