mirror of
https://github.com/Xtao-Labs/iShotaBot.git
synced 2024-11-16 04:35:55 +00:00
49 lines
1.3 KiB
Python
49 lines
1.3 KiB
Python
from pyrogram import Client, filters, ContinuePropagation
|
||
from pyrogram.types import Message
|
||
|
||
from init import bot
|
||
|
||
last_msg = {}
|
||
last_repeat_msg = {}
|
||
repeat_count = {}
|
||
|
||
|
||
@bot.on_message(filters.incoming & filters.group)
|
||
async def repeater_handler(client: Client, message: Message):
|
||
global last_msg, last_repeat_msg, repeat_count
|
||
|
||
group_id = message.chat.id
|
||
|
||
try:
|
||
last_msg[group_id]
|
||
except KeyError:
|
||
last_msg[group_id] = ""
|
||
try:
|
||
last_repeat_msg[group_id]
|
||
except KeyError:
|
||
last_repeat_msg[group_id] = ""
|
||
|
||
msg = t_msg = message.text
|
||
if not msg:
|
||
raise ContinuePropagation
|
||
if (
|
||
msg.startswith("/")
|
||
or msg.startswith("!")
|
||
or msg.startswith(",")
|
||
or msg.startswith(",")
|
||
):
|
||
raise ContinuePropagation
|
||
|
||
if msg != last_msg[group_id] or msg == last_repeat_msg[group_id]:
|
||
last_msg[group_id] = msg
|
||
repeat_count[group_id] = 0
|
||
else:
|
||
repeat_count[group_id] += 1
|
||
last_repeat_msg[group_id] = ""
|
||
if repeat_count[group_id] >= 2:
|
||
await client.send_message(group_id, t_msg)
|
||
repeat_count[group_id] = 0
|
||
last_msg[group_id] = ""
|
||
last_repeat_msg[group_id] = msg
|
||
raise ContinuePropagation
|