gurland / telegram-delete-all-messages Goto Github PK
View Code? Open in Web Editor NEWDelete all your messages in groups / supergroups using this python script
License: GNU General Public License v3.0
Delete all your messages in groups / supergroups using this python script
License: GNU General Public License v3.0
Hello I'm having this error when I try to execute the script, any solutions ?
File "cleaner.py", line 72
print(f' {i+1}. {group.title}')
^
SyntaxError: invalid syntax
It would be great to use a command line with args to exclude or include some groups by ID, So people can write a crontab schedule to delete messages during a specified time.
Currently user can enter 0 or negative index of dialog. It's not the expected way of selection and could cause huge problems because deleted messages are not recoverable.
-help
In my telegram chat export, I have all the groups I ever joined, I have no messages in the groups except "xxx joined". I'm unable to delete these messages directly. They appear in the chat export. I want these groups gone. I just want to delete these kind of messages.
Can I remove these joined messages from groups even if I'm not the admin with your tool?
Since there are currently no tests, it's hard to judge whether a new contribution will introduce subtle bugs / break currently supported functionality. It's basically up to the developer and/or the reviewer to manually test the tool in all supported scenarios as best as they can.
I'm working on a test suite with some unit tests and functional tests, which authenticate the API and create new test groups / supergroups, send random messages to those groups, and then delete those messages, and finally clean up and delete the test groups.
This should make testing and reviewing changes much safer.
i get the following message
TypeError: GetDialogs.get_dialogs() got an unexpected keyword argument 'pinned_only'
Just wondering if it's possible to delete messages in a normal group please?
i.e. could chat.type be modified to look for another type of group, and if so do you know what other types there are please?
pyrogram.errors.exceptions.not_acceptable_406.NotAcceptable: [406 Not Acceptable]: [406 UPDATE_APP_TO_LOGIN] (caused by "auth.SendCode")
The search is currently broken for both groups and supergroups:
#26 fixes both issues.
i have pyrogram updated, but after i after i put the hash id, when i put the phone number, the program closes, it dont even send the code, a few months ago, it worked for me
someone knows what to do?
Pyrogram's get_dialogs()
obtains only 100 dialogs.
With Python3 latest version of Pyrogram is installed.
Following lines are related to the old version of Pyrogram and cause error on running script on Ubuntu version 18.04 and later:
from pyrogram.api.functions.messages import Search
from pyrogram.api.types import InputPeerSelf, InputMessagesFilterEmpty
from pyrogram.api.types.messages import ChannelMessages
This code should be used instead
from pyrogram.raw.functions.messages import Search
from pyrogram.raw.types import InputPeerSelf, InputMessagesFilterEmpty
from pyrogram.raw.types.messages import ChannelMessages
Please see the docs.
[client] Sleeping for 24s (required by "messages.GetDialogs")
So I tried to delete messages from a group. But it only removed like first 5000 of them. Manually searching for them in telegram I can see the rest. But script doesn't. It just reports - Found 0 of your messages. Deleting 0 messages with message ID.
Any way to run it deeply or something?
Traceback (most recent call last):
File "/Users/admin/Projects/telegram-delete-all-messages/cleaner.py", line 134, in
deleter.select_groups()
File "/Users/admin/Projects/telegram-delete-all-messages/cleaner.py", line 50, in select_groups
chats = self.get_all_chats()
File "/Users/admin/Projects/telegram-delete-all-messages/cleaner.py", line 40, in get_all_chats
dialogs = app.get_dialogs(pinned_only=True)
File "/Users/admin/.pyenv/versions/3.9.12/lib/python3.9/site-packages/pyrogram/sync.py", line 53, in async_to_sync_wrap
coroutine = function(*args, **kwargs)
TypeError: get_dialogs() got an unexpected keyword argument 'pinned_only'
Endless loop after enter the phone number.
[client] Sleeping for 15s (required by "messages.GetDialogs")
[client] Sleeping for 15s (required by "messages.GetDialogs")
[client] Sleeping for 17s (required by "messages.GetDialogs")
[client] Sleeping for 16s (required by "messages.GetDialogs")
[client] Sleeping for 14s (required by "messages.GetDialogs")
[client] Sleeping for 16s (required by "messages.GetDialogs")
[client] Sleeping for 16s (required by "messages.GetDialogs")
[client] Sleeping for 18s (required by "messages.GetDialogs")
[client] Sleeping for 15s (required by "messages.GetDialogs")
[client] Sleeping for 14s (required by "messages.GetDialogs")
[...]
Someone has experienced that or know how to fix it?
I've got a bot which posts images in my super group and I'm not able to delete all of its stuff, so maybe I can use this tool?
If yes, please explain how.
Thanks
Is it possible to change the last function that deletes messages so that it instead forwards them to another group? Ideally, this would also forward files, images, etc.
With the current implementation it's pretty cumbersome to try and delete all messages at once. How hard would it be to add that as a selectable option where it iterates over each group and deletes the messages automagically?
I believe, sleep_threshold parameter should be added to app.send() method when searching messages, otherwise it dies sometimes with "pyrogram.errors.exceptions.flood_420.FloodWait". Value of 60 seconds seems to work OK.
test results:
[Q]
Found 40835 your messages in selected supergroup
[client] Sleeping for 15s (required by "messages.Search")
[client] Sleeping for 9s (required by "messages.Search")
[client] Sleeping for 3s (required by "messages.Search")
[client] Sleeping for 9s (required by "messages.Search")
Searching messages. OFFSET: 40900
[UQ]
Hi,
Currently the program seems to exit after deletion; in the case a user may want to delete a few groups, perhaps the program can prompt for another group after deleting the first?
Thanks!
Example:
Delete all your messages in
[...]
19. Sci⛷🚠
[...]
22. Sci⛷🚠
[...]
163. Birthday group
164. Birthday group
[...]
170. Friends group
[...]
185. Friends group
186. EP 2016
187. EP 2016
I confirm that I any of that groups has a duplicate with the same name.
Maybe related to #16
$ python cleaner.py
File "cleaner.py", line 55
print(f' {i+1}. {group.title}')
^
SyntaxError: invalid syntax
I ran into above error running in Ubuntu
I didnt know who else to ask but I was wondering if you guys could make a similar python script to remove all members from all of your groups and channels. So you keep your groups but remove everyone else in them.
Getting this error:
Traceback (most recent call last):
File "/Users/bm/telegram-delete-all-messages/cleaner.py", line 5, in
from pyrogram.api.functions.messages import Search
ModuleNotFoundError: No module named 'pyrogram.api'
Tested on Windows 10 CMD, Log:
> install.bat
python -m venv venv
call venv/Scripts/activate.bat
Requirement already satisfied: pyrogram in c:\...\telegram-delete-all-messages-master\venv\lib\site-packages (from -r requirements.txt (line 1)) (1.0.7)
Requirement already satisfied: tgcrypto in c:\...\telegram-delete-all-messages-master\venv\lib\site-packages (from -r requirements.txt (line 2)) (1.2.2)
Requirement already satisfied: async-lru==1.0.2 in c:\...\telegram-delete-all-messages-master\venv\lib\site-packages (from pyrogram->-r requirements.txt (line 1)) (1.0.2)
Requirement already satisfied: pyaes==1.6.1 in c:\...\telegram-delete-all-messages-master\venv\lib\site-packages (from pyrogram->-r requirements.txt (line 1)) (1.6.1)
Requirement already satisfied: pysocks==1.7.1 in c:\...\telegram-delete-all-messages-master\venv\lib\site-packages (from pyrogram->-r requirements.txt (line 1)) (1.7.1)
"Successfully installed requirements!"
> start.bat
call venv/Scripts/activate.bat
Traceback (most recent call last):
File "cleaner.py", line 5, in <module>
from pyrogram.api.functions.messages import Search
ModuleNotFoundError: No module named 'pyrogram.api'
pyrogram.errors.BadMsgNotification: [16] The msg_id is too low, the client time has to be synchronized.
Pyrogram v1.2.9, Copyright (C) 2017-2021 Dan https://github.com/delivrance
Licensed under the terms of the GNU Lesser General Public License v3 or later (LGPLv3+)
Traceback (most recent call last):
File "/home/kali/hack/telegram-delete-all-messages/cleaner.py", line 130, in
deleter.select_groups()
File "/home/kali/hack/telegram-delete-all-messages/cleaner.py", line 50, in select_groups
chats = self.get_all_chats()
File "/home/kali/hack/telegram-delete-all-messages/cleaner.py", line 42, in get_all_chats
dialog_chunk = app.get_dialogs()
File "/home/kali/.local/lib/python3.9/site-packages/pyrogram/sync.py", line 56, in async_to_sync_wrap
return loop.run_until_complete(coroutine)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/kali/.local/lib/python3.9/site-packages/pyrogram/methods/chats/get_dialogs.py", line 96, in get_dialogs
messages[chat_id] = await types.Message._parse(self, message, users, chats)
File "/home/kali/.local/lib/python3.9/site-packages/pyrogram/types/messages_and_media/message.py", line 720, in _parse
parsed_message.reply_to_message = await client.get_messages(
File "/home/kali/.local/lib/python3.9/site-packages/pyrogram/methods/messages/get_messages.py", line 114, in get_messages
r = await self.send(rpc, sleep_threshold=-1)
File "/home/kali/.local/lib/python3.9/site-packages/pyrogram/methods/advanced/send.py", line 77, in send
r = await self.session.send(
File "/home/kali/.local/lib/python3.9/site-packages/pyrogram/session/session.py", line 425, in send
return await self._send(data, timeout=timeout)
File "/home/kali/.local/lib/python3.9/site-packages/pyrogram/session/session.py", line 395, in _send
RPCError.raise_it(result, type(data))
File "/home/kali/.local/lib/python3.9/site-packages/pyrogram/errors/rpc_error.py", line 78, in raise_it
raise getattr(
pyrogram.errors.exceptions.bad_request_400.ChannelPrivate: [400 CHANNEL_PRIVATE]: The channel/supergroup is not accessible (caused by "channels.GetMessages")
Python 3.8.6, all is made as specified in readme.
Would be great if we could just pass an ID to delete the messages from groups you've left.
Add feature of complete messages removal in all groups.
>python3 cleaner.py
Traceback (most recent call last):
File "cleaner.py", line 5, in <module>
from pyrogram.api.functions.messages import Search
ModuleNotFoundError: No module named 'pyrogram.api'
# python3 --version
Python 3.7.3
# pip3 list
Package Version
------------------ -------------
asn1crypto 0.24.0
async-lru 1.0.2
attrs 19.3.0
certifi 2018.8.24
chardet 3.0.4
cloud-init 20.1
configobj 5.0.6
cryptography 2.6.1
entrypoints 0.3
httplib2 0.11.3
idna 2.6
importlib-metadata 1.6.0
Jinja2 2.10
jsonpatch 1.25
jsonpointer 2.0
jsonschema 3.2.0
keyring 17.1.1
keyrings.alt 3.1.1
MarkupSafe 1.1.0
oauthlib 3.1.0
pip 18.1
pyaes 1.6.1
pycrypto 2.6.1
pycurl 7.43.0.2
PyGObject 3.30.4
Pyrogram 1.1.13
pyrsistent 0.16.0
PySimpleSOAP 1.16.2
PySocks 1.7.1
python-apt 1.8.4.3
python-debian 0.1.35
python-debianbts 2.8.2
pyxattr 0.6.1
pyxdg 0.25
PyYAML 3.13
reportbug 7.5.3-deb10u1
requests 2.21.0
SecretStorage 2.3.1
setuptools 40.8.0
six 1.12.0
TgCrypto 1.2.2
urllib3 1.24.1
wheel 0.32.3
youtube-dl 2019.1.17
zipp 3.1.0
Line 12, where API_HASH is being populated, getenv() reads API_ID instead of API_HASH
Traceback (most recent call last):
File "/root/telegram-delete-all-messages/cleaner.py", line 154, in
deleter.select_groups()
File "/root/telegram-delete-all-messages/cleaner.py", line 67, in select_groups
chats = self.get_all_chats()
File "/root/telegram-delete-all-messages/cleaner.py", line 57, in get_all_chats
dialogs = app.get_dialogs(pinned_only=True)
File "/usr/local/lib/python3.9/site-packages/pyrogram/sync.py", line 53, in async_to_sync_wrap
coroutine = function(*args, **kwargs)
TypeError: get_dialogs() got an unexpected keyword argument 'pinned_only'
How to fix it ?
Thks !
for fix this error:
pyrogram.errors.exceptions.flood_420.FloodWait: [420 FLOOD_WAIT_X]: A wait of 21 seconds is required (caused by "messages.Search")
do you change number of count from 100 tu 1000
for i in range(0, messages_count, 1000):
q = self.search_messages()
self.update_ids(q)
self.add_offset += 1000
I have joined lots of chats, so instead of deleting messages of groups one by one, I want to delete all of them at once.
Currently I run a bash shell loop to run the script, but the group number seems changes sometimes. so there are chance that I didn't delete messages in some groups.
Could you add an argument that specific something like -all
for this? or answer ALL
to delete messages in every group?
Some groups are not listed (seems happens when there are too many chats, I got these groups listed by quitting some groups and channels), I want to delete all of messages in every group I joined. To delete them I have to send new messages in these groups and then the python script will list it.
Seems it only list 50 groups at most.
Is it possible to find out all of groups I joined and delete them at once?
This script is currently no longer valid and needs to be re-adapted to the latest version of Pyrogram.
running the script only shows that you have deleted 100 messages. When looking at the telegram group, all the messages disappear but after a while all the messages appear again except 100 messages
I am able to get the script up and running but it does not seem to list all my groups. Namely, the one group I am an admin/owner of.
That is the group I want to clear out and I'm not sure why it's not showing via the API. Any ideas?
Thanks for the good work so far on this!
Edit- This script is able to recognize all of my chats, but is unable to delete messages from the one chat I run. https://github.com/seabasssec/del_my_messages_from_chat
If you see an error UnicodeEncodeError: 'ascii' codec can't encode characters as happened to me on Mac, doing export PYTHONIOENCODING=utf8
may help you.
Sorry, I don't know if it should be as a PR in readme or anything else.
Name: Pyrogram
Version: 2.0.106
Traceback (most recent call last):
File "/root/telegram-delete-all-messages/cleaner.py", line 154, in <module>
deleter.select_groups()
File "/root/telegram-delete-all-messages/cleaner.py", line 67, in select_groups
chats = self.get_all_chats()
File "/root/telegram-delete-all-messages/cleaner.py", line 57, in get_all_chats
dialogs = app.get_dialogs(pinned_only=True)
File "/usr/local/lib/python3.9/site-packages/pyrogram/sync.py", line 53, in async_to_sync_wrap
coroutine = function(*args, **kwargs)
TypeError: get_dialogs() got an unexpected keyword argument 'pinned_only'
Wouldn't Delete all your messages in groups / supergroups with python script.
be more accurate?
Implement ability to work with multiple accounts.
For CLI interactive mode we have to:
For default argument based CLI (should be implemented in #11) simply add argument with name/path to client session file.
Sessions in pyrogram are stored in .session
files which are simply SQlite database files. https://docs.pyrogram.org/topics/storage-engines.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.