Exemplo n.º 1
0
async def ls_service(session: CommandSession, service_name: str):
    all_services = Service.get_loaded_services()
    if service_name in all_services:
        sv = all_services[service_name]
        on_g = '\n'.join(map(str, sv.enable_group))
        off_g = '\n'.join(map(str, sv.disable_group))
        default_ = 'enabled' if sv.enable_on_default else 'disabled'
        msg = f"服务{sv.name}:\n默认:{default_}\nuse_priv={sv.use_priv}\nmanage_priv={sv.manage_priv}\nvisible={sv.visible}\n启用群:\n{on_g}\n禁用群:\n{off_g}"
        session.finish(msg)
    else:
        session.finish(f'未找到服务{service_name}')
Exemplo n.º 2
0
async def buy_item(session: CommandSession):
    bot = session.bot
    ev = session.event
    gid = ev.group_id
    uid = ev.user_id
    if duel_judger.get_on_off_status(ev.group_id):
        msg = '现在正在决斗中哦,请决斗后再来购买道具吧。'
        await bot.finish(ev, msg, at_sender=True)
    num = get_user_counter(gid, uid, UserModel.ITEM_BUY_TIME)
    if num <= 0:
        await bot.send(ev, f'你的城市没有商店或已经没有购买次数,无法购买道具')
        return
    score_counter = ScoreCounter2()
    score = score_counter._get_score(gid, uid)
    if score < 10000:
        await bot.send(ev, f'你的金币不足1万,无法购买道具')
        return
    if check_technolog_counter(gid, uid, TechnologyModel.TRANSPARENT_TRADE):
        if not session.state['item']:
            item = choose_item()
            session.state['item'] = item["name"]
            jieshou = session.get(
                'jieshou',
                prompt=
                f'商店老板拿出的道具为{item["rank"]}级道具{item["name"]},是否要购买(是|否)回答其他内容默认为是'
            )
        jieshou = session.get('jieshou')
        if jieshou != '否':
            item = get_item_by_name(session.state['item'])
            score_counter._reduce_score(gid, uid, 10000)
            add_item(gid, uid, item)
            num -= 1
            save_user_counter(gid, uid, UserModel.ITEM_BUY_TIME, num)
            await bot.send(ev, f'你花费了1万金币购买到了{item["rank"]}级道具{item["name"]}')
            return
        else:
            num -= 1
            save_user_counter(gid, uid, UserModel.ITEM_BUY_TIME, num)
            await bot.send(ev, f'你一脸嫌弃的看着老板拿出的道具,拒绝了购买')
            return
    num -= 1
    score_counter._reduce_score(gid, uid, 10000)
    save_user_counter(gid, uid, UserModel.ITEM_BUY_TIME, num)
    item = choose_item()
    add_item(gid, uid, item)
    await bot.send(ev, f'你花费了1万金币购买到了{item["rank"]}级道具{item["name"]}')
Exemplo n.º 3
0
async def _(session: CommandSession):
    text = session.current_arg_text
    img = session.current_arg_images
    if session.is_first_run:
        session.state['item'] = 0
        return
    if img:
        session.state[session.current_key] = img
    else:
        session.state[session.current_key] = text
Exemplo n.º 4
0
async def _(session: CommandSession):
    text = session.current_arg_text
    img = session.current_arg_images
    if session.is_first_run:
        if text:
            session.state['search_name'] = text.strip()
        return
    if img:
        session.state[session.current_key] = img
    else:
        session.state[session.current_key] = text
Exemplo n.º 5
0
async def dnd_search(session: CommandSession):
    bot = session.bot
    ev = session.event
    cmd_msg = session.get('search_name', prompt="请输入要搜索的内容")
    ds = DndSearchCounter()
    result_li = []
    result_li.extend(ds._search_skill(cmd_msg))
    result_li.extend(ds._search_armor(cmd_msg))
    result_li.extend(ds._search_classes(cmd_msg))
    result_li.extend(ds._search_feat(cmd_msg))
    result_li.extend(ds._search_races(cmd_msg))
    result_li.extend(ds._search_rule(cmd_msg))
    result_li.extend(ds._search_tools(cmd_msg))
    result_li.extend(ds._search_spell_list(cmd_msg))
    result_li.extend(ds._search_magic_items(cmd_msg))
    result_li.extend(ds._search_rule_dmg(cmd_msg))
    result_li.extend(ds._search_background(cmd_msg))
    result_li.extend(ds._search_mm(cmd_msg))
    if len(result_li) > 1:
        msg = '查询结果存在多个,请在3分钟以内回复清单的数字来查阅内容:'
        if len(result_li) > 20:
            msg += "最多显示20条数据。如果需要查询更多信息,请前往网站查询:https://eiriksgata.github.io/rulateday-dnd5e-wiki/#/"
        for i in range(20):
            msg += f'\n{i + 1}. {result_li[i][1]}'
        aliases_str = session.get('number', prompt=msg)
        if not str(aliases_str).strip().isdecimal():
            await bot.finish(ev, "无法识别输入内容")
        num = int(str(aliases_str).strip()) - 1
        # TODO 匹配前五个字符为怪物图鉴: 做额外下载图片展示的处理
        detail = result_li[num][2].replace('\n\n', '\n')
        msg = f"{result_li[num][1]}:\n{detail}"
        await bot.finish(ev, msg)
    else:
        if len(result_li) == 0:
            await bot.finish(ev, "未搜索到结果")
        # TODO 匹配前五个字符为怪物图鉴: 做额外下载图片展示的处理
        detail = result_li[0][2].replace('\n\n', '\n')
        msg = f"{result_li[0][1]}:\n{detail}"
        await bot.finish(ev, msg)