Exemplo n.º 1
0
async def sections(mes: Message):
    #journal_log(mes)
    if not uc.select_id(mes.from_user.id):
        await mes.answer('Доступ запрещён.')
        return

    await mes.answer(**SECTION_LIST.get(mes.text))
Exemplo n.º 2
0
async def help(mes: Message):
    #journal_log(mes)
    if mes.chat.type != 'private':
        return
    if not uc.select_id(mes.from_user.id):
        await mes.answer('Доступ запрещён.')
        return

    res = uc.select_id(mes.from_user.id).get('role')
    answer = {
        1: HELP_MEMBER_TEXT,
        2: HELP_COM_TEXT,
        3: HELP_COM_TEXT,
        4: HELP_MEMBER_TEXT
    }
    await mes.answer(answer.get(res[0], 'Error'))
Exemplo n.º 3
0
async def patchnote(mes: Message):
    #journal_log(mes)
    if mes.chat.type != 'private':
        return
    if not uc.select_id(mes.from_user.id):
        await mes.answer('Доступ запрещён.')
        return
    await mes.answer(PATCHNOTE_TEXT, reply_markup=patchnote_keyboard)
Exemplo n.º 4
0
async def craft(mes: Message):
    #journal_log(mes)
    if mes.chat.type != 'private':
        return
    if not uc.select_id(mes.from_user.id) or not uc.check_perm_role(mes.from_user.id, [2, 3]):
        await mes.answer('Доступ запрещён.')
        return

    await mes.answer(**SECTION_LIST.get(mes.text))
    await craft_states.Q1.set()
Exemplo n.º 5
0
async def top(mes: Message):
    if not uc.select_id(mes.from_user.id):
        await mes.answer('Доступ запрещён.')
        return

    req = 'SELECT nickname, class, guild_tag, top_loc FROM users WHERE top_loc != 0 ORDER BY -top_loc LIMIT 10'
    text = '<u><b>🗺Топ нашедших:</b></u>\n\n'
    users = mes.db.checkall(req)
    for i, user in enumerate(users):
        text += f'<b>{i+1}) {user[1]}[{user[2]}]{user[0]} — {user[3]}</b>\n'
    await mes.answer(text)
Exemplo n.º 6
0
async def reg_as(mes: Message):
    if mes.from_user.id != ADMIN:
        return
    if mes.reply_to_message is None:
        await mes.answer('Error')
        return
    if not uc.select_id(mes.reply_to_message.from_user.id):
        await mes.answer('Not in database')
        return

    mes.db.query('UPDATE users SET role = ? WHERE id = ?',
                 [mes.text[8:], mes.reply_to_message.from_user.id])
    uc.loading()
Exemplo n.º 7
0
async def loc_miss(mes: Message):
    if not uc.select_id(mes.from_user.id):
        await mes.answer('Доступ запрещён.')
        return

    res = mes.db.checkall('SELECT name, lvl FROM loc WHERE code LIKE "NoneCode%"', [])
    answer = '<b><u>🔎Разыскиваемые локации:</u></b>\n\n{}'
    txt = ''
    if not res:
        answer = answer.format('Пусто')
        await mes.answer(answer)
        return
    for i, l in enumerate(res):
        txt += '<b>{}){} {} lvl.{}</b>\n\n'.format(i+1, LOC_TYPES.get(l[0].split(" ")[-1]), l[0], l[1])
    await mes.answer(answer.format(txt))
Exemplo n.º 8
0
async def start_func(mes: Message, state: FSMContext):
    #await journal_log(mes)
    if mes.chat.type != 'private':
        return
    if uc.select_id(mes.from_user.id):
        # if already registered
        news = mes.db.check('SELECT info FROM settings WHERE name = "news"',
                            [])[0]
        await mes.answer(START_MAIN_MENU_TEXT.format(
            random.choice(START_HEADER_TEXT), news),
                         reply_markup=start_menu)
        await state.finish()
    else:
        for el in START_INVITE_TEXT:
            await mes.answer(el)
            await asyncio.sleep(0.5)
        await start_states.Q1.set()
Exemplo n.º 9
0
async def pub_pinnn(query: InlineQuery):
    pin_id = query.db.check(
        'SELECT info FROM settings WHERE name = "al_pin_num"')[0]
    data_pid = query.query[8:]
    if pin_id != data_pid:
        return

    user = uc.select_id(query.from_user.id)
    if user:
        guild_tag = user.get('guild_tag')
        castle = CASTLE_EMBLEMS_AROUND.get(user.get('castle'))
        d = f'🔹{castle}[{guild_tag}]'
        pin_order = query.db.check(
            'SELECT info FROM settings WHERE name = "al_pin"')[0]

        if d not in pin_order:
            pin_order = pin_order + '\n' + d
            query.db.query(
                'UPDATE settings SET info = ? WHERE name = "al_pin"',
                [pin_order])

            x = query.db.check(
                'SELECT info FROM settings WHERE name = "al_pin_mes_id"')[0]
            al_pin_mid_dict = json.loads(x)
            keyboard = pub_pin_keyboard(f'pub_pin:{data_pid}')
            for mid in al_pin_mid_dict.items():
                try:
                    await bot.edit_message_text(pin_order,
                                                int(mid[0]),
                                                int(mid[1]),
                                                reply_markup=keyboard)
                    await asyncio.sleep(0.3)
                except:
                    pass

    txt = query.db.check(
        'SELECT info FROM settings WHERE name = "al_pin_pub"')[0]
    results = []
    results.append(
        InlineQueryResultArticle(
            id='1',
            title='📯Приказ',
            description='Опубликовать приказ',
            input_message_content=InputTextMessageContent(message_text=txt)))
    await query.answer(results=results, cache_time=1, is_personal=True)
Exemplo n.º 10
0
async def loc_list(mes: Message):
    #journal_log(mes)
    if not uc.select_id(mes.from_user.id):
        await mes.answer('Доступ запрещён.')
        return

    als_len = len(mes.db.checkall('SELECT * FROM loc WHERE lvl = 99', []))
    mines_len = len(
        mes.db.checkall('SELECT * FROM loc WHERE name LIKE "%Mine%"', []))
    ruins_len = len(
        mes.db.checkall('SELECT * FROM loc WHERE name LIKE "%Ruins%"', []))
    forts_len = len(
        mes.db.checkall(
            'SELECT * FROM loc WHERE name IN ("Fort", "Tower", "Outpost")',
            []))
    last_update = mes.db.check(
        'SELECT info FROM settings WHERE name = "last_l_check"', [])[0]

    txt = LOC_LIST_TEXT.format(ruins_len, mines_len, forts_len, als_len,
                               last_update)
    await mes.answer(txt, reply_markup=loc_keyboard)
Exemplo n.º 11
0
async def hero_analyz(mes: Message):
    # Сбор данных
    parse = re.search(HERO_PARSE, mes.text)
    for emblem in list(CASTLE_EMBLEMS):
        if parse.group('castle') == emblem:
            castle = CASTLE_EMBLEMS.get(emblem)
            break
        else:
            castle = 'ERROR'

    if uc.select_id(mes.from_user.id):
        mes.db.query(
            'UPDATE users SET username = ?, nickname = ?, lvl = ?, class = ?, guild_tag = ?, castle = ? WHERE id = ?',
            [
                mes.from_user.username,
                parse.group('nickname'),
                int(parse.group('lvl')),
                parse.group('class'),
                parse.group('guild_tag'), castle, mes.from_user.id
            ])
    else:
        mes.db.query(
            'INSERT INTO users (id, username, nickname, lvl, class, guild_tag, castle) values (?,?,?,?,?,?,?)',
            [
                mes.from_user.id, mes.from_user.username,
                parse.group('nickname'),
                parse.group('lvl'),
                parse.group('class'),
                parse.group('guild_tag'), castle
            ])

    # Автоназначение Командира и Админа по умолчанию
    if mes.chat.id == ADMIN:
        mes.db.query('UPDATE users SET role = 2 WHERE id = ?', [ADMIN])
    elif mes.chat.id == GUILD_MASTER:
        mes.db.query('UPDATE users SET role = 3 WHERE id = ?', [GUILD_MASTER])

    # Update cash
    uc.loading()
Exemplo n.º 12
0
async def trade(mes: Message):
    #journal_log(mes)
    if mes.chat.type != 'private':
        return
    if not uc.select(**{'id': mes.from_user.id, 'guild_tag': 'AT'}):
        await mes.answer('Доступ запрещён.')
        return

    load = await mes.answer('Запрашиваю, подожди./⏳')
    await load.edit_text('Запрашиваю, подожди../⌛')
    await load.edit_text('Запрашиваю, подожди.../⏳')

    res = uc.select_id(mes.from_user.id).get('trade')
    if not res:
        await load.edit_text(TRADE_ANSWER_TEXT.format('Пусто'))
        return

    herb_text = ''
    herb_list = res.split(' ')
    await main_client.connect()
    for el in herb_list:
        async with main_client.conversation(CW_BOT_ID) as conv:
            time.sleep(float(str(random.uniform(1, 2))[0:4]))
            await conv.send_message('/t_' + str(el))
            answer = await conv.get_response()
        try:
            cost = re.search(r'шт. по (\d+)', answer.message).group(1)
            name = re.search(r'Предложения (\D+) сейчас:',
                             answer.message).group(1)
        except:
            x = 'В правилах введён недоступный ресурс.\nПожалуйста поменяйте правило через /gs id, либо обратитесь к @Irrenriel.'
            await load.edit_text(x)
            return

        herb_text += f'<code>{el}</code> | {name} | <a href="https://t.me/share/url?url=/wtb_{el}">{cost}💰</a>\n'
    await main_client.disconnect()
    await load.edit_text(TRADE_ANSWER_TEXT.format(herb_text))
Exemplo n.º 13
0
async def loc_list_query(query: InlineQuery):
    if not uc.select_id(query.from_user.id):
        return

    mes_text = CALL_DATA_LOC_TYPE_DICT.get('loc_type_cap')
    res = query.db.checkall(
        'SELECT name, lvl, code FROM loc WHERE lvl = 99 ORDER BY name', [])
    txt = '<u><b>{}</b></u>\n\n'.format(mes_text['text'])
    for el in res:
        locs = query.db.checkall(
            'SELECT code,name,lvl,working,work_status FROM loc WHERE conqueror = ? ORDER BY lvl',
            [el[0]])
        if not locs: continue
        txt += '<b>{}{} ({}):</b>\n'.format('⚜🎪 ', el[0], len(locs))
        for l in locs:
            txt += '{}{} lvl.{} [{}{}]\n'.format(
                LOC_TYPES.get(l[1].split(' ')[-1], 'error'), l[1], str(l[2]),
                str(l[3]), l[4])
        txt += '\n'
    empty_locs = query.db.checkall(
        'SELECT code,name,lvl FROM loc WHERE conqueror = "Forbidden Clan" ORDER BY lvl',
        [])
    len_el = len(empty_locs)
    txt += f'<b>🏴‍☠ Forbidden Clan ({len_el})</b>{":" if len_el else ""}\n'
    if len_el:
        for l in empty_locs:
            txt += '{}{} lvl.{}</a>\n'.format(
                LOC_TYPES.get(l[1].split(' ')[-1], 'error'), l[1], str(l[2]))

    results = []
    results.append(
        InlineQueryResultArticle(id=query.from_user.id,
                                 title='🚩Карта',
                                 description='Карта мира',
                                 input_message_content=InputTextMessageContent(
                                     message_text=txt, parse_mode='HTML')))
    await query.answer(results=results, cache_time=1, is_personal=True)