예제 #1
0
async def check_language(message: types.Message):
    locale = message.from_user.locale

    await message.reply(md.text(
        md.bold('Info about your language:'),
        md.text('🔸', md.bold('Code:'), md.code(locale.language)),
        md.text('🔸', md.bold('Territory:'), md.code(locale.territory or 'Unknown')),
        md.text('🔸', md.bold('Language name:'), md.code(locale.language_name)),
        md.text('🔸', md.bold('English language name:'), md.code(locale.english_name)),
        sep='\n',
    ))
예제 #2
0
파일: mainP.py 프로젝트: MaKxex/HouSec
async def heya(message: types.Message):
    WUpdater()
    chat_id = message.chat.id
    if id in dicty.keys():
        await message.reply(md.text(md.bold("Здраствуй, ",
                                            dicty.get(chat_id))))
    else:
        await message.reply(
            md.text(md.bold(
                "Привет, используйте команду /login чтобы зайти в систему"),
                    md.bold("Пример /login Login Password Name"),
                    sep="\n"))
예제 #3
0
def format_post(post_id: str, post: dict) -> (str, types.InlineKeyboardMarkup):
    text = md.text(
        md.hbold(post['title']),
        md.quote_html(post['body'])
    )

    markup = types.InlineKeyboardMarkup()
    markup.add(types.InlineKeyboardButton('Geri', callback_data=posts_cb.new(id='-', action='list')))
    return text, markup
예제 #4
0
파일: mainP.py 프로젝트: MaKxex/HouSec
async def switch(message: types.Message):
    user_id = message.chat.id
    global switch_index

    if user_id in dicty.keys():  # if ID in ID's pool
        if switch_index == 0:
            switch_index += 1
            await message.reply(md.bold("Система видеонаблюдения включена"))
            g1.start()
            sch.start()

        else:
            switch_index -= 1
            await message.reply(md.bold("Система видеонаблюдения выключена"))
            #python = sys.executable
            #os.execl(python, python, * sys.argv)
    else:
        await message.reply(
            md.text(md.bold("Вы не прошли Авторизацию"),
                    md.text("Используйте команду /login"),
                    sep="\n"))
예제 #5
0
async def get_feedback(call: types.CallbackQuery):
    # print(call.data.split(':'))
    message = call.message
    language = await get_locale(message)
    await FeedbackProcess.intro.set()
    keyboard = types.InlineKeyboardMarkup(inline_keyboard=[[
        types.InlineKeyboardButton(text=locale.get_text(
            'btn_cancel', language),
                                   callback_data="menu:cancel")
    ]])
    await message.edit_text(text=md.text(
        locale.get_text('msg_send_your_feedback', language)),
                            reply_markup=keyboard)
예제 #6
0
    def assetsPosibles(self):
        pLlave = self.pLlave
        try:
            AssetsPosibles = []
            server = Server(horizon_url=self.Horizon_url)
            cuenta = server.accounts().account_id(pLlave).call()
            #Assets no creados por el
            for i in cuenta['balances']:
                if i['asset_type'] != 'native':
                    AssetsPosibles.append((i['asset_code'], i['asset_issuer']))
            # Assets no creados por el
            try:
                Assets = server.assets().for_issuer(pLlave).call()

                for e in Assets['_embedded']['records']:
                    if not self.busqueda(AssetsPosibles, e['asset_code'],
                                         e['asset_issuer']):
                        AssetsPosibles.append(
                            (e['asset_code'], e['asset_issuer']))
            except:
                pass

            texto = md.text(
                md.bold("Seleccione un numero Assets:")) + "\n➖➖➖➖➖➖➖➖➖➖➖➖➖➖\n"
            contador = 0
            for i in AssetsPosibles:
                texto += (md.text(md.bold(str(contador))) + ". Assets Code: " +
                          md.text(md.code(str(i[0]))) + "\n   Asset Issuer:" +
                          md.text(md.code(str(i[1]))) + "\n")
                texto += ("\n➖➖➖➖➖➖➖➖➖➖➖➖➖➖\n")
                contador += 1

            return [texto, AssetsPosibles, contador]
        except:
            print("error")
            return []
예제 #7
0
def format_post(post_id: str, post: dict) -> (str, types.InlineKeyboardMarkup):
    text = md.text(
        md.hbold(post['title']),
        md.quote_html(post['body']),
        '',  # just new empty line
        f"Votes: {post['votes']}",
        sep='\n',
    )

    markup = types.InlineKeyboardMarkup()
    markup.row(
        types.InlineKeyboardButton('👍', callback_data=posts_cb.new(id=post_id, action='like')),
        types.InlineKeyboardButton('👎', callback_data=posts_cb.new(id=post_id, action='dislike')),
    )
    markup.add(types.InlineKeyboardButton('<< Back', callback_data=posts_cb.new(id='-', action='list')))
    return text, markup
예제 #8
0
async def send_menu_msg(message: types.Message):
    language = await get_locale(message)
    keyboard = types.InlineKeyboardMarkup(
        inline_keyboard=[[
            types.InlineKeyboardButton(text=locale.get_text(
                'btn_feedback', language),
                                       callback_data="menu:feedback:start")
        ],
                         [
                             types.InlineKeyboardButton(
                                 text=locale.get_text('btn_settings',
                                                      language),
                                 callback_data="menu:settings")
                         ]])
    text = md.text(locale.get_text('msg_feedback', language))
    return text, keyboard
예제 #9
0
async def show_user_info(message: types.Message):
    user: User = await register(message)
    return await message.answer(md.text(
        md.text('Information about ' + message.from_user.first_name + ' ' +
                str(message.from_user.last_name)),
        md.text('🔸', md.hbold('Your ID:'), md.hcode(message.from_user.id)),
        md.text('🔸', md.hbold('First name:'),
                md.hcode(message.from_user.first_name)),
        md.text('🔸', md.hbold('Second name:'),
                md.hcode(message.from_user.last_name or 'Unknown')),
        md.text('🔸', md.hbold('Username:'******'Unknown')),
        md.text('🔸', md.hbold('Phone number:'), md.hcode(user.phone_number))
        if user else "",
        sep='\n',
    ),
                                reply_markup=types.ReplyKeyboardRemove())
예제 #10
0
async def show_menu(message: types.Message, user: User):

    await message.answer(text=md.text(
        md.text('Information about ' + message.from_user.first_name + ' ' +
                str(message.from_user.last_name)),
        md.text('🔸', md.hbold('Your ID:'), md.hcode(user.user_id)),
        md.text('🔸', md.hbold('First name:'), md.hcode(user.first_name)),
        md.text('🔸', md.hbold('Second name:'),
                md.hcode(user.last_name or 'Unknown')),
        md.text('🔸', md.hbold('Username:'******'Unknown')),
        md.text('🔸', md.hbold('Phone number:'),
                md.hcode(user.phone_number)),
        sep='\n',
    ),
                         reply_markup=types.ReplyKeyboardRemove())

    text, keyboard = await fuser.send_menu_msg(message)
    return await message.answer(text=text, reply_markup=keyboard)
예제 #11
0
파일: mainP.py 프로젝트: MaKxex/HouSec
async def register(message: types.Message):
    WUpdater()
    Mtext = message.get_args().split(" ")  # Login Password UserName
    print(Mtext)
    user_id = message.chat.id

    try:
        if not user_id in dicty.keys():  # if ID in ID's pool

            if len(Mtext) < 3:
                await message.reply(
                    md.text(
                        md.bold('Не хватает данных!'),
                        md.text(
                            "Введите по примеру /login Login Password Name"),
                        sep="\n"))

            else:
                logpass = Mtext[0] + " " + Mtext[1]
                if not whitedict.get(logpass) == "":
                    await message.reply(md.bold("Этот пароль уже использован"))

                else:
                    if logpass in whitedict.keys():
                        create_user(user_id, Mtext[2])
                        used_password(logpass, user_id)
                        await message.reply(
                            md.text(md.bold("Авторизация прошла успешно"),
                                    md.text("Здравствуй, " + Mtext[2]),
                                    sep="\n"))

                    else:
                        await message.reply(
                            md.bold("Не верный Логин или Пароль"))
        else:
            await message.reply(
                md.text(md.bold("Вы уже прошли Авторизацию"),
                        md.text("Эта команда вам больше не понадобится"),
                        sep="\n"))
    except Exception as e:
        print(e)
        await message.reply(md.bold("Error in login"))
예제 #12
0
async def links(msg: types.Message, state: FSMContext, locale):
    urls = extractor.find_urls(msg.text)

    # Return if message not contain urls
    if not urls:
        if msg.chat.type == types.chat.ChatType.PRIVATE:
            await msg.answer(
                _('No links to music services were found in the message\\.'))
        return

    if not msg.chat.type == types.chat.ChatType.PRIVATE and not is_supported_link(
            urls[0]):
        return

    # Send bot `typing...`
    await bot.send_chat_action(chat_id=msg.chat.id,
                               action=types.ChatActions.TYPING)

    # Get user data from state
    user_data = await state.get_data()

    # Set layout if it not defined early
    if user_data.get(LINKS_LAYOUT_NAME) is None:
        async with state.proxy() as data:
            data[LINKS_LAYOUT_NAME] = LinksLayout.COMBINED.value

    for url in urls:
        new_url = url
        shazam = Shazam(url)
        if shazam.is_shazam_url():
            new_url = await shazam.find_links()
        message: List[str] = []

        try:
            linksdata = await odesli.links(url=new_url)
        except Exception as e:
            print(e)
            await msg.answer(
                _('Unfortunately, we have no data for this link 😥\.'))
            return

        entity = linksdata.entitiesByUniqueId[linksdata.entityUniqueId]

        def links_by_platform(platform: Platform) -> Optional[str]:
            return getattr(linksdata.linksByPlatform.get(platform), 'url',
                           None)

        message.append(
            md.hlink(
                f"{entity.artistName} - {entity.title}\n",
                get_streaming_hell_link(id=entity.id,
                                        type=entity.type,
                                        platform=entity.platforms[0])))

        # Compose message text for `SEPARATE` layout
        if user_data.get(LINKS_LAYOUT_NAME) == LinksLayout.SEPARATE.value:
            listen_links: list[str] = []
            buy_links: list[str] = []
            for key, value in platforms.items():
                if links_by_platform(key) and value['isStore'] is False:
                    listen_links.append(
                        md.hlink(value['name'], links_by_platform(key)))
                elif links_by_platform(key) and value['isStore'] is True:
                    buy_links.append(
                        md.hlink(value['name'], links_by_platform(key)))

            if listen_links:
                message.append(md.hbold(_('🎧 Listen')))
                message.extend(listen_links)
                message.append(
                    md.hlink(
                        'VK',
                        get_vk_search_link(
                            f"{entity.artistName} - {entity.title}")))
            if buy_links:
                message.append(md.hbold(_('\n🛍 Buy')))
                message.extend(buy_links)

        # Compose message text for `COMBINED` layout
        if user_data.get(LINKS_LAYOUT_NAME) == LinksLayout.COMBINED.value:
            for key, value in platforms.items():
                if links_by_platform(key):
                    message.append(
                        md.hlink(value['name'], links_by_platform(key)))
            message.append(
                md.hlink(
                    'VK',
                    get_vk_search_link(
                        f"{entity.artistName} - {entity.title}")))

        # Compose message text for `MINIMAL` layout
        if user_data.get(LINKS_LAYOUT_NAME) == LinksLayout.MINIMAL.value:
            for key, value in platforms.items():
                if links_by_platform(key):
                    message.append(
                        md.hlink(value['name'], links_by_platform(key)))
                    message.append(md.text(' | '))
            message.append(
                md.hlink(
                    'VK',
                    get_vk_search_link(
                        f"{entity.artistName} - {entity.title}")))

        caption = md.text(*message, sep='\n')
        if user_data.get(LINKS_LAYOUT_NAME) == LinksLayout.MINIMAL.value:
            caption = md.text(*message, sep='')

        # Delete user message that contains streaming link
        bot_member = await bot.get_chat_member(chat_id=msg.chat.id,
                                               user_id=bot.id)
        if msg.chat.type == types.ChatType.PRIVATE:
            await bot.delete_message(chat_id=msg.chat.id,
                                     message_id=msg.message_id)
        elif bot_member.can_delete_messages:
            await bot.delete_message(chat_id=msg.chat.id,
                                     message_id=msg.message_id)

        # Send found streaming links
        await msg.answer_photo(photo=entity.thumbnailUrl,
                               caption=caption,
                               parse_mode=types.ParseMode.HTML)