forked from cHAuHaNz/TGUserBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogpms.py
41 lines (35 loc) · 1.26 KB
/
logpms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"""Log PMs
Check https://t.me/tgbeta/3505"""
import asyncio
from telethon import events
from telethon.tl import functions, types
from uniborg.util import admin_cmd
NO_PM_LOG_USERS = []
@borg.on(admin_cmd(incoming=True, func=lambda e: e.is_private))
async def monito_p_m_s(event):
sender = await event.get_sender()
if Config.NC_LOG_P_M_S and not sender.bot:
chat = await event.get_chat()
if chat.id not in NO_PM_LOG_USERS and chat.id != borg.uid:
try:
e = await borg.get_entity(int(Config.PM_LOGGR_BOT_API_ID))
fwd_message = await borg.forward_messages(
e,
event.message,
silent=True
)
except Exception as e:
logger.warn(str(e))
@borg.on(admin_cmd(pattern="nolog ?(.*)"))
async def approve_p_m(event):
if event.fwd_from:
return
reason = event.pattern_match.group(1)
chat = await event.get_chat()
if Config.NC_LOG_P_M_S:
if event.is_private:
if chat.id not in NO_PM_LOG_USERS:
NO_PM_LOG_USERS.append(chat.id)
await event.edit("Won't Log Messages from this chat")
await asyncio.sleep(3)
await event.delete()