How to use 'telegram markdown link' in Python

Every line of 'telegram markdown link' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
73def markdown(text,messenger):
74
75 msg = text.replace('<c>','`')
76
77 if messenger == 'telegram':
78 msg = msg.replace('<b>','*')
79 msg = msg.replace('<u>','')
80 msg = msg.replace('<cb>','/')
81 msg = msg.replace('<ca>','')
82 elif messenger == 'discord':
83 msg = msg.replace('<u>','__')
84 msg = msg.replace('<b>','**')
85 msg = msg.replace('<cb>','`')
86 msg = msg.replace('<ca>','`')
87
88 return msg
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

340def slave_message_link(self, msg: Message, tg_dest: TelegramChatID, msg_template: str, reactions: str,
341 old_msg_id: OldMsgID = None,
342 target_msg_id: Optional[TelegramMessageID] = None,
343 reply_markup: Optional[ReplyMarkup] = None,
344 silent: bool = False) -> telegram.Message:
345 self.bot.send_chat_action(tg_dest, ChatAction.TYPING)
346
347 assert isinstance(msg.attributes, LinkAttribute)
348 attributes: LinkAttribute = msg.attributes
349
350 thumbnail = urllib.parse.quote(attributes.image or "", safe="?=&#:/")
351 thumbnail = "<a href=\"%s\">🔗</a>" % thumbnail if thumbnail else "🔗"
352 text = "%s <a href=\"%s\">%s</a>\n%s" % \
353 (thumbnail,
354 urllib.parse.quote(attributes.url, safe="?=&#:/"),
355 html.escape(attributes.title or attributes.url),
356 html.escape(attributes.description or ""))
357
358 if msg.text:
359 text += "\n\n" + self.html_substitutions(msg)
360 if old_msg_id:
361 return self.bot.edit_message_text(text=text, chat_id=old_msg_id[0], message_id=old_msg_id[1],
362 prefix=msg_template, suffix=reactions, parse_mode='HTML',
363 reply_markup=reply_markup)
364 else:
365 return self.bot.send_message(chat_id=tg_dest,
366 text=text,
367 prefix=msg_template, suffix=reactions,
368 parse_mode="HTML",
369 reply_to_message_id=target_msg_id,
370 reply_markup=reply_markup,
371 disable_notification=silent)

Related snippets