Example #1
0
async def handle_check(bot: Bot, event: GroupMessageEvent, state: T_State):
    check_msg = state['check']
    room_id = state['room_id']
    if check_msg != '是':
        await bilibili_live.finish('操作已取消')
    sub_command = state['sub_command']
    if sub_command == '订阅':
        _res = await sub_add(bot=bot, event=event, state=state)
    elif sub_command == '取消订阅':
        _res = await sub_del(bot=bot, event=event, state=state)
    elif sub_command == '清空订阅':
        _res = await sub_clear(bot=bot, event=event, state=state)
    else:
        _res = Result(error=True,
                      info='Unknown error, except sub_command',
                      result=-1)
    if _res.success():
        logger.info(
            f"{sub_command}直播间成功, group_id: {event.group_id}, room_id: {room_id}"
        )
        await bilibili_live.finish(f'{sub_command}成功!')
    else:
        logger.error(
            f"{sub_command}直播间失败, group_id: {event.group_id}, room_id: {room_id},"
            f"info: {_res.info}")
        await bilibili_live.finish(f'{sub_command}失败了QAQ, 可能并未订阅该用户, 或请稍后再试~')
Example #2
0
async def handle_sub_command_args(bot: Bot, event: GroupMessageEvent,
                                  state: T_State):
    sub_command = state['sub_command']
    if sub_command not in ['订阅', '取消订阅']:
        await pixivision.reject('没有这个命令哦, 请在【订阅/取消订阅】中选择并重新发送, 取消命令请发送【取消】:')

    if sub_command == '订阅':
        _res = await sub_add(bot=bot, event=event, state=state)
    elif sub_command == '取消订阅':
        _res = await sub_del(bot=bot, event=event, state=state)
    else:
        _res = Result(error=True,
                      info='Unknown error, except sub_command',
                      result=-1)
    if _res.success():
        logger.info(
            f"{sub_command}Pixivision成功, group_id: {event.group_id}, {_res.info}"
        )
        await pixivision.finish(f'{sub_command}成功!')
    else:
        logger.error(
            f"{sub_command}Pixivision失败, group_id: {event.group_id}, {_res.info}"
        )
        await pixivision.finish(
            f'{sub_command}失败了QAQ, 可能并未订阅Pixivision, 或请稍后再试~')