Files
homelab/userbot/modules/spam.py
T
forust 0506aaaac8 chore(userbot): apply ruff check --fix and ruff format
- ruff check --fix: 210 auto-fixed errors (import sorting, trailing
  whitespace, unused imports, f-string fixups, deprecated annotations)
- ruff format: 104 files reformatted to consistent style
- 268 non-auto-fixable issues remain (S113 requests timeout, etc.)
2026-06-19 12:19:01 +02:00

54 lines
1.8 KiB
Python

# Moon-Userbot - telegram userbot
# Copyright (C) 2020-present Moon Userbot Organization
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import asyncio
from pyrogram import Client, filters
from pyrogram.types import Message
from utils.misc import modules_help, prefix
commands = ['spam', 'statspam', 'slowspam', 'fastspam']
@Client.on_message(filters.command(commands, prefix) & filters.me)
async def spam(client: Client, message: Message):
amount = int(message.command[1])
text = ' '.join(message.command[2:])
cooldown = {'spam': 0.15, 'statspam': 0.1, 'slowspam': 0.9, 'fastspam': 0}
await message.delete()
for _msg in range(amount):
if message.reply_to_message:
sent = await message.reply_to_message.reply(text)
else:
sent = await client.send_message(message.chat.id, text)
if message.command[0] == 'statspam':
await asyncio.sleep(0.1)
await sent.delete()
await asyncio.sleep(cooldown[message.command[0]])
modules_help['spam'] = {
'spam [amount] [text]': 'Start spam',
'statspam [amount] [text]': 'Send and delete',
'fastspam [amount] [text]': 'Start fast spam',
'slowspam [amount] [text]': 'Start slow spam',
}