I'm looking for a telegram bot that will allow the admins or group moderators to first approve a message before the message is released to the greater group. Admins or moderators should be able to either approve or decline a message sent by a user of a group that way to keep control of messages and content of the group ?
Telegram is not made use of this, I think this is impossible.
You can try allow any message in group, and if admin approved, bot forward it to channel.
What about scrabbling the message posted by the users so when user sends message to group other users can't read it but only admins can read it and have to type password to open and read message ?
Related
Please kindly someone explain me how can the Telegram bot could understand who is sending the command in group chats and respond it with the the unique answer which is just for that user.
Surely in this case security issues should be considered and a user must not send command as another user.
I guess I can use username to send along with command.
Any suggestions...
The Message Object contains two objects apart from other objects:
Chat, message['chat'] which represents the Chat from which the message is coming. In your case the group.
User, message['from'] which represents the user that sent the message/command.
So it's easy to differentiate which user sent the message. And in case of Private chats, both the Chat object and the User Object are same.
i want create telegram bot .
It can join to the group and delete messages in group .
Is that possible a telegram bot can remove messages from group ?
i search and some people say yes it possible , some people say no
Check this link out, it seems the new bot API made it possible with some restrictions:
https://core.telegram.org/bots/api#deletemessage
The following details are from telegram API page:
A message can only be deleted if it was sent less than 48 hours ago.
Bots can delete outgoing messages in groups and supergroups.
Bots granted can_post_messages permissions can delete outgoing messages in channels.
If the bot is an administrator of a group, it can delete any message there.
If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
Returns True on success.
This is now outdated, please see Darkc0d3r's answer
Using the Telegram Bot API? No, there is no such functionality as of now.
However you can if you are using the Telegram API, where you can use the messages.deleteMessages method, which requires you to give it a list of message id's as a parameter.
You can use
bot.DeleteMessageAsync(chatId, messageId)
you should make it in a try catch in case the message doesn't exist anymore or you have a wrong messageId,
messageId is a property which you get in MessageEventArgs.Message,
Note: the chatId should be the Group/Channel chatId and not of the user who sent it, get that in Chat.Id property of MessageEventArgs.Message ...
User1 has a Telegram account and created the Telegram bot Bot1.
User2 has a Telegram account.
How User 2 can work with Bot1? i.e. in teh same way as User1 does it: send commands etc.
How Bot1 can send messages to User2? I.e. report about smth etc
You mean work with BotFather? No.
Each user can access to its own bots using BotFather and you can't access other bots from another accounts. But if you mean work with tokens, then yes you can work with bots that you have their tokens.
Getting last updates from telegram: https://core.telegram.org/bots/api#getupdates
NodeJS library: https://github.com/yagop/node-telegram-bot-api
Okay let's break your questions into parts:
How User 2 can work with Bot1?
When you say work with its kind of relative. There are two assumptions I can
come up with:
(I). It means that User2 wants to send commands from his
telegram app on his mobile device to bot1(bot1 was made by User1), in this
case anyone can send messages (any form of text) and commands (like
/showusers) to any bot even though they were not its creator. Also just a
side note this is from the telegram bot docs
Bots can't initiate conversations with users. A user must either add them to a group or send them a message first. People can use telegram.me/ links or username search to find your bot.
(II). On the other hand work with can mean that I can program how bot1
interacts with its users, e.g if a user sends /ping to the bot reply with a
message pong. In this case only User1 can work with bot1 because he has the
bot token. However if User1 gives his Bot token(its like your credit card
details) to User2 then User2 can program that bot to do anything he wants.
So to answer your question, if you mean my first assumption then User2 only needs telegram installed and the name of Bot1 but if you mean assumption 2 then User2 needs the bot token from User1 to work with it.
How Bot1 can send messages to User2? Every user has a unique chatid that telegram sends to you the first time someone clicks the start button of your bot(actually they send the chatid every time a person uses your bot). All you need to do is to store this chatid in a database or something and then when you want to send the person a message you indicate the chat id. Read about the sendMessage method made available by the API to better understand how to use it.
how to send Send message to the all of bots users?
There is no way to sned message to all ?
what is the method name ?
From Official API FAQ:
How can I message all of my bot's subscribers at once?
Unfortunately, at this moment we don't have methods for sending bulk messages, e.g. notifications. We may add something along these lines in the future. (...)
Obviously, if you store users chat_id, you can send individual message to all users (I use this method).
Navid wants to send message to all subscribers via bot.
If subscribers are more than 100 persons bot will very slow to sending all messages and may doesn't send messages to all.
Navid's question was how we can send message without this problem?
you can send with curl_multi_exec
Currently, a developer would need to implement a special broadcasting function that would send the message to each active user at the time adding a small delay to avoid hitting the rate limit of 30 messages per second (see https://core.telegram.org/bots/faq#how-can-i-message-all-of-my-bot-39s-subscribers-at-once). This would mean that a very popular bot with say 10K active users cannot give timely notification as the last user would get the message about 5 minutes after the first user.
Here is a feature request to ask to add a method in the Bot API to broadcast a message to all its active users at once. You can upvote this feature request. https://bugs.telegram.org/c/8463
I have chatId and want send messages while execute some tasks from java code. I found this explain on telegram "Bots can't initiate conversations with users. A user must either add them to a group or send them a message first. People can use telegram.me/ links or username search to find your bot." But my task works good when I use https request directly from browser. My bot perfectly answer for requests but how I can do this without user request?
I can not truly understand your case!
Anyway, your bot can send a message to a chat ID Only if the user witch blongs to the specified chat ID added your bot (send start to a bot).
and if it happened then send your message with
/sendMessage