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

@@ -3,7 +3,7 @@
import asyncio
from telethon import events
from telethon.tl.types import PeerUser
from telethon.tl.types import PeerUser, PeerChat, PeerChannel
import utils
@@ -25,7 +25,7 @@ def mod_get_mighty() -> bool:
def mod_get_tags() -> None:
''' Get tags used by the mod '''
return ['base']
return ['base', 'base_peerid']
async def mod_new_message(session, event) -> None:
''' Handle new message '''
@@ -35,21 +35,35 @@ async def mod_new_message(session, event) -> None:
# not outgoing - do not process
if not msg.out:
return
# peer must be user
peer = msg.peer_id
if type(peer) is not PeerUser:
return
# get the text
text = msg.message
text = None
try:
text = msg.message
if not text:
return
except:
return
# get args
args = [i for i in text.split(' ') if i][1:]
args = [i for i in text.split(' ') if i]
# cmd and args
cmd = args[0].lower()
args = args[1:]
# no args
if not args:
if cmd == 'base':
if args:
return
response_text = 'tg-utility available mods:'
mods = utils.get_all_mods()
for mod in mods:
response_text += '\n - %s' % mod
response_text += '\n\nmod_basic commands:'
response_text += '\n - base_peerid - get peer ID of current chat'
await event.reply(message=response_text)
elif cmd == 'base_peerid':
if args:
return
peer = msg.peer_id
await event.reply(message=utils.peer_to_id(msg.peer_id))
except:
utils.pex()