Added mod_chat_sanitizer for messages deletion
This commit is contained in:
26
utils.py
26
utils.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user