forked from TeamUltroid/Ultroid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecho.py
95 lines (80 loc) · 2.69 KB
/
echo.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# Ultroid - UserBot
# Copyright (C) 2021 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available
•`{i}addecho <reply to anyone>`
Start Auto Echo message of Replied user.
•`{i}remecho <reply to anyone>`
Turn It off
•`{i}listecho <reply to anyone>`
To Get list.
"""
from pyUltroid.functions.echo_db import *
from telethon.utils import get_display_name
from . import *
@ultroid_cmd(pattern="addecho ?(.*)")
async def echo(e):
r = await e.get_reply_message()
if r:
user = r.sender_id
else:
try:
user = e.text.split()[1]
if user.startswith("@"):
ok = await e.client.get_entity(user)
user = ok.id
else:
user = int(user)
except BaseException:
return await eod(e, "Reply To A user.")
if check_echo(e.chat_id, user):
return await eod(e, "Echo already activated for this user.")
add_echo(e.chat_id, user)
ok = await e.client.get_entity(user)
user = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
await eor(e, f"Activated Echo For {user}.")
@ultroid_cmd(pattern="remecho ?(.*)")
async def rm(e):
r = await e.get_reply_message()
if r:
user = r.sender_id
else:
try:
user = e.text.split()[1]
if user.startswith("@"):
ok = await e.client.get_entity(user)
user = ok.id
else:
user = int(user)
except BaseException:
return await eod(e, "Reply To A User.")
if check_echo(e.chat_id, user):
rem_echo(e.chat_id, user)
ok = await e.client.get_entity(user)
user = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
return await eor(e, f"Deactivated Echo For {user}.")
await eor(e, "Echo not activated for this user")
@ultroid_bot.on(events.NewMessage(incoming=True))
async def okk(e):
if check_echo(e.chat_id, e.sender_id):
try:
ok = await e.client.get_messages(e.chat_id, ids=e.id)
return await e.client.send_message(e.chat_id, ok)
except Exception as er:
LOGS.info(er)
@ultroid_cmd(pattern="listecho$")
async def lstecho(e):
k = list_echo(e.chat_id)
if k:
user = "**Activated Echo For Users:**\n\n"
for x in k:
ok = await e.client.get_entity(int(x))
kk = f"[{get_display_name(ok)}](tg://user?id={ok.id})"
user += "•" + kk + "\n"
await eor(e, user)
else:
await eod(e, "`List is Empty, For echo`")