Пример #1
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
Пример #2
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
Пример #3
0
async def gather_file_data(bot: Bot,
                           data: PostingData) -> Tuple[str, str, str]:
    """
    Build and return output filename and caption for further processing.

    :param channel: Channel database object
    :param file: Wallpaper database object
    :return: Filename, caption and chat title
    """
    chat = await bot.get_chat(data.channel_id)
    if data.extension == "jpeg" or data.extension is None:
        extension = "jpg"
    else:
        extension = data.extension

    base_name = chat.username or chat.title.replace(" ", "_")
    if data.enable_counter:
        filename = f"{base_name.lower()}-{data.counter_value + 1}.{extension}"
    else:
        filename = f"{base_name.lower()}.{extension}"

    if chat.username:
        title_signature = f'<a href="https://t.me/{chat.username}">{chat.username}</a>'
    else:
        title_signature = md.quote_html(chat.title)

    if data.custom_signature:
        caption = data.custom_signature.replace("{title}", title_signature)
    elif data.enable_signature:
        if data.signature_text:
            caption = data.signature_text.replace("{title}", title_signature)
        else:
            caption = title_signature
    else:
        caption = None

    return filename, caption, helper.get_chat_title(chat)
Пример #4
0
async def cmd_version(message: types.Message):
    bot_version = md.quote_html(str(aiogram_core.SysInfo()))
    await message.reply(
        f"My Engine: {bot_version}")
Пример #5
0
async def cmd_version(message: types.Message) -> None:
    await message.reply("My Engine\n{api_info}".format(
        api_info=md.quote_html(str(aiogram_core.SysInfo()))))