Exemple #1
0
async def parse(bot: Bot, event: GroupMessageEvent, state: T_State):
    args = str(event.get_plaintext()).strip().lower().split()
    if not args:
        await luck.reject('你似乎没有发送有效的参数呢QAQ, 请重新发送:')
    state[state["_current_key"]] = args[0]
    if state[state["_current_key"]] == '取消':
        await luck.finish('操作已取消')
Exemple #2
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_State):
    args = str(event.get_plaintext()).strip().lower().split()
    if not args:
        pass
    elif args and len(args) == 1:
        state['draw'] = args[0]
    else:
        await luck.finish('参数错误QAQ')
Exemple #3
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent,
                               state: T_State):
    args = set(str(event.get_plaintext()).strip().split())
    # 排除r18
    for tag in args.copy():
        if tag in ['r18', 'R18', 'r-18', 'R-18']:
            args.remove(tag)
    state['tags'] = args
Exemple #4
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent,
                               state: T_State):
    args = str(event.get_plaintext()).strip().lower().split()
    if not args:
        state['skill'] = None
    elif args and len(args) == 1:
        state['skill'] = args[0]
    else:
        await set_vocation.finish('参数错误QAQ')
Exemple #5
0
async def miya_button(bot: Bot, event: GroupMessageEvent, state: T_State):
    arg = str(event.get_plaintext()).strip().lower()
    voice = re.sub('喵一个', '', arg)
    voice_file = MiyaVoice().get_voice_filepath(voice=voice)
    if not os.path.exists(voice_file):
        await bot.send(event=event, message='喵?')
    else:
        msg = MessageSegment.record(file=f'file:///{voice_file}')
        await bot.send(event=event, message=msg)
Exemple #6
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_State):
    args = str(event.get_plaintext()).strip().lower().split()
    if args and len(args) == 1:
        state['sub_command'] = args[0]
    elif args and len(args) == 2:
        state['sub_command'] = args[0]
        state['sub_arg'] = args[1]
    else:
        await nhentai.finish('参数错误QAQ')
Exemple #7
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_State):
    args = str(event.get_plaintext()).strip().lower().split()
    if args and len(args) == 1:
        state['sub_command'] = args[0]
        state['sub_arg'] = None
    elif args and len(args) == 2:
        state['sub_command'] = args[0]
        state['sub_arg'] = args[1]
    else:
        await omega.finish('你好呀~ 我是Omega Miya~ 请问您今天要来点喵娘吗?')
Exemple #8
0
async def set_rate(bot: Bot, event: GroupMessageEvent):
    try:
        rate = float(event.get_plaintext().strip())
        if rate > 1 or rate < 0:
            await bot.send(event, '概率要在0~1之间', at_sender=event.is_tome())
            return
        YYGQ_RATE = rate
        await sv.set_config('YYGQ_RATE', YYGQ_RATE, target=event.group_id)
        await bot.send(event, f'当前回复概率为{YYGQ_RATE}')
    except Exception as e:
        await bot.send(event, str(e))
Exemple #9
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_State):
    # 载入牌堆
    state['deck'] = deck_list.keys()

    args = str(event.get_plaintext()).strip().lower().split()

    if not args:
        msg = '当前可用卡组有:'
        for item in state['deck']:
            msg += f'\n【{item}】'
        await deck.send(msg)
    elif args and len(args) == 1:
        state['draw'] = args[0]
    else:
        await deck.finish('参数错误QAQ')
Exemple #10
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_State):
    args = str(event.get_plaintext()).strip().lower().split()
    if not args:
        pass
    elif args and len(args) == 1:
        state['sub_command'] = args[0]
    elif args and len(args) == 2:
        state['sub_command'] = args[0]
        state['skill_name'] = args[1]
    elif args and len(args) == 3:
        state['sub_command'] = args[0]
        state['skill_name'] = args[1]
        state['skill_description'] = args[2]
    else:
        await skill_admin.finish('参数错误QAQ')
Exemple #11
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent,
                               state: T_State):
    args = str(event.get_plaintext()).strip().split()
    if args:
        await admin_mail_bind.finish('该命令不支持参数QAQ')

    # 发送已有邮箱列表
    mailbox_list_res = DBEmailBox.list()
    mailbox_list = mailbox_list_res.result
    if not mailbox_list_res.success() or not mailbox_list:
        await admin_mail_bind.finish('无可绑定邮箱, 请先添加邮箱!')

    state['mailbox_list'] = mailbox_list
    mailbox_msg = '】\n【'.join(mailbox_list)
    msg = f'当前可绑定邮箱:\n【{mailbox_msg}】'
    await admin_mail_bind.send(msg)
Exemple #12
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent,
                               state: T_State):
    args = str(event.get_plaintext()).strip().split()
    if args:
        await mail_receive.finish('该命令不支持参数QAQ')

    group_id = event.group_id
    group = DBGroup(group_id=group_id)
    res = group.mailbox_clear()

    if res.success():
        logger.info(f'Group:{event.group_id}/User:{event.user_id} 清空绑定邮箱成功')
        await admin_mail_bind.finish('Success! 已清空本群组的绑定邮箱')
    else:
        logger.info(
            f'Group:{event.group_id}/User:{event.user_id} 清空绑定邮箱失败, error: {res.info}'
        )
        await admin_mail_bind.finish('清空本群组的绑定邮箱失败QAQ, 请检联系管理员处理')
Exemple #13
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_State):
    args = str(event.get_plaintext()).strip().lower().split()
    if not args:
        pass
    else:
        await almanac.finish('参数错误QAQ')

    user_id = event.user_id

    # 求签者昵称, 优先使用群昵称
    draw_user = event.sender.card
    if not draw_user:
        draw_user = event.sender.nickname

    draw_result = old_almanac(user_id=user_id)

    # 向用户发送结果
    today = datetime.date.today().strftime('%Y年%m月%d日')
    msg = f"今天是{today}\n{draw_user}今日:\n{'='*12}\n{draw_result}"
    await almanac.finish(msg)
Exemple #14
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent,
                               state: T_State):
    # 获取设置了名称的插件列表
    plugins = list(
        filter(
            lambda p: set(p.export.keys()).issuperset({'custom_name', 'usage'}
                                                      ), get_loaded_plugins()))
    if not plugins:
        await bot_help.finish('暂时没有可用的插件QAQ')
    state['plugin_list'] = plugins
    # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海
    args = str(event.get_plaintext()).strip().lower().split()
    if args:
        # 如果用户发送了参数则直接赋值
        state['plugin_name'] = args[0]
    else:
        # 如果用户没有发送参数, 则发送功能列表并结束此命令
        plugins_list = '\n'.join(p.export.custom_name for p in plugins)
        await bot_help.finish(
            f'我现在支持的插件有: \n\n{plugins_list}\n\n注意: 群组权限等级未达到要求的命令不会被响应\n输入"/help [插件]"即可查看插件详情及帮助'
        )
Exemple #15
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent,
                               state: T_State):
    args = str(event.get_plaintext()).strip().lower().split()
    if args:
        await search_image.finish('该命令不支持参数QAQ')
Exemple #16
0
async def handle_first_receive(bot: Bot, event: GroupMessageEvent,
                               state: T_State):
    args = str(event.get_plaintext()).strip().split()
    if args:
        await mail_receive.finish('该命令不支持参数QAQ')

    group_id = event.group_id
    group = DBGroup(group_id=group_id)
    group_bind_mailbox = group.mailbox_list()
    if not group_bind_mailbox.success() or not group_bind_mailbox.result:
        logger.info(f'{group_id} 收邮件失败: 没有绑定的邮箱')
        await mail_receive.finish('本群组没有绑定的邮箱, 请先绑定邮箱后再收件!')

    mail_box_list_msg = '\n'.join([x for x in group_bind_mailbox.result])
    await mail_receive.send(
        f'本群组已绑定邮箱:\n{mail_box_list_msg}\n\n正在连接到邮箱服务器, 请稍后...')

    for mailbox_address in group_bind_mailbox.result:
        mailbox = DBEmailBox(address=mailbox_address).get_info()
        if not mailbox.success():
            logger.error(
                f'邮箱 {mailbox_address} 信息获取失败, 请检查数据库, error: {mailbox.info}')
            await mail_receive.send(f'邮箱: {mailbox_address} 收件失败QAQ, 请联系管理员处理')
            continue

        host = mailbox.result.get('server_host')
        password = mailbox.result.get('password')
        # 解密密码
        password = decrypt_password(ciphertext=password)
        if not password.success():
            logger.error(f'邮箱 {mailbox_address} 密码验证失败')
            await mail_receive.send(
                f'邮箱: {mailbox_address}\n密码验证失败QAQ, 请联系管理员处理')
            continue
        password = password.result
        unseen_mail_res = await get_unseen_mail_info(address=mailbox_address,
                                                     server_host=host,
                                                     password=password)
        if not unseen_mail_res.success():
            logger.error(
                f'邮箱 {mailbox_address} 收件失败, error: {unseen_mail_res.info}')
            await mail_receive.send(f'邮箱: {mailbox_address}\n收件失败QAQ, 请稍后再试')
            continue
        elif not unseen_mail_res.result:
            logger.info(f'邮箱 {mailbox_address} 收件完成, 没有新的邮件')
            await mail_receive.send(f'邮箱: {mailbox_address}\n收件完成, 没有新的邮件~')
            continue
        else:
            for mail in unseen_mail_res.result:
                html = mail.html
                content = re.sub(r'<[^>]*>', '', html)
                content = re.sub(r'\s', '', content)
                content = content.replace('&nbsp;',
                                          '').replace('\n',
                                                      '').replace(' ', '')
                msg = f"【{mail.header}】\n时间: {mail.date}\n发件人: {mail.sender}\n{'='*16}\n{content}"
                await mail_receive.send(msg)
            logger.info(
                f'邮箱 {mailbox_address} 收件完成, 共{len(unseen_mail_res.result)}封新的邮件'
            )
            await mail_receive.send(
                f'邮箱: {mailbox_address}\n收件完成, 共{len(unseen_mail_res.result)}封新的邮件~'
            )
Exemple #17
0
async def sleep(bot: Bot, event: GroupMessageEvent):
    base = 0 if '午' in event.get_plaintext() else 5 * 60 * 60
    length = len(event.get_plaintext())
    sleep_time = base + round(
        math.sqrt(length) * 60 * 30 + 60 * random.randint(-15, 15))
    await util.silence(event, sleep_time, skip_su=False)