How to remove a sticker from Telegram sticker set (for every user) - telegram

I created a sticker set by my bot. I added there some junk images. Now I ask myself a question: How to remove a single sticker from Telegram sticker set for every user?

You should use #Stickers Bot, all you need to do is type /delsticker and follow the directions from there. As long as you are the owner of the sticker pack, it shouldn't be a problem.

Default API connection with URL:
https://api.telegram.org/bot <token>/METHOD_NAME
In order for your bot to interact with your sticker pack, you must create it using the createNewStickerSet method (https://core.telegram.org/bots/api#createnewstickerset )
Send the desired sticker to your bot
Use the get Updates method (https://core.telegram.org/bots/api#getupdates).
In the response, you will get a json structure where you can take the file_id
Use deleteStickerFromSet method (https://core.telegram.org/bots/api#deletestickerfromset)
python example
def deleteStickerFromSet(file_id: str):
data = {
'sticker': file_id,
}
r = requests.post('https://api.telegram.org/bot <token>/' + "deleteStickerFromSet", data=data)
Returns True on success.

Related

How to send ElectroNeek RPA bot output to Telegram

I have made a ElectroNeek RPA bot that scouts the web for a particular piece of data and then I wish to send it to my Telegram. Any ideas?
Let's break up the task in two parts.
First, in order to send anything to yourself at telegram you would need to create a telegram bot and find out your telegram ID. A good tutorial on that is here. Not all of it is necessary. Read from the beginning to the words "Every Update object consists of Message objects." (You would need some basic python skills to implement this).
After you are done, you would have two numbers:
bot_token = 'XXXXXXXXXX:AAGs7Rapl-NW00ZoQMs6AP6BfhqvlXXXxXX'
bot_chatID = 'XXXXXXXXX'
Second, you would need to create the HTTP request action in your ElectroNeek flow like so:
The URL property should be a string that is comprised of variables obtained in step one, telegram URL and your message, like so:
'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&text=' + your_variable
where "your_variable" is the variable you would like to send yourself on Telegram.

Telegram bot Delete a sticker set

You can create a new sticker set owned by your bot and the user with createNewStickerSet method. I was wondering if you can delete the sticker set too because I can't find any method specifying that in the wiki
Detete all the stickers out of the pack so it's just a dead pack, it will disappear after about an hour

Get TELEGRAM Channel/Group ID

Let's say, I've joined TELEGRAM group...
I am just a typical member of GROUP (and thus, cant use any bots there.. ?) so, I am unable to find out the way, how to get GROUP ID.
New Update
Just Simply Forward a message from your channel to This Bot: (https://telegram.me/getidsbot)
Update
1: Goto (https://web.telegram.org)
2: Goto your Gorup and Find your link of Gorup(https://web.telegram.org/#/im?p=g154513121)
3: Copy That number after g and put a (-) Before That -154513121
4: Send Your Message to Gorup
bot.sendMessage(-154513121, "Hi")
I Tested Now and Work like a Charm
Node.js:
Try using TelegramBot#getChat():
bot.getChat("#channelusername").then(function(chat) {
// 'chat' is a Chat object
console.log(chat.id);
});
See API getChat() method and Chat object.
Hope that helps.
There is a unofficicl Plus Messenger client for Android users, and you can see ID in group/channel info.
Supergroup and Channel will looks like 1068773197, which is -1001068773197 for bots (with -100 prefix).
If you just want to obtain channel/user ID, forward message to #RawDataBot.
there are lots of ways to do so.
simplest one: download plus messenger which is a fork of telegram. it shows every channel's id in the about page of that channel.
https://play.google.com/store/apps/details?id=org.telegram.plus&hl=en
thanks to #Sean:
Supergroup and Channel will looks like 1068773197, which is -1001068773197 for bots (with -100 prefix).
Above method works for channels, for groups you may use this method:
Just forward a single message from that chat to #RawDataBot. it will reply you with a json data containing chatid.
via code:
If you are a member of a group, you should receive updates from that group when ever there is any activity from that group. The updates will contain a chats list-element from which you can get a Channel which has the following relevant fields:
id: group_id,
title: "the_group_title",
username: "group_username"
As of my experience ,there are two popular libraries,
python-Telethon --->Telegram Client Library(uses api_id,api_hash)
python-Telegram-bot ---->Telegram Bot (uses api token)
There are lot of ways to get the user_id ,group_id,channel_id .
To get the these ids use Telethon client library
from telethon import TelegramClient,sync
api_id="xxx" #get from telegram website
api_hash="yyy" #get from telegram website
client=TelegramClient(session_object,api_id,api_hash)
client.start()
#To get the channel_id,group_id,user_id
for chat in client.get_dialogs():
print('name:{0} ids:{1} is_user:{2} is_channel{3} is_group:{4}'.format(chat.name,chat.id,chat.is_user,chat.is_channel,chat.is_group))
That is all about, it will print name and id of channel,group,user.
Also, it will check wheather the id is belong to channel or group or user
generally, Channel id starts with negrative(eg:-1001109500936) starts with (-100)
group id is normal and starts with negative
user id starts with positve
Another way is to use 'plus messanger app'
To see all the group,channel,user id
Cheers
Another Simple Way,
client=TelegramClient(session,api_id,api_hash)
client.start()
destination_entity_name="Type User(may be bot) or group or channel name"
entity=client.get_entity(destination_entity_name)
print(entity.stringify()) #All paratmeters
print(entity.id) #user(bot also considered as user) or group
That should be obtainable using tg-messenger-cli: https://github.com/vysheng/tg I haven't had time to try it out yet but friend has made some automated messages for his daughter. Should be quite versatile.
After hours spent, I was able to find the ID of GROUPS using CuteGram app.
Open group there, and click "COPY" icon, that opens a folder, and in the address you will see the ID.
Invite your bot to your group
and use ur bot to text /myid
then use the GetUpdates api, you shall have your group ID

How do I add multiple locations on Google Maps via Telegram Bot?

I want to send multiple locations pinned on a single map into telegram-bot, by using send location function. is there a way to send multiple locations to telegram bot? I try and just can send one location to telegram bot.
As I understood you want to send multiple locations to the user so you don't want to put numbers in the SendLocation method. If the locations that need to be sent are some fixed locations you can save them in an array or in a DB and use a loop to send them.
But if they're not fixed you have to send them to the bot first and then force the bot to send to a user or anywhere else.(channel or group) The code below may help you:
//Send the location like: latitude=xxx&longtitude=yyy;
if(update.Message.Text.Contains("latitude") && update.Message.Text.Contains("longtitude"))
{
string latitude = text.Split('&').First();
string longtitude = text.Split('&').Last();
//splites the input text into two parts first part is latitude=xxx and second or last part is longtitude=yyy. because the string is splited based on & sign
float latitue_num = float.Parse(latitude.Split('=').Last());
float longtitude_num = float.Parse(longtitude.Split('=').Last());
//does the same action for "latitude=xxx" and "longtitude=yyy" after that the number xxx is stored in latitude_num and yyy is stored in longtitude_num
var req = new SendLocation(update.Message.Chat.Id, latitue_num, longtitude_num);
await bot.MakeRequestAsync(req);
}
Of course if the number of locations is too big, it's better to use a database and send them to bot from the DB.
And if you want to send the locations from a user to the bot(not from bot to a user) you can use:
if(update.Message.Location != null)
{
.
.
.
//here you can do whatever you want every time bot receives a location. no matter how many locations are sent to the bot the bot will receive them one by one and do the action(s) listed in this method.
}
I hope these will help you, your question was not clear therefore I explained this way.
You Can't.
This method Just send point on the map.
Check Telegram Bot API (https://core.telegram.org/bots/api#sendlocation)

Telegram bot: How to mention user by its id (not its username)

I am creating a telegram bot and using sendMessage method to send the messages.
it is easy to mention user using #username, But how to mention user when they don't have username?
If using the telegram app/web, we can mentioned the user by #integer_id (name), and telegram app/web will convert it into clickable text. integer_id will be generated automatically when we select the user, after typing #.
another background:
I am trying to use forceReply and I want to target user, if they have username, I can easily target them, by mentioning them on the text on sendMessage method.
the bot I am creating is a "quiz" like bot. where each player need to take turn, and the bot is sending them the question, each msg from bot will target different player.
NOTE: I am not disabling the Privacy Mode, I don't want telegram bombing my server with msg I don't need. it was overloading my cheap nasty server. so, disabling it not an option.
I am open for other solution, where the bot can listen to selected player.
thanks.
UPDATE 21/10:
I've spoke to BotSupport for telegram, they said, for now Bots can't mention user without username.
so in my case, I still keep using forceReply, and also, gave a short msg to user which doesn't have username to set it up, so they can get the benefit from forceReply function.
According to official documentation it is possible to mention user by its numerical id with markup:
[inline mention of a user](tg://user?id=123456789)
According to this 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](tg://user?id=123456789)
and you can also use HTML style :
HTML style
To use this mode, pass HTML in the parse_mode field when using sendMessage. The following tags are currently supported:
inline mention of a user
Try this:
#bot.message_handler(func=lambda message: True)
def echo_message(message):
cid = message.chat.id
message_text = message.text
user_id = message.from_user.id
user_name = message.from_user.first_name
mention = "["+user_name+"](tg://user?id="+str(user_id)+")"
bot_msg = f"Hi, {mention}"
if message_text.lower() == "hi":
bot.send_message(cid, bot_msg, parse_mode="Markdown")
For python-telegram-bot you can do the following:
user_id = update.message.from_user['id']
user_name = update.message.from_user['username']
mention = "["+user_name+"](tg://user?id="+str(user_id)+")"
response = f"Hi, {mention}"
context.bot.sendMessage(chat_id=update.message.chat_id,text=response,parse_mode="Markdown")
No, this restriction is related to Telegram's privacy policy and prevention of abuse.
It is possible to mention a user when sending messages (BOT API), but that is not what you need:
[inline mention of a user](tg://user?id=<user_id>)
Links tg://user?id= can be used to mention a user by their id without using a username. Please note:
These links will work only if they are used inside an inline link. For example, they will not work, when used in an inline keyboard button or in a message text.
These mentions are only guaranteed to work if the user has contacted the bot in the past, has sent a callback query to the bot via inline button or is a member in the group where he was mentioned.
https://core.telegram.org/bots/api#markdown-style
you need to link to the text: "tg://user?id=" and id
user_id = 123456XX # id of the user to mention
chat_id = 123456XXX # chat id where to mention
user_name = name of user
await bot.send_message(chat_id, f"<a href='tg://user?id={user_id}'>{user_name}</a>", "HTML")
here is an example:
#dp.message_handler()
async def mention(msg: types.Message):
await msg.answer(f"<a href='tg://user?id={msg.from_user.id}'>{msg.from_user.full_name}</a>", "HTML")
Bots are able to tag users by their ID, they just can't do this using the official HTTP Bot API.
Update: Not necessairy anymore, since Telegram added native Support for this.
If you log into your bots account with MadelineProto (PHP) you can use this 'link' to mention someone by it's ID with parse_mode set to markdown
[Daniil Gentili](mention:#danogentili)

Resources