Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion assistant/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@

from datetime import datetime

from pytz import timezone as tz
try:
from pytz import timezone as tz
except ImportError:
tz = None
from telethon import Button, events
from telethon.errors.rpcerrorlist import MessageDeleteForbiddenError
from telethon.utils import get_display_name
Expand Down Expand Up @@ -211,6 +214,11 @@ async def setting(event):
@callback("tz", owner=True)
async def timezone_(event):
await event.delete()
if tz is None:
return await event.client.send_message(
event.sender_id,
f"`pytz` is not installed, TimeZone feature is unavailable.\n\nInstall it via `{HNDLR}update` or `{HNDLR}bash pip install pytz`.",
)
pru = event.sender_id
var = "TIMEZONE"
name = "Timezone"
Expand Down
34 changes: 34 additions & 0 deletions plugins/admintools.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,3 +469,37 @@ async def autodelte(ult):
f"Auto Delete Setting is Already same to `{match}`", time=5
)
await ult.eor(f"Auto Delete Status Changed to `{match}` !")


@ultroid_cmd(
pattern=r"kickall( (.*)|$)",
admins_only=True,
fullsudo=True,
require="ban_users",
)
async def kickall_cmd(ult):
"""Kick all non-admin members from the group."""
if ult.is_private:
return await ult.eor("`Use this in a Group.`", time=5)
match = ult.pattern_match.group(1).strip()
confirm = match.lower() == "confirm"
if not confirm:
return await ult.eor(
f"`Are you sure? This will kick ALL non-admin members!\nUse` `{HNDLR}kickall confirm` `to proceed.`",
time=10,
)
xx = await ult.eor("`Starting KickAll...`")
kicked = 0
failed = 0
async for member in ult.client.iter_participants(ult.chat_id):
if member.bot or getattr(member.participant, "admin_rights", None) or getattr(member.participant, "creator", False):
continue
try:
await ult.client.kick_participant(ult.chat_id, member.id)
kicked += 1
await asyncio.sleep(0.5)
except Exception:
failed += 1
await xx.edit(
f"**KickAll Done!**\n**Kicked:** `{kicked}`\n**Failed:** `{failed}`"
)
45 changes: 45 additions & 0 deletions plugins/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,45 @@
from . import HNDLR, LOGS, eor, get_string, udB, ultroid_bot, ultroid_cmd

KeyM = KeyManager("BROADCAST", cast=list)
BlackM = KeyManager("BROADCAST_BLACKLIST", cast=list)


@ultroid_cmd(
pattern=r"addblacklist( (.*)|$)",
allow_sudo=False,
)
async def broadcast_blacklist_add(event):
msgg = event.pattern_match.group(1).strip()
chat_id = int(msgg) if msgg and msgg.lstrip("-").isdigit() else event.chat_id
if BlackM.contains(chat_id):
return await event.eor("`Already in broadcast blacklist.`", time=5)
BlackM.add(chat_id)
await event.eor(f"`Added {chat_id} to broadcast blacklist.`", time=5)


@ultroid_cmd(
pattern=r"remblacklist( (.*)|$)",
allow_sudo=False,
)
async def broadcast_blacklist_rem(event):
msgg = event.pattern_match.group(1).strip()
chat_id = int(msgg) if msgg and msgg.lstrip("-").isdigit() else event.chat_id
if not BlackM.contains(chat_id):
return await event.eor("`Not in broadcast blacklist.`", time=5)
BlackM.remove(chat_id)
await event.eor(f"`Removed {chat_id} from broadcast blacklist.`", time=5)


@ultroid_cmd(
pattern="listblacklist$",
allow_sudo=False,
)
async def broadcast_blacklist_list(event):
bl = BlackM.get()
if not bl:
return await event.eor("`Broadcast blacklist is empty.`", time=5)
msg = "**Broadcast Blacklist:**\n" + "\n".join(f"• `{c}`" for c in bl)
await event.eor(msg)


@ultroid_cmd(
Expand Down Expand Up @@ -147,7 +186,10 @@ async def forw(event):
sent_count = 0
previous_message = await event.get_reply_message()
error_count = 0
blacklist = BlackM.get() or []
for channel in channels:
if channel in blacklist:
continue
try:
await ultroid_bot.forward_messages(channel, previous_message)
sent_count += 1
Expand Down Expand Up @@ -192,7 +234,10 @@ async def sending(event):
if previous_message:
error_count = 0
sent_count = 0
blacklist = BlackM.get() or []
for channel in channels:
if channel in blacklist:
continue
try:
await ultroid_bot.send_message(channel, previous_message)
sent_count += 1
Expand Down
95 changes: 95 additions & 0 deletions plugins/delayspam.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Ultroid - UserBot
# Copyright (C) 2021-2026 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.

"""
✘ Commands Available -

• `{i}delayspam <count> <delay> <message>`
Spam a message `count` times with `delay` seconds between each.
Reply to a message to spam that message instead.

• `{i}stopspam`
Stop an ongoing delayspam.

Examples:
`{i}delayspam 5 2 Hello!` — sends "Hello!" 5 times with 2s delay
`{i}delayspam 10 1` (reply to a message) — forwards replied msg 10 times with 1s delay
"""

import asyncio

from . import HNDLR, eod, get_string, udB, ultroid_bot, ultroid_cmd

_spam_tasks = {}


@ultroid_cmd(pattern=r"delayspam( (.*)|$)")
async def delayspam_cmd(ult):
args = ult.pattern_match.group(1).strip().split(None, 2)
reply = await ult.get_reply_message()

if len(args) < 2:
return await ult.eor(
f"`Usage: {HNDLR}delayspam <count> <delay> [message]\n"
f"Or reply to a message: {HNDLR}delayspam <count> <delay>`",
time=10,
)

try:
count = int(args[0])
delay = float(args[1])
except ValueError:
return await ult.eor("`count and delay must be numbers.`", time=5)

if count > 200:
return await ult.eor("`Max 200 repetitions allowed.`", time=5)
if delay < 0.5:
return await ult.eor("`Minimum delay is 0.5 seconds.`", time=5)

text = args[2] if len(args) > 2 else None
chat_id = ult.chat_id

if not text and not reply:
return await ult.eor(
f"`Provide a message or reply to one.\nUsage: {HNDLR}delayspam <count> <delay> <text>`",
time=8,
)

await ult.delete()

task_key = f"{ult.sender_id}_{chat_id}"
if task_key in _spam_tasks:
_spam_tasks[task_key].cancel()

async def _do_spam():
for i in range(count):
if task_key not in _spam_tasks:
break
try:
if reply:
await ultroid_bot.send_message(
chat_id, reply.text or "", file=reply.media
)
else:
await ultroid_bot.send_message(chat_id, text)
except Exception:
break
await asyncio.sleep(delay)
_spam_tasks.pop(task_key, None)

task = asyncio.get_event_loop().create_task(_do_spam())
_spam_tasks[task_key] = task


@ultroid_cmd(pattern="stopspam$")
async def stopspam_cmd(ult):
task_key = f"{ult.sender_id}_{ult.chat_id}"
if task_key in _spam_tasks:
_spam_tasks.pop(task_key).cancel()
await ult.eor("`Spam stopped.`", time=3)
else:
await ult.eor("`No active spam in this chat.`", time=3)
22 changes: 14 additions & 8 deletions plugins/pdftools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,6 @@
import cv2
import numpy as np

try:
from PIL import Image
except ImportError:
Image = None
LOGS.info(f"{__file__}: PIL not Installed.")
from PyPDF2 import PdfFileMerger, PdfFileReader, PdfFileWriter
from telethon.errors.rpcerrorlist import PhotoSaveFileInvalidError

from pyUltroid.fns.tools import four_point_transform

from . import (
Expand All @@ -54,6 +46,20 @@
ultroid_cmd,
)

try:
from PIL import Image
except ImportError:
Image = None
LOGS.info(f"{__file__}: PIL not Installed.")
try:
from PyPDF2 import PdfReader, PdfWriter, PdfMerger
PdfFileReader = PdfReader
PdfFileWriter = PdfWriter
PdfFileMerger = PdfMerger
except ImportError:
from PyPDF2 import PdfFileMerger, PdfFileReader, PdfFileWriter
from telethon.errors.rpcerrorlist import PhotoSaveFileInvalidError

if not os.path.isdir("pdf"):
os.mkdir("pdf")

Expand Down
Loading
Loading