forked from darkpc1412/AutoDeleteBotV3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.py
More file actions
41 lines (22 loc) · 788 Bytes
/
bot.py
File metadata and controls
41 lines (22 loc) · 788 Bytes
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
from pyrogram import Client, filters
from time import sleep
API_ID = "15428219"
API_HASH = "0042e5b26181a1e95ca40a7f7c51eaa7"
BOT_TOKEN = "5429880614:AAGomxybHKTYLRHNxomJOBsfe6azogCa9S0"
GROUP_ID = "-1001397638909"
# Create the Pyrogram client
app = Client("delete_bot", api_id=API_ID, api_hash=API_HASH, bot_token=BOT_TOKEN)
# Filter to handle incoming messages in the group
@ app.on_message(filters.group & ~filters.edited)
def delete_messages(client, message):
if not message.edited:
# Delete the message
client.delete_messages(chat_id=GROUP_ID, message_ids=message.message_id)
# Start the bot
app.start()
# Run a loop to continuously delete messages every 3 seconds
while app.is_running:
app.idle()
sleep(3)
# Stop the bot gracefully
app.stop()