Telegram : How can show welcome message for new join bot - telegram-bot

I create new bot in telegram bot ,and do steps like here :-
https://core.telegram.org/bots#
But now i need when any new user join in my bot, i need to show him welcome message.
How can do that ?

Use /setdescription and /setabouttext #BotFather commands

You must send these commands to #BotFather
/setdescription
then send your bot id like:
#example_bot
and send you welcome message
Welcome to my bot

You need to implement the /start command in your bot realization - set the welcome message.
And you should describe this command in chat with #BotFather via /setcommands for your bot.
After that when user adds your bot, the /start command fires automatically, and he will see the message you implemented.

Related

How to send message to the user by using telegram id and python_telegram_bot library?

I want to send the message to anybody by using his telegramid and python_telegram_bot library.
I can send the message to me by using below code but if I put other's id then I can not send the message and it says chat not found message.
updater = Updater(mybot_token, use_context=True)
updater.bot.send_message(chat_id = receiver_id, text="welcome")
I am not sure why it is only possible to send the message to me, not the others even though I puth the chat_id as their telegram_id.
Bots can only send messages to users that have already started the bot. See the Telegram Bot docs.

How to avoid Bot repeating command in groups?

I created a new Telegram Bot which maintains a simple list. When I chat with the Bot directly (in PMs) the Bot works as intended.
I created this bot for a group of friends, so I added the bot to the group, and now, whenever I execute a command, the bot responds, but also repeats my command. Is there any way to avoid this behavior?
I am using the python-telegram-bot API and sending messages using update.message.reply_text('My message')
Is this just intended behavior or is there any way to avoid the bot repeating the sent command?
The bot only is replying message, not creating 2 messages.
You should use send_message.
I found the solution. Telegram API understands this as quoting, and is enabled in groups by default, disabled in private chats.
It can be disabled by using:
update.message.reply_text("message", quote=False)

Is it possible to pin a message using Telegram API?

Is it possible to pin a message using the Telegram API? I would like to create a bot to pin messages in a chat group. I was unable to find an specific method to do it in the documentation:
https://core.telegram.org/bots/api
Is there any way to do it?
Thanks.
you should first turn off the group privacy mode of your bot in your BotFather panel.
then, your bot should be the admin of that chat in order to be able to pin messages.
finally, you can use pinChatMessage, unpinChatMessage to do the task.

How to receive messages in group chats using telegram bot api

My telegram bot receives messages sent by user to my bot in private chats but not receives messages sent by users in group chats. Any options/api for getting group chat messages also,.
Talk to #botfather and disable the privacy mode.
Sequence within a BotFather chat:
You: /setprivacy
BotFather: Choose a bot to change group messages settings.
You: #your_name_bot
BotFather: 'Enable' - your bot will only receive messages that either start with the '/' symbol or mention the bot by username.
'Disable' - your bot will receive all messages that people send to groups.
Current status is: ENABLED
You: Disable
BotFather: Success! The new status is: DISABLED. /help
By default A Bot will receive only messages addressed to it by any user directly via posting by /command#YourBot any message you send.
After that it vill be available via getUpdates API call.
In browser it will be:
https://api.telegram.org/botToken/getupdates
Find the related message in output JSON and grab chatId. It will allow you to answer back with:
https://api.telegram.org/botToken/sendmessage?chat_id=123456788&text=My Answer
Make your bot by admin in group.
You can access all avaliable settings from all of your bots by sending /mybots to Botfather. Choose the bot, then Bot Settings and Group Privacy. If its disable (default), you can tap on Turn off.
Now its possible to receive the chat history using GetUpdates. This can be done via HTTP API or the frameworks. For example, in C# (.NET Core) like this:
var bot = new TelegramBotClient(ApiToken);
var updates = bot.GetUpdatesAsync().Result;
foreach(var update in updates) {
Console.WriteLine($"{update.ChannelPost.Date} {update.ChannelPost.Text}");
}
But keep in mind that this feature has some kind of perfect forward secrecy implemented. So you only get messages that were send after group privacy is disabled. As a result, the GetUpdates result is empty until some post was made.
if you added your bot before disable the privacy mode, you should remove the bot from the group and add it again

How to know if user has seen a message sent by my bot in Telegram?

I'm developing a Telegram bot, and I want to know whether a user, that has started a private chat with my bot, has seen a certain message sent by bot, and to know when has he seen it.
Is it possible to do so?
Thank you very much.
That's currently not possible.
I'm using this solution.
Create a channel specially for your bot
Let your robot send message from this channel to users, you can use forward method.
Now you can see how many users have seen your message
Telegram Bot API has limit functionality. There is absolutely no way to get message view count at the time of this comment.
Usually TDLib can be used instead of Telegram Bot. It is Telegram client library. You can use it directly or make it as services for BOT to call.
For example. use TdApi.GetMessage to get the message, and the returned message has field of interactionInfo which contains forwardCount or viewCount.
perhaps this answer help you :
in the end of your message place
link example : yoursite.com\checkvisit.php?id=1234
when user open message link automatic run for telegram ...
you can understand message was read
you must in checkvisit.php set to check db if id exist and not read set it to read
then id in db remove or disable
but this method simple - telegram must add 1 parameter to return this
sorry my english not good
it is not possible yet , you might want to search for Madeline bot