@@ 1,3 1,5 @@
+import html
+
import googletrans
import toml
@@ 19,11 21,23 @@ bot = Client("bot", api_id, api_hash, bot_token=config["bot"]["token"])
async def translate(cl: Client, msg: Message):
if not (msg.text or msg.caption):
return
- text = tr.translate(msg.text or msg.caption).text
+
+ translated = tr.translate(msg.text or msg.caption)
+ text = msg.link
+
+ if msg.reply_to_message:
+ text += f" (<a href=\"{msg.reply_to_message.link}\">replied to</a>)"
+
+ if msg.edit_date:
+ text += " (edited)"
+
+ text += "\n\n"
+ text += html.escape(translated.text)
await bot.send_message(
chat_id=channels[msg.chat.id],
- text=f"{msg.link}{' (edited)' if msg.edit_date else ''}\n\n{text}",
+ text=text,
+ parse_mode="html",
disable_web_page_preview=bool(msg.text),
disable_notification=bool(msg.edit_date)
)