File size: 3,003 Bytes
78b07ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pyrogram import Client
from pyrogram.types import Message

from Hellbot.core import Symbols

from . import HelpMenu, db, hellbot, on_message


@on_message("echo", allow_stan=True)
async def echo(client: Client, message: Message):
    if message.reply_to_message:
        user = message.reply_to_message.from_user.id
    elif len(message.command) > 1:
        user = (await client.get_users(message.command[1])).id
    else:
        return await hellbot.delete(
            message, "Reply to an user or pass me a user id to start echoing!"
        )

    if await db.is_echo(client.me.id, message.chat.id, user):
        return await hellbot.delete(message, "Echo is already enabled for this user!")

    await db.set_echo(client.me.id, message.chat.id, user)
    await hellbot.delete(message, "Echo enabled for this user!")


@on_message("unecho", allow_stan=True)
async def unecho(client: Client, message: Message):
    if message.reply_to_message:
        user = message.reply_to_message.from_user.id
    elif len(message.command) > 1:
        user = (await client.get_users(message.command[1])).id
    else:
        return await hellbot.delete(
            message, "Reply to an user or pass me a user id to stop echoing!"
        )

    if not await db.is_echo(client.me.id, message.chat.id, user):
        return await hellbot.delete(message, "Echo is already disabled for this user!")

    await db.rm_echo(client.me.id, message.chat.id, user)
    await hellbot.delete(message, "Echo disabled for this user!")


@on_message("listecho", allow_stan=True)
async def listecho(client: Client, message: Message):
    echos = await db.get_all_echo(client.me.id, message.chat.id)
    if not echos:
        return await hellbot.delete(message, "No echos in this chat!")

    text = "**π–«π—‚π—Œπ— π—ˆπ–Ώ π–€π–Όπ—π—ˆ 𝗂𝗇 π—π—π—‚π—Œ 𝖼𝗁𝖺𝗍:**\n\n"
    for echo in echos:
        text += f"    {Symbols.anchor} `{echo}`\n"

    await hellbot.edit(message, text)


@on_message(["resend", "copy"], allow_stan=True)
async def reSend(_, message: Message):
    if message.reply_to_message:
        await message.reply_to_message.copy(
            message.chat.id, reply_to_message_id=message.reply_to_message.id
        )
    await message.delete()


HelpMenu("echo").add(
    "echo",
    "<reply> or <userid>",
    "Echo every message of the replied user in present chat!",
    "echo @ForGo10God",
    "Echo works on text and sticker messages only!",
).add(
    "unecho",
    "<reply> or <userid>",
    "Stop echoing messages of the replied user in present chat!",
    "unecho @ForGo10God",
).add(
    "listecho",
    None,
    "List all the users whose messages are being echoed in present chat!",
    "listecho",
).add(
    "resend",
    "<reply>",
    "Resend the replied message!",
    "resend",
    "An alias of 'copy' is also available!",
).info(
    "Is it Echoing?"
).done()