1

I want to share my friend's telegram contact via bot. But my friend does not have a telegram username. I know his id number. How can I share it?

I use PyTelegramBotApi. And my code is as follows:

from telebot import TeleBot, types bot = TeleBot(token=TOKEN) @bot.message_handler(commands=['start']) def start_bot(message): text = "My friend contact" markup = types.InlineKeyboardMarkup() markup.add(types.InlineKeyboardButton(text='Contact', url="tg://user?id=<1427022865>")) bot.send_message(message.chat.id, text=text, reply_markup=markup) bot.polling() 

I read on the internet how to use url. But I make mistakes. Because: url="tg://user?id=<1427022865>"

How to use it properly? Or is there another way?

2 Answers 2

1

A bot can only send a message to a profile that has already activated the bot.

So make your friend "start" the bot, than the code should work

Sign up to request clarification or add additional context in comments.

Comments

-1
text_message += f'<a href="#{id}" class="follow" data-follow="{id}">{name of user or something}</a>' input_box = driver.find_element(By.CSS_SELECTOR, ".input-message-input.scrollable.scrollable-y.no-scrollbar[data-peer-id]") driver.execute_script(""" var div = arguments[0]; var new_a_tag = arguments[1]; div.innerHTML = div.innerHTML + new_a_tag; """, input_box, text_message) input_box.send_keys(Keys.ENTER) 

try this

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.