async def get_m_id(message):

    # id_message = message.message_id
    message_id = message.forward_from_message_id
    try:
        if message.forward_from_chat.id == channels[0]:
            await commands.add_post(post_id=message_id)
            m_id = message.message_id
            text = message.text
            message_id = message.forward_from_message_id
            like_list = await commands.get_like_condition(post_id=message_id)
            rating_keyboard2 = InlineKeyboardMarkup(inline_keyboard=[
                [
                    InlineKeyboardButton(text=f"🔥 {like_list[1]}",
                                         callback_data=like_callback.new(
                                             action='no_reaction')),
                    InlineKeyboardButton(text=f"👍 {like_list[0]}",
                                         callback_data=like_callback.new(
                                             action='up_like')),
                    InlineKeyboardButton(text=f"👎 {like_list[2]}",
                                         callback_data=like_callback.new(
                                             action='down_like'))
                ],
                [
                    InlineKeyboardButton(
                        text='Предложить новость',
                        url=f'http://t.me/{bot_name}?start=start'),
                    InlineKeyboardButton(
                        text='Прокомментировать',
                        url=
                        f'http://t.me/{name_discussion_group}/{m_id}?comment=1'
                    ),
                ]
            ])
            await bot.edit_message_reply_markup(chat_id=channels[0],
                                                message_id=message_id,
                                                reply_markup=rating_keyboard2)
            # await bot.send_message(chat_id=channels_comment_id, text=' 👆  👆  👆  👆  👆  👆  👆  👆  👆  👆  👆 ', reply_to_message_id=message.message_id, reply_markup=rating_keyboard2)
            # await message.send_copy(chat_id=-1001101661839, reply_markup=rating_keyboard2)

            if message.content_type == 'photo':
                text = message.caption
                await message.photo[-1].download('test.jpg')
                send(text, 'test.jpg')
            elif message.content_type == 'text':
                text = message.text
                send(text)

    except AttributeError:
        pass

    if message.text is not None:
        logging.info(f'Новое сообщение в канале {message.chat.title}. \n'
                     f'{message.text}')
    elif message.caption is not None:
        logging.info(f'Новое сообщение в канале {message.chat.title}. \n'
                     f'{message.caption}')
Exemple #2
0
async def up_ind(call: CallbackQuery):
    await bot.answer_callback_query(call.id, text='Спасибо. Ваш голос учтен.')
    url_comment = call.message.reply_markup["inline_keyboard"][-1][-1]['url']
    message_id = call.message.message_id
    mention_id = str(call.from_user.id)
    # users = await commands.get_all_user(post_id=message_id)[0].replace('=', '&').split('&')
    users_str = await commands.get_all_user(post_id=message_id)
    users = users_str.replace('=', '&').split('&')
    if mention_id not in users:
        await commands.update_indifference(post_id=message_id, user_id=mention_id)
    elif mention_id in users:
        reaction = users[int(users.index(f'{mention_id}')) + 1]
        if reaction == 'like':
            await commands.like_take_away(post_id=message_id)
            # users_old = await commands.get_all_user(post_id=message_id)[0]
            users_old = await commands.get_all_user(post_id=message_id)
            users_new = users_old.replace(f'&{mention_id}=like', '')
            await commands.update_users(post_id=message_id, users=users_new)
            await commands.update_indifference(post_id=message_id, user_id=mention_id)
        elif reaction == 'ind':
            await commands.indifference_take_away(post_id=message_id)
            # users_old = await commands.get_all_user(post_id=message_id)[0]
            users_old = await commands.get_all_user(post_id=message_id)
            users_new = users_old.replace(f'&{mention_id}=ind', '')
            await commands.update_users(post_id=message_id, users=users_new)

        elif reaction == 'dis':
            await commands.dislike_take_away(post_id=message_id)
            # users_old = await commands.get_all_user(post_id=message_id)[0]
            users_old = await commands.get_all_user(post_id=message_id)
            users_new = users_old.replace(f'&{mention_id}=dis', '')
            await commands.update_users(post_id=message_id, users=users_new)
            await commands.update_indifference(post_id=message_id, user_id=mention_id)

    like_list = await commands.get_like_condition(post_id=message_id)
    rating_keyboard3 = InlineKeyboardMarkup(
        inline_keyboard=[
            [
                InlineKeyboardButton(text=f"🔥 {like_list[1]}", callback_data=like_callback.new(action='no_reaction')),
                InlineKeyboardButton(text=f"👍 {like_list[0]}", callback_data=like_callback.new(action='up_like')),
                InlineKeyboardButton(text=f"👎 {like_list[2]}", callback_data=like_callback.new(action='down_like'))
            ],
            [
                InlineKeyboardButton(text='Предложить новость', url=f'http://t.me/{bot_name}?start=start'),
                InlineKeyboardButton(text='Прокомментировать', url=f'{url_comment}'),
            ]
        ]

    )
    await call.message.edit_reply_markup(reply_markup=rating_keyboard3)
Exemple #3
0
from aiogram.types import InlineKeyboardButton, InlineKeyboardMarkup

# like_callback = CallbackData('count_like', 'action')
from keyboards.inline.callback_data import like_callback

rating_keyboard = InlineKeyboardMarkup(inline_keyboard=[
    [
        InlineKeyboardButton(
            text="👍", callback_data=like_callback.new(action='up_like')),
        InlineKeyboardButton(
            text="😐", callback_data=like_callback.new(action='no_reaction')),
        InlineKeyboardButton(
            text="👎", callback_data=like_callback.new(action='down_like'))
    ],
    [
        InlineKeyboardButton(text='Предложить новость',
                             url='http://t.me/defoldadmin_bot?start=start'),
        InlineKeyboardButton(text='Прокомментировать', callback_data='2'),
    ]
])