How to remove stickers from telegram
python - The telegram bot does not delete stickers from the group
Ask Question
Asked
Modified 5 years, 3 months ago
Viewed 1k times
I create a telegram bot using the Python-Telegram-Bot framework and the Re Module. The bot should delete the stickers the members send to the group, that is, when the word is start
send to the group, it will delete the bot stickers that are sent after the group start
.
My code:
from telegram.ext import Updater, MessageHandler, Filters import re def delete_method(bot, update): mlist=['/start'] for i in mlist: if re. match(i, update, message.text): update.message.delete() def main(): updater = Updater(token='TOKEN') dispatcher = updater.dispatcher dispatcher.add_handler(MessageHandler(Filters.all, delete_method)) updater.start_polling() updater.idle() if __name__ == '__main__': main() # for exit # updater.idle()
But the bot does not work, that is, after sending the word start
of the send to the group, it does not delete the stickers that are sent to the group.
The codes do not give any errors.And the group is a super group, and the bot is admin and it has access to messages!
What do you think is the problem ???
- python
- filter
- python-telegram-bot
2
This line here if re.match(i, update, message.text):
is the problem. You are searching for i
(which has the value /start
) in the update
object. I don't see why this should work.
You need to check if the current message is a sticker. If the message is a sticker, then update.effective_message.sticker
will return a value. Otherwise it will return None
. So you could check for a sticker with this i guess - i didn't test it:
from telegram.ext import Updater, MessageHandler, Filters def delete_sticker(bot, update): if update.effective_message.sticker: update.message.delete if __name__ == '__main__': updater = Updater(token='TOKEN') dispatcher = updater.dispatcher dispatcher.add_handler(MessageHandler(Filters.all, delete_sticker)) updater.start_polling() updater.idle()
0
Sign up or log in
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Post as a guest
Required, but never shown
python 2.
7 - The telegram bot should delete Sticker, Gif, and Voice that are sent to the group;but do not delete themAsked
Modified 5 years, 4 months ago
Viewed 1k times
I built a telegram bot with a python-telegram-bot module.I added the bot to the group and got the bot in the admin group.The bot should be delete when Sticker, Gif or Voice are sent to the group;But the bot does not delete them.bot code:
from telegram.ext import Updater, MessageHandler, Filters def sticker_method(bot, update): bot.delete_sticker(chat_id = update.message.chat_id, sticker_id = update.sticker.chat_id) bot.delete_gif(chat_id = update.message.chat_id, gif_id = update.gif.chat_id) bot.delete_voice(chat_id = update. message.chat_id, voice_id = update.voice.chat_id) def main(): updater = Updater(token='TOKEN') dispatcher = updater.dispatcher dispatcher.add_handler(MessageHandler(Filters.all, sticker_method)) updater.start_polling() updater.idle() if __name__ == '__main__': main() # for exit # updater.idle()
There is no error during execution;But the bot does nothing!
- python-2.7
- python-telegram-bot
There are no delete_sticker
, delete_gif
nor delete_voice
methods in this library. What you are looking for is bot.delete_message()
.
Also you can use some extensive filters, for example Filters.sticker
and Filters.voice
.
More Info (Edited):
For example you can do (with the usage of Filters.sticker
and Message.delete()
):
def delete_sticker_callback(bot, update): update.message.delete() def main(): updater = Updater(token='TOKEN') dispatcher = updater. dispatcher dispatcher.add_handler(MessageHandler(Filters.sticker, delete_sticker_callback)) updater.start_polling() updater.idle() if __name__ == '__main__': main()
2
Sign up or log in
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Post as a guest
Required, but never shown
Frequently asked questions about stickers in Telegram
What are stickers?
Stickers are pictures (stickers) with which you can express your emotions. It's almost like emoticons, only much cooler. Telegram stickers are completely free to use.
Where can I find new stickers for Telegram?
All the best Telegram stickers can be found in the sticker directory. You can also use the built-in Telegram @sticker bot.
It is enough to type @sticker in the message input field and select the emoticon with the emotion you need. The bot will offer you some of the most suitable stickers for this situation to choose from. nine0005
How to create your own set of Telegram stickers?
Everyone can create their own set of stickers. To do this, write to the @stickers bot and follow its instructions.
- 1 step. Type the command
/newpack
and enter the name of your future pack. It can be anything. - 2 step. Now let's start adding stickers. Send the bot a picture, then an emotion that will match it. That's it, your first sticker is already in the set! Then repeat this procedure (smiley picture) until you get bored (or until the pictures run out). The maximum number of stickers in one set is 120 pieces. nine0022
- 3 step. Once you have finished filling out your sticker pack, send the command
/publish
to the bot and enter a short name for the pack (this name will be contained in a link that all your friends can then install this pack for themselves). The name must be written in Latin letters and must not be shorter than four characters. - 4 step. Everything is ready! Now the bot has given you a link to your own set and you can share it with your friends or send it to us in the sticker catalog. nine0022
It may be that the name you want to use is already taken. Then the bot will tell you about it, and you will have to choose a different name.
What are video stickers?
Video stickers are video files saved in a special format that supports transparency. Learn more about video stickers in a special section.
What about animated stickers?
Animated stickers are created in Adobe After Effects using a special plug-in. Read more about this in a separate article. nine0005
The bot does not want to accept my address, what should I do?
The dialing address must be five characters or more and must start with a letter. The first part of the address ( t.me/addstickers
) is not required.
What are the image format requirements?
The file must be in PNG or * WebP format with a transparent background. The image must fit into a 512×512 square (one side is 512 pixels, the other is 512 or less). nine0005
To make your sticker look equally good on any background, we recommend adding a white stroke and shadow to the image, as in this example.
How do I remove/add stickers to my pack?
For any operations with your set, you need to contact the @stickers robot.
To remove a sticker from a set, send the command /delsticker
to the robot and then send the sticker you would like to remove.
To add a new sticker to an already created set, send the command 9 to the robot0020 /addsticker , then send him the link to your pack (to which you want to add the sticker). Well, then according to the old scheme, send a picture to the bot, and then a smiley.
Also, the robot functions allow you to view the download statistics of your set.
How to completely delete a Telegram sticker pack?
To remove a pack, send the command /delpack
to the @stickers bot. Please note that after deletion, the set will remain with those users who have already installed it. New users will not be able to install it. nine0005
How do I change the name of a set?
The set name cannot be changed. This problem can only be solved by creating the set again (already with the desired name).
How many stickers can be in one set?
The maximum number of stickers in one set is 120 pieces.
Why did the link to the Telegram sticker pack stop working?
Recently, there have been more cases when a link to a favorite set suddenly stopped working. Most likely, this set was removed from Telegram at the request of the copyright holders (copyright violation). nine0005
How to transfer rights to view statistics of sticker sets to another user?
Unfortunately not. Only the creator of the set can view statistics, as well as perform any other actions with the set (delete or add stickers).
How to make private stickers?
All sticker packs in Telegram are public. However, if you do not share a link to your set with anyone, then no one else will see it.
How to change the order of stickers in a set? nine0003
To do this, use the command /ordersticker
in the @stickers bot.
How do I link a sticker pack to my group?
You can link a set of stickers in the group settings. This only works in groups with more than 200 people.
How to add or remove stickers in Telegram
Stickers are funny pictures that have replaced the usual emoticons that can be used in any kind of correspondence. With their help, you can convey absolutely any emotions that cannot be expressed using text, and just brighten up communication and cheer up a little is never superfluous. nine0005
The Telegram messenger, like any other similar applications and services, has excellent support for such pictures. They can be installed almost unlimited. In one of our articles (by the way, you can find it here) we wrote how you can create a set of drawings yourself. If you don’t want to go too deep, and you are quite satisfied with the existing sets, then carefully read the instructions in this article. Here we will tell you how to quickly and easily find any picture, how to add stickers to Telegram for later use, and how to remove an unnecessary or unused package. nine0005
How to find and save stickers in Telegram
In order to find and add any new sticker you like to your Telegram, you can use one of the following methods:
- new images, you can easily copy the entire package. What is needed for this? Click on the picture itself, then add it by selecting "Add sticker". The program will upload it to your account, after which it will be displayed in the emoji selection menu. nine0022
- Use the special online catalogue. The largest Russian-language resource at the moment is https://tlgrm.ru/stickers. Select the set you like, click the "ADD TO TELEGRAM" button, and then click the "Install stickers" button in the messenger that opens.
- The easiest and fastest way is using the built-in @sticker bot. In no case should you confuse it with @Stickers, which is intended to create your own sets with images. Inside the Telegram correspondence, enter @sticker and put a space, then insert some kind of emoticon. The bot automatically searches for all available pictures associated with the selected emoji. The entire search takes a matter of seconds. nine0022
How to delete stickers in Telegram
what remove it from there.