-
Notifications
You must be signed in to change notification settings - Fork 22
/
auto_comment.py
38 lines (31 loc) · 1.38 KB
/
auto_comment.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
from contextlib import suppress
from pyrogram import Client, filters, ContinuePropagation
from pyrogram.types import Message
from pyrogram.errors import MsgIdInvalid
from utils.misc import modules_help, prefix
from utils.db import db
@Client.on_edited_message(filters.channel)
async def send_comment(client: Client, message: Message):
enabled = db.get("custom.auto_comment", "enabled", False)
with suppress(MsgIdInvalid):
if enabled:
msg = await client.get_discussion_message(
message.chat.id, message.message_id
)
await msg.reply(db.get("custom.auto_comment", "text"))
raise ContinuePropagation
@Client.on_message(filters.command(["auto_comment", "ac"], prefix) & filters.me)
async def auto_comment(_, message: Message):
if len(message.command) > 1:
comment = message.text.split(maxsplit=1)[1]
db.set("custom.auto_comment", "enabled", True)
db.set("custom.auto_comment", "text", comment)
await message.edit(
f"<b>Auto comment enabled\nComment:</b> <code>{comment}</code>"
)
else:
db.set("custom.auto_comment", "enabled", False)
await message.edit("<b>Auto comment disabled</b>")
modules_help["auto_comment"] = {
"auto_comment [text]*": "enable auto-reply to posts in channels. Running without text equals to disable"
}