Exemplo n.º 1
0
async def weather(session: CommandSession):
    location = session.get('location', prompt_expr=expr.WHERE)
    # time = session.get_optional('time')

    if location.province and not location.city and not location.district:
        # there is no city or district, ask the user for more info!
        session.get('location_more',
                    prompt=render(expr.WHERE_IN_PROVINCE,
                                  province=location.province))

    final_loc = location.heweather_format()
    await session.send(f'位置:{final_loc}')
Exemplo n.º 2
0
async def note_add(session: CommandSession):
    content = session.get('content', prompt_expr=expr.ADD_WHAT_CONTENT)
    new_note = await Note.create(content=content,
                                 context_id=context_id(session.ctx))
    await session.send_expr(expr.ADD_SUCCESS,
                            id=new_note.id,
                            content=new_note.content)
Exemplo n.º 3
0
async def weather(session: CommandSession):
    # 从 Session 对象中获取城市名称(city),如果当前不存在,则询问用户
    city = session.get('city', prompt='你想查询哪个城市的天气呢?')
    # 获取城市的天气预报
    weather_report = await get_weather_of_city(city)
    # 向用户发送天气预报
    await session.send(weather_report)
Exemplo n.º 4
0
async def tuling(session: CommandSession):
    message = session.get('message', prompt='我已经准备好啦,来跟我聊天吧~')

    finish = message in ('结束', '拜拜', '再见')
    if finish:
        asyncio.ensure_future(session.send('拜拜啦,你忙吧,下次想聊天随时找我哦~'))
        return

    # call tuling api
    reply = f'你说了:{message}'

    one_time = session.get_optional('one_time', False)
    if one_time:
        asyncio.ensure_future(session.send(reply))
    else:
        del session.args['message']
        session.get('message', prompt=reply)
Exemplo n.º 5
0
async def teach(session: CommandSession):
    text = session.get('text')
    msg = session.ctx
    if text == '':
        await session.send('请输入 /teach 关键词 说什么')
    else:
        text_report = await get_text(msg, text)
        await session.send(text_report)
Exemplo n.º 6
0
async def tuling(session: CommandSession):
    message = session.get('message', prompt='我已经准备好啦,来跟我聊天吧~')

    finish = message in ('结束', '拜拜', '再见')
    if finish:
        asyncio.ensure_future(session.send('拜拜啦,你忙吧,下次想聊天随时找我哦~'))
        return

    # call tuling api
    reply = f'你说了:{message}'

    one_time = session.get_optional('one_time', False)
    if one_time:
        asyncio.ensure_future(session.send(reply))
    else:
        del session.args['message']
        session.get('message', prompt=reply)
Exemplo n.º 7
0
async def forget(session: CommandSession):
    text = session.get('text')
    msg = session.ctx
    if text == '':
        await session.send('请输入 /forget 关键词')
    else:
        text_report = await fg_text(msg, text)
        await session.send(text_report)
Exemplo n.º 8
0
async def logs(session: CommandSession):
    text = session.get('text')
    msg = session.ctx
    if text == '':
        await session.send('请正确输入 /进度 游戏版本 服务器 玩家ID (只支持查询3.0以后的版本)')
    else:
        text_report = await get_logs(text)
        await session.send(text_report)
Exemplo n.º 9
0
async def ss1(session: CommandSession):
    ss1 = session.get('ss1')
    if ss1 == '':
        await session.send('请输入 /咏速 咏速数值')
    elif ss1.isdigit():
        if int(ss1) > 364:
            text_report = await get_ss1(ss1)
            await session.send(text_report)
        else:
            await session.send('请输入 /咏速 咏速数值')
        if int(ss1) > 5000:
            await session.send('您咏唱速度要上天啊')
    else:
        await session.send('请输入 /咏速 咏速数值(数字)')
Exemplo n.º 10
0
async def dh(session: CommandSession):
    dh = session.get('dh')
    if dh == '':
        await session.send('请输入 /直击 直击数值')
    elif dh.isdigit():
        if int(dh) > 364:
            if int(dh) > 5000:
                await session.send('您直击要上天啊')
            else:
                text_report = await get_dh(dh)
                await session.send(text_report)
        else:
            await session.send('请输入大于初始直击的数值')
    else:
        await session.send('请输入 /直击 直击数值(数字)')
Exemplo n.º 11
0
async def det(session: CommandSession):
    det = session.get('det')
    if det == '':
        await session.send('请输入 /信念 信念数值')
    elif det.isdigit():
        if int(det) > 364:
            if int(det) > 5000:
                await session.send('您信念要上天啊')
            else:
                text_report = await get_det(det)
                await session.send(text_report)
        else:
            await session.send('请输入大于初始信念的数值')
    else:
        await session.send('请输入 /信念 信念数值(数字)')
Exemplo n.º 12
0
async def fy(session: CommandSession):
    fy = session.get('fy')
    if fy == '':
        await sefyion.send('请输入 /防御 防御数值')
    elif fy.isdigit():
        if int(fy) > 364:
            if int(fy) > 20000:
                await session.send('您防御要上天啊')
            else:
                text_report = await get_fy(fy)
                await session.send(text_report)
        else:
            await session.send('请输入 /防御 防御数值')
    else:
        await session.send('请输入 /防御 防御数值(数字)')
Exemplo n.º 13
0
async def ss(session: CommandSession):
    ss = session.get('ss')
    if ss == '':
        await session.send('请输入 /技速 技速数值')
    elif ss.isdigit():
        if int(ss) > 364:
            if int(ss) > 5000:
                await session.send('您技能速度要上天啊')
            else:
                text_report = await get_ss(ss)
                await session.send(text_report)
        else:
            await session.send('请输入 /技速 技速数值')
    else:
        await session.send('请输入 /技速 技速数值(数字)')
Exemplo n.º 14
0
async def bq(session: CommandSession):
    bq = session.get('bq')
    if bq == '':
        await session.send('请输入 /不屈 不屈数值')
    elif bq.isdigit():
        if int(bq) > 364:
            if int(bq) > 5000:
                await session.send('您不屈要上天啊')
            else:
                text_report = await get_bq(bq)
                await session.send(text_report)
        else:
            await session.send('请输入 /不屈 不屈数值')
    else:
        await session.send('请输入 /不屈 不屈数值(数字)')
Exemplo n.º 15
0
async def hit(session: CommandSession):
    hit = session.get('hit')
    if hit == '':
        await session.send('请输入 /暴击 暴击数值')
    elif hit.isdigit():
        if int(hit) > 364:
            if int(hit) > 5000:
                await session.send('您暴击要上天啊')
            else:
                text_report = await get_hit(hit)
                await session.send(text_report)
        else:
            await session.send('请输入大于初始暴击的数值')
    else:
        await session.send('请输入 /暴击 暴击数值(数字)')
Exemplo n.º 16
0
async def tuling(session: CommandSession):
    message = session.get('message', prompt='我已经准备好啦,来跟我聊天吧~')

    finish = message in ('结束', '拜拜', '再见')
    if finish:
        session.finish('拜拜啦,你忙吧,下次想聊天随时找我哦~')
        return

    # call tuling api
    reply = f'你说了:{message}'

    one_time = session.get_optional('one_time', False)
    if one_time:
        session.finish(reply)
    else:
        session.pause(reply)
Exemplo n.º 17
0
async def note_remove(session: CommandSession):
    ctx_id = context_id(session.ctx)
    count = await note_count(ctx_id)
    if count == 0:
        await session.send_expr(expr.LIST_EMPTY)
        return

    id_ = session.get('id', prompt_expr=expr.DEL_WHICH_ID)
    note_ = await Note.query.where((Note.context_id == ctx_id)
                                   & (Note.id == id_)).gino.first()
    if note_ is None:
        await session.send_expr(expr.DEL_ID_NOT_EXISTS, id=id_)
    else:
        await note_.delete()
        await session.send_expr(expr.DEL_SUCCESS,
                                id=id_,
                                content=note_.content)
Exemplo n.º 18
0
async def tuling(session: CommandSession):
    message = session.get('message', prompt_expr=expr.I_AM_READY)

    ctx_id = context_id(session.ctx)
    if ctx_id in tuling_sessions:
        del tuling_sessions[ctx_id]

    tmp_msg = Message(message)
    text = tmp_msg.extract_plain_text()
    images = [s.data['url'] for s in tmp_msg
              if s.type == 'image' and 'url' in s.data]

    # call tuling api
    replies = await call_tuling_api(session, text, images)
    logger.debug(f'Got tuling\'s replies: {replies}')

    if replies:
        for reply in replies:
            await session.send(escape(reply))
            await asyncio.sleep(0.8)
    else:
        await session.send_expr(expr.I_DONT_UNDERSTAND)

    one_time = session.get_optional('one_time', False)
    if one_time:
        # tuling123 may opened a session, we should recognize the
        # situation that tuling123 want more information from the user.
        # for simplification, we only recognize named entities,
        # and since we will also check the user's input later,
        # here we can allow some ambiguity.
        ne_type = tuling_ne_type(replies, {
            'LOC': ('哪里', '哪儿', re.compile(r'哪\S城市'), '位置'),
            'TIME': ('什么时候',),
        })
        if ne_type:
            logger.debug(f'One time call, '
                         f'and there is a tuling session for {ne_type}')
            tuling_sessions[ctx_id] = ne_type
    else:
        session.pause()
Exemplo n.º 19
0
async def weather(session: CommandSession):
    city = session.get('city', prompt='你想查询哪个城市的天气呢?')
    weather_report = await get_weather_of_city(city)
    await session.send(weather_report)
Exemplo n.º 20
0
async def weather(session: CommandSession):
    city = session.get('city', prompt=__(e.WHICH_CITY))
    await session.send(__(e.REPORT, city=city))
Exemplo n.º 21
0
async def note_add(session: CommandSession):
    content = session.get('content', prompt='你想记录什么内容呢?')
    await session.send(f'记录了:{content}')
Exemplo n.º 22
0
async def note_remove(session: CommandSession):
    id_ = session.get('id', prompt='你想删除的笔记的 ID 是多少呢?')
    await session.send(f'你删除了笔记 {id_}')
Exemplo n.º 23
0
async def weather(session: CommandSession):
    city = session.get('city', prompt_expr=expr.WHICH_CITY)
    await session.send_expr(expr.REPORT, city=city)
Exemplo n.º 24
0
async def weather(session: CommandSession):
    city = session.get('city', prompt_expr=expr.WHICH_CITY)
    await session.send_expr(expr.REPORT, city=city)
Exemplo n.º 25
0
async def weather(session: CommandSession):
    city = session.get('city', prompt='你想查询哪个城市的天气呢?')
    weather_report = await get_weather_of_city(city)
    await session.send(weather_report)