def off_on_topic(update: Update, context: CallbackContext): chat_username = update.message.chat.username group_one = context.match.group(1) if chat_username == ONTOPIC_USERNAME and group_one.lower() == 'off': reply = update.message.reply_to_message moved_notification = 'I moved this discussion to the [off-topic Group]({}).' if reply and reply.text: issued_reply = get_reply_id(update) if reply.from_user.username: name = '@' + reply.from_user.username else: name = reply.from_user.first_name replied_message_text = reply.text_html replied_message_id = reply.message_id text = ( f'{name} <a href="t.me/pythontelegrambotgroup/{replied_message_id}">wrote</a>:\n' f'{replied_message_text}\n\n' f'⬇️ ᴘʟᴇᴀsᴇ ᴄᴏɴᴛɪɴᴜᴇ ʜᴇʀᴇ ⬇️') offtopic_msg = context.bot.send_message( OFFTOPIC_CHAT_ID, text, disable_web_page_preview=True, parse_mode=ParseMode.HTML) update.message.reply_text(moved_notification.format( 'https://telegram.me/pythontelegrambottalk/' + str(offtopic_msg.message_id)), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_to_message_id=issued_reply) else: update.message.reply_text( 'The off-topic group is [here](https://telegram.me/pythontelegrambottalk). ' 'Come join us!', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN) elif chat_username == OFFTOPIC_USERNAME and group_one.lower() == 'on': update.message.reply_text( 'The on-topic group is [here](https://telegram.me/pythontelegrambotgroup). ' 'Come join us!', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN)
def off_on_topic(bot, update, groups): chat_username = update.message.chat.username if chat_username == ONTOPIC_USERNAME and groups[0].lower() == 'off': reply = update.message.reply_to_message moved_notification = 'I moved this discussion to the ' \ '[off-topic Group]({}).' if reply and reply.text: issued_reply = get_reply_id(update) if reply.from_user.username: name = '@' + reply.from_user.username else: name = reply.from_user.first_name replied_message_text = reply.text replied_message_id = reply.message_id text = ( f'{name} [wrote](t.me/{ONTOPIC_USERNAME}/{replied_message_id}):\n' f'{replied_message_text}\n\n' f'⬇️ ᴘʟᴇᴀsᴇ ᴄᴏɴᴛɪɴᴜᴇ ʜᴇʀᴇ ⬇️') offtopic_msg = bot.send_message(OFFTOPIC_CHAT_ID, text, disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN) update.message.reply_text(moved_notification.format( f'https://telegram.me/{OFFTOPIC_USERNAME}/' + str(offtopic_msg.message_id)), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_to_message_id=issued_reply) else: update.message.reply_text( f'The off-topic group is [here](https://telegram.me/{OFFTOPIC_USERNAME}). ' 'Come join us!', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN) elif chat_username == OFFTOPIC_USERNAME and groups[0].lower() == 'on': update.message.reply_text( f'The on-topic group is [here](https://telegram.me/{ONTOPIC_USERNAME}). ' 'Come join us!', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN)
def off_on_topic(update: Update, context: CallbackContext): chat_username = update.message.chat.username group_one = context.match.group(1) if chat_username == ONTOPIC_USERNAME and group_one.lower() == 'off': reply = update.message.reply_to_message moved_notification = 'I moved this discussion to the [off-topic Group]({}).' if reply and reply.text: issued_reply = get_reply_id(update) if reply.from_user.username: name = '@' + reply.from_user.username else: name = reply.from_user.first_name replied_message_text = reply.text replied_message_id = reply.message_id text = (f'{name} [wrote](t.me/pythontelegrambotgroup/{replied_message_id}):\n' f'{replied_message_text}\n\n' f'⬇️ ᴘʟᴇᴀsᴇ ᴄᴏɴᴛɪɴᴜᴇ ʜᴇʀᴇ ⬇️') offtopic_msg = context.bot.send_message(OFFTOPIC_CHAT_ID, text, disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN) update.message.reply_text( moved_notification.format('https://telegram.me/pythontelegrambottalk/' + str(offtopic_msg.message_id)), disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_to_message_id=issued_reply ) else: update.message.reply_text( 'The off-topic group is [here](https://telegram.me/pythontelegrambottalk). ' 'Come join us!', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN) elif chat_username == OFFTOPIC_USERNAME and group_one.lower() == 'on': update.message.reply_text( 'The on-topic group is [here](https://telegram.me/pythontelegrambotgroup). ' 'Come join us!', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN)
def off_on_topic(bot, update, groups): chat_username = update.message.chat.username if chat_username == ONTOPIC_USERNAME and groups[0] == 'off': reply = update.message.reply_to_message if reply and reply.text: issued_reply = get_reply_id(update) update.message.reply_text( 'I moved this discussion to the ' '[off-topic Group](https://telegram.me/pythontelegrambottalk).', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_to_message_id=issued_reply) if reply.from_user.username: name = '@' + reply.from_user.username else: name = reply.from_user.first_name replied_message_text = reply.text text = (f'{name} _wrote:_\n' f'{replied_message_text}\n\n' f'⬇️ ᴘʟᴇᴀsᴇ ᴄᴏɴᴛɪɴᴜᴇ ʜᴇʀᴇ ⬇️') bot.sendMessage(OFFTOPIC_CHAT_ID, text, disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN) else: update.message.reply_text( 'The off-topic group is [here](https://telegram.me/pythontelegrambottalk). ' 'Come join us!', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN) elif chat_username == OFFTOPIC_USERNAME and groups[0] == 'on': update.message.reply_text( 'The on-topic group is [here](https://telegram.me/pythontelegrambotgroup). ' 'Come join us!', disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN)