I am trying to get my telegram bot mention users on telegram who don't have username and want to mention them using userID. Below is my python code.. it doesn't tags those who don't have username.
def welcome(update, context, new_member):
# Greets a person who joins the chat
message = update.message
chat_id = message.chat.id
if new_member.username is None:
username = "["+new_member.first_name+"](tg://user?id="+str(new_member.id)+")"
else:
username = new_member.username
logger.info(
"%s joined to chat %d (%s)",
escape(username),
chat_id,
escape(message.chat.title),
)
text = (
f"Hello @{username}! Welcome to the {message.chat.title} "
"telegram group!\n"
"Please introduce yourself."
)
context.bot.send_message(chat_id=chat_id, text=text)
according to link : it is possible to mention user by its numerical id with markup: Markdown style
To use this mode, pass Markdown in the parse_mode field when using sendMessage. Use the following syntax in your message:
inline mention of a user
I am not able to apply this in my code and get it to work. Can someone pls help me? The feature has been applied successfully here
https://github.com/domdorn/telegram/commit/ea308cadb739a9a018c7fbabc16824e2ff82d415
I wanna apply the same in my code so that it will mention users who don't have username with their ID.