Added mod_chat_sanitizer for messages deletion

This commit is contained in:
Nikita Tyukalov, ASUS, Linux
2025-11-25 04:55:47 +03:00
parent 6975b817d0
commit 27bfc18c1f
6 changed files with 753 additions and 14 deletions

View File

@@ -8,6 +8,8 @@ import hashlib
import mimetypes
import traceback
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
def pex() -> None:
''' Print last exception '''
traceback.print_exc()
@@ -69,3 +71,27 @@ def rm_glob(path_glob: str) -> None:
pass
except:
pass
def id_to_peer(id: str):
s = id[0]
try:
if s == 'u':
return PeerUser(user_id=int(id[1:]))
elif s == 'c':
return PeerChat(chat_id=int(id[1:]))
elif s == 's':
return PeerChannel(channel_id=int(id[1:]))
else:
return int(id)
except:
return 'me'
def peer_to_id(peer) -> str:
t = type(peer)
if t is PeerUser:
return 'u%s' % peer.user_id
elif t is PeerChat:
return 'c%s' % peer.chat_id
elif t is PeerChannel:
return 's%s' % peer.channel_id
return str(peer)