From 41c35c0e3bf8cae9afd0c7e857aea6da2f1c9220 Mon Sep 17 00:00:00 2001 From: yasirarism Date: Fri, 15 Sep 2023 22:23:36 +0700 Subject: [PATCH] Remove rate limiter since useless and not good --- misskaty/core/decorator/__init__.py | 2 -- misskaty/core/decorator/ratelimiter.py | 48 -------------------------- misskaty/core/ratelimiter_func.py | 46 ------------------------ misskaty/plugins/admin.py | 19 ---------- misskaty/plugins/afk.py | 3 -- misskaty/plugins/auto_approve.py | 3 -- misskaty/plugins/bypass.py | 4 +-- misskaty/plugins/code_tester.py | 36 ------------------- misskaty/plugins/copy_forward.py | 2 -- misskaty/plugins/currency.py | 2 -- misskaty/plugins/download_upload.py | 7 +--- misskaty/plugins/filter_request.py | 9 ----- misskaty/plugins/filters.py | 4 --- misskaty/plugins/fun.py | 13 +++++-- misskaty/plugins/genss.py | 2 -- misskaty/plugins/grup_tools.py | 3 -- misskaty/plugins/imdb_search.py | 7 ---- misskaty/plugins/inkick_user.py | 5 --- misskaty/plugins/inline_search.py | 4 --- misskaty/plugins/json.py | 2 -- misskaty/plugins/media_extractor.py | 4 --- misskaty/plugins/mediainfo.py | 2 -- misskaty/plugins/misc_tools.py | 13 ------- misskaty/plugins/nightmodev2.py | 3 +- misskaty/plugins/notes.py | 5 --- misskaty/plugins/ocr.py | 2 -- misskaty/plugins/paste.py | 7 ---- misskaty/plugins/ping.py | 3 -- misskaty/plugins/pypi_search.py | 4 --- misskaty/plugins/quotly.py | 2 -- misskaty/plugins/sangmata.py | 2 -- misskaty/plugins/sed.py | 2 -- misskaty/plugins/session_generator.py | 3 -- misskaty/plugins/start_help.py | 5 --- misskaty/plugins/stickers.py | 5 --- misskaty/plugins/subscene_dl.py | 5 --- misskaty/plugins/urban_dict.py | 3 -- misskaty/plugins/web_scraper.py | 27 --------------- misskaty/plugins/webss.py | 2 -- misskaty/plugins/ytdl_plugins.py | 9 +---- 40 files changed, 16 insertions(+), 313 deletions(-) delete mode 100644 misskaty/core/decorator/ratelimiter.py delete mode 100644 misskaty/core/ratelimiter_func.py diff --git a/misskaty/core/decorator/__init__.py b/misskaty/core/decorator/__init__.py index 852264de..41a2565d 100644 --- a/misskaty/core/decorator/__init__.py +++ b/misskaty/core/decorator/__init__.py @@ -1,7 +1,6 @@ from .errors import capture_err from .misc import asyncify, new_task from .permissions import adminsOnly, require_admin -from .ratelimiter import ratelimiter __all__ = [ "capture_err", @@ -9,5 +8,4 @@ __all__ = [ "new_task", "adminsOnly", "require_admin", - "ratelimiter", ] diff --git a/misskaty/core/decorator/ratelimiter.py b/misskaty/core/decorator/ratelimiter.py deleted file mode 100644 index bc1e69ab..00000000 --- a/misskaty/core/decorator/ratelimiter.py +++ /dev/null @@ -1,48 +0,0 @@ -from functools import wraps -from typing import Callable, Union - -from cachetools import TTLCache -from pyrogram import Client -from pyrogram.errors import QueryIdInvalid -from pyrogram.types import CallbackQuery, Message - -from ..ratelimiter_func import RateLimiter - -ratelimit = RateLimiter() -# storing spammy user in cache for 1minute before allowing them to use commands again. -warned_users = TTLCache(maxsize=128, ttl=60) -warning_message = "Spam detected! ignoring your all requests for few minutes." - - -def ratelimiter(func: Callable) -> Callable: - """ - Restricts user's from spamming commands or pressing buttons multiple times - using leaky bucket algorithm and pyrate_limiter. - """ - - @wraps(func) - async def decorator(client: Client, update: Union[Message, CallbackQuery]): - userid = update.from_user.id if update.from_user else update.sender_chat.id - is_limited = await ratelimit.acquire(userid) - - if is_limited and userid not in warned_users: - if isinstance(update, Message): - await update.reply_text(warning_message) - warned_users[userid] = 1 - return - - elif isinstance(update, CallbackQuery): - try: - await update.answer(warning_message, show_alert=True) - except QueryIdInvalid: - warned_users[userid] = 1 - return - warned_users[userid] = 1 - return - - elif is_limited and userid in warned_users: - pass - else: - return await func(client, update) - - return decorator diff --git a/misskaty/core/ratelimiter_func.py b/misskaty/core/ratelimiter_func.py deleted file mode 100644 index dd233f5f..00000000 --- a/misskaty/core/ratelimiter_func.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import Union - -from pyrate_limiter import ( - BucketFullException, - Duration, - Limiter, - InMemoryBucket, - Rate, -) - - -class RateLimiter: - """ - Implement rate limit logic using leaky bucket - algorithm, via pyrate_limiter. - (https://pypi.org/project/pyrate-limiter/) - """ - - def __init__(self) -> None: - # 15 requests per minute. - self.minute_rate = Rate(15, Duration.MINUTE) - - # 100 requests per hour - self.hourly_rate = Rate(100, Duration.HOUR) - - # 300 requests per day - self.daily_rate = Rate(300, Duration.DAY) - - self.limiter = Limiter([ - self.minute_rate, - self.hourly_rate, - self.daily_rate - ] - ) - - async def acquire(self, userid: Union[int, str]) -> bool: - """ - Acquire rate limit per userid and return True / False - based on userid ratelimit status. - """ - - try: - self.limiter.try_acquire(userid) - return False - except BucketFullException: - return True diff --git a/misskaty/plugins/admin.py b/misskaty/plugins/admin.py index 3f42c2ee..3a52edac 100644 --- a/misskaty/plugins/admin.py +++ b/misskaty/plugins/admin.py @@ -44,7 +44,6 @@ from misskaty.core.decorator.permissions import ( list_admins, member_permissions, ) -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.core.keyboard import ikb from misskaty.helper.functions import ( extract_user, @@ -164,7 +163,6 @@ async def purge(_, ctx: Message, strings): # Kick members @app.on_cmd(["kick", "dkick"], self_admin=True, group_only=True) @app.adminsOnly("can_restrict_members") -@ratelimiter @use_chat_lang() async def kickFunc(client: Client, ctx: Message, strings) -> "Message": user_id, reason = await extract_user_and_reason(ctx) @@ -197,7 +195,6 @@ async def kickFunc(client: Client, ctx: Message, strings) -> "Message": # Ban/DBan/TBan User @app.on_cmd(["ban", "dban", "tban"], self_admin=True, group_only=True) @app.adminsOnly("can_restrict_members") -@ratelimiter @use_chat_lang() async def banFunc(client, message, strings): user_id, reason = await extract_user_and_reason(message, sender_chat=True) @@ -257,7 +254,6 @@ async def banFunc(client, message, strings): # Unban members @app.on_cmd("unban", self_admin=True, group_only=True) @app.adminsOnly("can_restrict_members") -@ratelimiter @use_chat_lang() async def unban_func(_, message, strings): # we don't need reasons for unban, also, we @@ -289,7 +285,6 @@ async def unban_func(_, message, strings): @app.on_message( filters.user(SUDO) & filters.command("listban", COMMAND_HANDLER) & filters.group ) -@ratelimiter @use_chat_lang() async def list_ban_(c, message, strings): userid, msglink_reason = await extract_user_and_reason(message) @@ -344,7 +339,6 @@ async def list_ban_(c, message, strings): @app.on_message( filters.user(SUDO) & filters.command("listunban", COMMAND_HANDLER) & filters.group ) -@ratelimiter @use_chat_lang() async def list_unban(_, message, strings): userid, msglink = await extract_user_and_reason(message) @@ -382,7 +376,6 @@ async def list_unban(_, message, strings): # Delete messages @app.on_cmd("del", group_only=True) @app.adminsOnly("can_delete_messages") -@ratelimiter @use_chat_lang() async def deleteFunc(_, message, strings): if not message.reply_to_message: @@ -397,7 +390,6 @@ async def deleteFunc(_, message, strings): # Promote Members @app.on_cmd(["promote", "fullpromote"], self_admin=True, group_only=True) @app.adminsOnly("can_promote_members") -@ratelimiter @use_chat_lang() async def promoteFunc(client, message, strings): try: @@ -449,7 +441,6 @@ async def promoteFunc(client, message, strings): # Demote Member @app.on_cmd("demote", self_admin=True, group_only=True) @app.adminsOnly("can_restrict_members") -@ratelimiter @use_chat_lang() async def demote(client, message, strings): user_id = await extract_user(message) @@ -482,7 +473,6 @@ async def demote(client, message, strings): # Pin Messages @app.on_cmd(["pin", "unpin"]) @app.adminsOnly("can_pin_messages") -@ratelimiter @use_chat_lang() async def pin(_, message, strings): if not message.reply_to_message: @@ -510,7 +500,6 @@ async def pin(_, message, strings): # Mute members @app.on_cmd(["mute", "tmute"], self_admin=True, group_only=True) @app.adminsOnly("can_restrict_members") -@ratelimiter @use_chat_lang() async def mute(client, message, strings): try: @@ -561,7 +550,6 @@ async def mute(client, message, strings): # Unmute members @app.on_cmd("unmute", self_admin=True, group_only=True) @app.adminsOnly("can_restrict_members") -@ratelimiter @use_chat_lang() async def unmute(_, message, strings): user_id = await extract_user(message) @@ -577,7 +565,6 @@ async def unmute(_, message, strings): @app.on_cmd(["warn", "dwarn"], self_admin=True, group_only=True) @app.adminsOnly("can_restrict_members") -@ratelimiter @use_chat_lang() async def warn_user(client, message, strings): try: @@ -619,7 +606,6 @@ async def warn_user(client, message, strings): @app.on_callback_query(filters.regex("unwarn_")) -@ratelimiter @use_chat_lang() async def remove_warning(client, cq, strings): from_user = cq.from_user @@ -650,7 +636,6 @@ async def remove_warning(client, cq, strings): @app.on_callback_query(filters.regex("unmute_")) -@ratelimiter @use_chat_lang() async def unmute_user(client, cq, strings): from_user = cq.from_user @@ -671,7 +656,6 @@ async def unmute_user(client, cq, strings): @app.on_callback_query(filters.regex("unban_")) -@ratelimiter @use_chat_lang() async def unban_user(client, cq, strings): from_user = cq.from_user @@ -697,7 +681,6 @@ async def unban_user(client, cq, strings): # Remove Warn @app.on_cmd("rmwarn", self_admin=True, group_only=True) @app.adminsOnly("can_restrict_members") -@ratelimiter @use_chat_lang() async def remove_warnings(_, message, strings): if not message.reply_to_message: @@ -717,7 +700,6 @@ async def remove_warnings(_, message, strings): # Warns @app.on_cmd("warns", group_only=True) -@ratelimiter @use_chat_lang() async def check_warns(_, message, strings): if not message.from_user: @@ -745,7 +727,6 @@ async def check_warns(_, message, strings): & filters.group ) @capture_err -@ratelimiter @use_chat_lang() async def report_user(_, ctx: Message, strings) -> "Message": if not ctx.reply_to_message: diff --git a/misskaty/plugins/afk.py b/misskaty/plugins/afk.py index 675dd1eb..d70c6a10 100644 --- a/misskaty/plugins/afk.py +++ b/misskaty/plugins/afk.py @@ -19,7 +19,6 @@ from pyrogram.types import Message from database.afk_db import add_afk, cleanmode_off, cleanmode_on, is_afk, remove_afk from misskaty import app from misskaty.core.decorator.permissions import adminsOnly -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import get_readable_time2 from misskaty.helper.localization import use_chat_lang from utils import put_cleanmode @@ -33,7 +32,6 @@ Just type something in group to remove AFK Status.""" # Handle set AFK Command @app.on_cmd("afk") -@ratelimiter @use_chat_lang() async def active_afk(_, ctx: Message, strings): if ctx.sender_chat: @@ -207,7 +205,6 @@ async def active_afk(_, ctx: Message, strings): @app.on_cmd("afkdel", group_only=True) -@ratelimiter @adminsOnly("can_change_info") @use_chat_lang() async def afk_state(_, ctx: Message, strings): diff --git a/misskaty/plugins/auto_approve.py b/misskaty/plugins/auto_approve.py index 82503ba9..ee8e99fc 100644 --- a/misskaty/plugins/auto_approve.py +++ b/misskaty/plugins/auto_approve.py @@ -10,7 +10,6 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from misskaty import app from misskaty.core.decorator.errors import capture_err -from misskaty.core.decorator.ratelimiter import ratelimiter # Filters Approve User by bot in channel @YMovieZNew @@ -41,7 +40,6 @@ async def approve_join_chat(c, m): @app.on_callback_query(filters.regex(r"^approve")) -@ratelimiter async def approve_chat(c, q): _, chat = q.data.split("_") try: @@ -58,7 +56,6 @@ async def approve_chat(c, q): @app.on_callback_query(filters.regex(r"^declined")) -@ratelimiter async def decline_chat(c, q): _, chat = q.data.split("_") try: diff --git a/misskaty/plugins/bypass.py b/misskaty/plugins/bypass.py index fa75617b..41101025 100644 --- a/misskaty/plugins/bypass.py +++ b/misskaty/plugins/bypass.py @@ -16,7 +16,6 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message from misskaty import app from misskaty.core.decorator.errors import capture_err -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import get_readable_file_size, fetch, rentry from misskaty.vars import COMMAND_HANDLER @@ -24,6 +23,8 @@ LIST_LINK = """ - Pling and all aliases. - Wetransfer - Other link soon... + +This feature is deprecated.. """ __MODULE__ = "Bypass" @@ -94,7 +95,6 @@ def wetransfer_bypass(url: str) -> str: @app.on_message(filters.command(["directurl"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def bypass(_, ctx: Message): if len(ctx.command) == 1: return await ctx.reply_msg( diff --git a/misskaty/plugins/code_tester.py b/misskaty/plugins/code_tester.py index 19d16ba0..5ddcb6df 100644 --- a/misskaty/plugins/code_tester.py +++ b/misskaty/plugins/code_tester.py @@ -3,7 +3,6 @@ from pyrogram import enums, filters from pyrogram.errors import MessageTooLong from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.tools import rentry from misskaty.vars import COMMAND_HANDLER @@ -75,7 +74,6 @@ async def glot(lang, langcode, code): @app.on_message(filters.command(["codelist"], COMMAND_HANDLER)) -@ratelimiter async def list_lang(_, message): daftarlang = await listcode() list_ = "".join(f"~> {i['name']}\n" for i in daftarlang) @@ -86,7 +84,6 @@ async def list_lang(_, message): @app.on_message(filters.command(["assembly"], "!")) @app.on_edited_message(filters.command(["assembly"], "!")) -@ratelimiter async def assembly(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -104,7 +101,6 @@ async def assembly(_, message): @app.on_message(filters.command(["ats"], "!")) @app.on_edited_message(filters.command(["ats"], "!")) -@ratelimiter async def ats(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -122,7 +118,6 @@ async def ats(_, message): @app.on_message(filters.command(["bash"], "!")) @app.on_edited_message(filters.command(["bash"], "!")) -@ratelimiter async def bash(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -140,7 +135,6 @@ async def bash(_, message): @app.on_message(filters.command(["c"], "!")) @app.on_edited_message(filters.command(["c"], "!")) -@ratelimiter async def c(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -158,7 +152,6 @@ async def c(_, message): @app.on_message(filters.command(["clojure"], "!")) @app.on_edited_message(filters.command(["clojure"], "!")) -@ratelimiter async def clojure(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -176,7 +169,6 @@ async def clojure(_, message): @app.on_message(filters.command(["cobol"], "!")) @app.on_edited_message(filters.command(["cobol"], "!")) -@ratelimiter async def cobol(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -194,7 +186,6 @@ async def cobol(_, message): @app.on_message(filters.command(["coffeescript"], "!")) @app.on_edited_message(filters.command(["coffeescript"], "!")) -@ratelimiter async def coffeescript(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -212,7 +203,6 @@ async def coffeescript(_, message): @app.on_message(filters.command(["cpp"], "!")) @app.on_edited_message(filters.command(["cpp"], "!")) -@ratelimiter async def cpp(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -230,7 +220,6 @@ async def cpp(_, message): @app.on_message(filters.command(["crystal"], "!")) @app.on_edited_message(filters.command(["crystal"], "!")) -@ratelimiter async def crystal(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -248,7 +237,6 @@ async def crystal(_, message): @app.on_message(filters.command(["csharp"], "!")) @app.on_edited_message(filters.command(["csharp"], "!")) -@ratelimiter async def csharp(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -266,7 +254,6 @@ async def csharp(_, message): @app.on_message(filters.command(["d"], "!")) @app.on_edited_message(filters.command(["d"], "!")) -@ratelimiter async def d(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -284,7 +271,6 @@ async def d(_, message): @app.on_message(filters.command(["elixir"], "!")) @app.on_edited_message(filters.command(["elixir"], "!")) -@ratelimiter async def elixir(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -319,7 +305,6 @@ async def elm(_, message): @app.on_message(filters.command(["erlang"], "!")) @app.on_edited_message(filters.command(["erlang"], "!")) -@ratelimiter async def erlang(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -337,7 +322,6 @@ async def erlang(_, message): @app.on_message(filters.command(["fsharp"], "!")) @app.on_edited_message(filters.command(["fsharp"], "!")) -@ratelimiter async def fsharp(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -355,7 +339,6 @@ async def fsharp(_, message): @app.on_message(filters.command(["go"], "!")) @app.on_edited_message(filters.command(["go"], "!")) -@ratelimiter async def go(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -373,7 +356,6 @@ async def go(_, message): @app.on_message(filters.command(["groovy"], "!")) @app.on_edited_message(filters.command(["groovy"], "!")) -@ratelimiter async def groovy(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -391,7 +373,6 @@ async def groovy(_, message): @app.on_message(filters.command(["haskell"], "!")) @app.on_edited_message(filters.command(["haskell"], "!")) -@ratelimiter async def haskell(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -409,7 +390,6 @@ async def haskell(_, message): @app.on_message(filters.command(["idris"], "!")) @app.on_edited_message(filters.command(["idris"], "!")) -@ratelimiter async def idris(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -427,7 +407,6 @@ async def idris(_, message): @app.on_message(filters.command(["java"], "!")) @app.on_edited_message(filters.command(["java"], "!")) -@ratelimiter async def java(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -445,7 +424,6 @@ async def java(_, message): @app.on_message(filters.command(["javascript"], "!")) @app.on_edited_message(filters.command(["javascript"], "!")) -@ratelimiter async def javascript(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -463,7 +441,6 @@ async def javascript(_, message): @app.on_message(filters.command(["julia"], "!")) @app.on_edited_message(filters.command(["julia"], "!")) -@ratelimiter async def julia(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -481,7 +458,6 @@ async def julia(_, message): @app.on_message(filters.command(["kotlin"], "!")) @app.on_edited_message(filters.command(["kotlin"], "!")) -@ratelimiter async def kotlin(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -499,7 +475,6 @@ async def kotlin(_, message): @app.on_message(filters.command(["lua"], "!")) @app.on_edited_message(filters.command(["lua"], "!")) -@ratelimiter async def lua(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -517,7 +492,6 @@ async def lua(_, message): @app.on_message(filters.command(["mercury"], "!")) @app.on_edited_message(filters.command(["mercury"], "!")) -@ratelimiter async def mercury(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -535,7 +509,6 @@ async def mercury(_, message): @app.on_message(filters.command(["nim"], "!")) @app.on_edited_message(filters.command(["nim"], "!")) -@ratelimiter async def nim(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -553,7 +526,6 @@ async def nim(_, message): @app.on_message(filters.command(["nix"], "!")) @app.on_edited_message(filters.command(["nix"], "!")) -@ratelimiter async def nix(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -571,7 +543,6 @@ async def nix(_, message): @app.on_message(filters.command(["ocaml"], "!")) @app.on_edited_message(filters.command(["ocaml"], "!")) -@ratelimiter async def ocaml(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -589,7 +560,6 @@ async def ocaml(_, message): @app.on_message(filters.command(["perl"], "!")) @app.on_edited_message(filters.command(["perl"], "!")) -@ratelimiter async def perl(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -624,7 +594,6 @@ async def php(_, message): @app.on_message(filters.command(["python"], "!")) @app.on_edited_message(filters.command(["python"], "!")) -@ratelimiter async def python(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -642,7 +611,6 @@ async def python(_, message): @app.on_message(filters.command(["raku"], "!")) @app.on_edited_message(filters.command(["raku"], "!")) -@ratelimiter async def raku(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -660,7 +628,6 @@ async def raku(_, message): @app.on_message(filters.command(["ruby"], "!")) @app.on_edited_message(filters.command(["ruby"], "!")) -@ratelimiter async def ruby(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -678,7 +645,6 @@ async def ruby(_, message): @app.on_message(filters.command(["rust"], "!")) @app.on_edited_message(filters.command(["rust"], "!")) -@ratelimiter async def rust(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -696,7 +662,6 @@ async def rust(_, message): @app.on_message(filters.command(["scala"], "!")) @app.on_edited_message(filters.command(["scala"], "!")) -@ratelimiter async def scala(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") @@ -731,7 +696,6 @@ async def swift(_, message): @app.on_message(filters.command(["typescript"], "!")) @app.on_edited_message(filters.command(["typescript"], "!")) -@ratelimiter async def typescript(_, message): if len(message.command) < 2: return await message.reply("Please enter the code you want to run.") diff --git a/misskaty/plugins/copy_forward.py b/misskaty/plugins/copy_forward.py index d80d23cc..47f4c7e2 100644 --- a/misskaty/plugins/copy_forward.py +++ b/misskaty/plugins/copy_forward.py @@ -4,12 +4,10 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from misskaty import BOT_USERNAME, app from misskaty.core.decorator.errors import capture_err -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.vars import COMMAND_HANDLER @app.on_message(filters.command(["copy"], COMMAND_HANDLER)) -@ratelimiter async def copymsg(_, message): if len(message.command) == 1: if not message.reply_to_message: diff --git a/misskaty/plugins/currency.py b/misskaty/plugins/currency.py index 6f7eac23..cd01e785 100644 --- a/misskaty/plugins/currency.py +++ b/misskaty/plugins/currency.py @@ -7,7 +7,6 @@ import logging from pyrogram.types import Message from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.http import fetch from misskaty.vars import CURRENCY_API @@ -20,7 +19,6 @@ LOGGER = logging.getLogger("MissKaty") @app.on_cmd("currency") -@ratelimiter async def currency(_, ctx: Message): if CURRENCY_API is None: return await ctx.reply_msg( diff --git a/misskaty/plugins/download_upload.py b/misskaty/plugins/download_upload.py index 19c7e0ac..c1de743f 100644 --- a/misskaty/plugins/download_upload.py +++ b/misskaty/plugins/download_upload.py @@ -21,7 +21,6 @@ from pySmartDL import SmartDL from misskaty import app from misskaty.core.decorator import capture_err, new_task -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.http import fetch from misskaty.helper.pyro_progress import humanbytes, progress_for_pyrogram from misskaty.vars import COMMAND_HANDLER, SUDO @@ -43,7 +42,6 @@ __HELP__ = """ @app.on_message(filters.command(["anon"], COMMAND_HANDLER)) -@ratelimiter async def upload(bot, message): if not message.reply_to_message: return await message.reply("Please reply to media file.") @@ -176,7 +174,6 @@ async def download(client, message): @app.on_message(filters.command(["instadl"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def instadl(_, message): if len(message.command) == 1: return await message.reply( @@ -217,8 +214,7 @@ async def instadl(_, message): @app.on_message(filters.command(["twitterdl"], COMMAND_HANDLER)) @capture_err -@ratelimiter -async def twitter(_, message): +async def twitterdl(_, message): if len(message.command) == 1: return await message.reply( f"Use command /{message.command[0]} [link] to download Twitter video." @@ -270,7 +266,6 @@ async def twitter(_, message): @app.on_message(filters.command(["tiktokdl"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def tiktokdl(_, message): if len(message.command) == 1: return await message.reply( diff --git a/misskaty/plugins/filter_request.py b/misskaty/plugins/filter_request.py index 03e92d0f..a21e3da1 100644 --- a/misskaty/plugins/filter_request.py +++ b/misskaty/plugins/filter_request.py @@ -14,7 +14,6 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from misskaty import app from misskaty.core.decorator.errors import capture_err from misskaty.core.decorator.permissions import admins_in_chat -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.time_gap import check_time_gap from utils import temp @@ -164,7 +163,6 @@ async def thankregex(_, message): @app.on_callback_query(filters.regex(r"^donereq")) -@ratelimiter async def callbackreq(c, q): try: user = await c.get_chat_member(-1001201566570, q.from_user.id) @@ -221,7 +219,6 @@ async def callbackreq(c, q): @app.on_callback_query(filters.regex(r"^dahada")) -@ratelimiter async def callbackreqada(c, q): try: user = await c.get_chat_member(-1001201566570, q.from_user.id) @@ -280,7 +277,6 @@ async def callbackreqada(c, q): @app.on_callback_query(filters.regex(r"^rejectreq")) -@ratelimiter async def callbackreject(c, q): try: user = await c.get_chat_member(-1001201566570, q.from_user.id) @@ -337,7 +333,6 @@ async def callbackreject(c, q): @app.on_callback_query(filters.regex(r"^unavailablereq")) -@ratelimiter async def callbackunav(c, q): try: user = await c.get_chat_member(-1001201566570, q.from_user.id) @@ -402,7 +397,6 @@ async def callbackunav(c, q): @app.on_callback_query(filters.regex(r"^reqcompl$")) -@ratelimiter async def callbackaft_done(_, q): await q.answer( "Request ini sudah terselesaikan đŸĨŗ, silahkan cek di channel atau grup yaa..", @@ -412,7 +406,6 @@ async def callbackaft_done(_, q): @app.on_callback_query(filters.regex(r"^reqreject$")) -@ratelimiter async def callbackaft_rej(_, q): await q.answer( "Request ini ditolak 💔, silahkan cek rules grup yaa.", @@ -422,7 +415,6 @@ async def callbackaft_rej(_, q): @app.on_callback_query(filters.regex(r"^requnav$")) -@ratelimiter async def callbackaft_unav(_, q): await q.answer( "Request ini tidak tersedia â˜šī¸, mungkin filmnya belum rilis atau memang tidak tersedia versi digital.", @@ -432,7 +424,6 @@ async def callbackaft_unav(_, q): @app.on_callback_query(filters.regex(r"^reqavailable$")) -@ratelimiter async def callbackaft_dahada(_, q): await q.answer( "Request ini sudah ada, silahkan cari 🔍 di channelnya yaa 😉..", show_alert=True diff --git a/misskaty/plugins/filters.py b/misskaty/plugins/filters.py index 693bacdf..d8f32ac5 100644 --- a/misskaty/plugins/filters.py +++ b/misskaty/plugins/filters.py @@ -34,7 +34,6 @@ from database.filters_db import ( from misskaty import app from misskaty.core.decorator.errors import capture_err from misskaty.core.decorator.permissions import adminsOnly -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.core.keyboard import ikb from misskaty.helper.functions import extract_text_and_keyb @@ -49,7 +48,6 @@ You can use markdown or html to save text too. @app.on_message(filters.command(["addfilter", "filter"]) & ~filters.private) @adminsOnly("can_change_info") -@ratelimiter async def save_filters(_, m): if len(m.command) == 1 or not m.reply_to_message: return await m.reply_msg( @@ -78,7 +76,6 @@ async def save_filters(_, m): @app.on_message(filters.command("filters") & ~filters.private) @capture_err -@ratelimiter async def get_filterss(_, m): _filters = await get_filters_names(m.chat.id) if not _filters: @@ -92,7 +89,6 @@ async def get_filterss(_, m): @app.on_message(filters.command(["stop", "stopfilter"]) & ~filters.private) @adminsOnly("can_change_info") -@ratelimiter async def del_filter(_, m): if len(m.command) < 2: return await m.reply_msg("**Usage:**\n__/stopfilter [FILTER_NAME]__", del_in=6) diff --git a/misskaty/plugins/fun.py b/misskaty/plugins/fun.py index c33dd249..6fbdeb11 100644 --- a/misskaty/plugins/fun.py +++ b/misskaty/plugins/fun.py @@ -7,7 +7,6 @@ from pyrogram import filters from misskaty import app from misskaty.core.decorator.errors import capture_err -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.localization import use_chat_lang from misskaty.vars import COMMAND_HANDLER @@ -150,7 +149,6 @@ async def draw_meme_text(image_path, text): @app.on_message(filters.command(["mmf"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def memify(_, message): if message.reply_to_message and ( message.reply_to_message.sticker or message.reply_to_message.photo @@ -184,3 +182,14 @@ async def memify(_, message): async def dice(c, m, strings): dices = await c.send_dice(m.chat.id, reply_to_message_id=m.id) await dices.reply_msg(strings("result").format(number=dices.dice.value), quote=True) + + +@app.on_message(filters.command(["beri"], COMMAND_HANDLER)) +async def beriharapan(c, m): + reply = m.reply_to_message + if not reply and m.command == 1: + return m.reply("Harap berikan kalimat yang ingin diberi pada seseorang") + pesan = m.text.split(" ", 1)[1] + reply_name = reply.from_user.mention if reply.from_user else reply.sender_chat.title + sender_name = m.from_user.mention if m.from_user else m.sender_chat.title + await m.reply(f"{sender_name} memberikan {pesan} pada {reply_name}") \ No newline at end of file diff --git a/misskaty/plugins/genss.py b/misskaty/plugins/genss.py index a0db2412..20d228fc 100644 --- a/misskaty/plugins/genss.py +++ b/misskaty/plugins/genss.py @@ -19,7 +19,6 @@ from pyrogram.types import Message from pySmartDL import SmartDL from misskaty import app -from misskaty.core.decorator import new_task, ratelimiter from misskaty.helper import is_url, progress_for_pyrogram, take_ss from misskaty.helper.localization import use_chat_lang from misskaty.helper.pyro_progress import humanbytes @@ -34,7 +33,6 @@ __HELP__ = """" @app.on_cmd("genss") -@ratelimiter @new_task @use_chat_lang() async def genss(self: Client, ctx: Message, strings): diff --git a/misskaty/plugins/grup_tools.py b/misskaty/plugins/grup_tools.py index 8918787f..1b875284 100644 --- a/misskaty/plugins/grup_tools.py +++ b/misskaty/plugins/grup_tools.py @@ -17,7 +17,6 @@ from pyrogram.types import ChatMemberUpdated, InlineKeyboardButton, InlineKeyboa from database.users_chats_db import db from misskaty import BOT_USERNAME, app from misskaty.core.decorator import asyncify, capture_err -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import fetch, use_chat_lang from misskaty.vars import COMMAND_HANDLER, SUDO, SUPPORT_CHAT from utils import temp @@ -265,7 +264,6 @@ async def gen_invite(bot, message): @app.on_message(filters.command(["adminlist"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def adminlist(_, message): if message.chat.type == enums.ChatType.PRIVATE: return await message.reply("Perintah ini hanya untuk grup") @@ -288,7 +286,6 @@ async def adminlist(_, message): @app.on_message(filters.command(["kickme"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def kickme(_, message): reason = None if len(message.text.split()) >= 2: diff --git a/misskaty/plugins/imdb_search.py b/misskaty/plugins/imdb_search.py index d56f4e9e..2ba1c77c 100644 --- a/misskaty/plugins/imdb_search.py +++ b/misskaty/plugins/imdb_search.py @@ -30,7 +30,6 @@ from pyrogram.types import ( from database.imdb_db import add_imdbset, is_imdbset, remove_imdbset from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import GENRES_EMOJI, Cache, fetch, get_random_string, search_jw from utils import demoji @@ -40,7 +39,6 @@ LIST_CARI = Cache(filename="imdb_cache.db", path="cache", in_memory=False) # IMDB Choose Language @app.on_cmd("imdb") -@ratelimiter async def imdb_choose(_, ctx: Message): if len(ctx.command) == 1: return await ctx.reply_msg( @@ -76,7 +74,6 @@ async def imdb_choose(_, ctx: Message): @app.on_cb("imdbset") -@ratelimiter async def imdblangset(_, query: CallbackQuery): _, uid = query.data.split("#") if query.from_user.id != int(uid): @@ -101,7 +98,6 @@ async def imdblangset(_, query: CallbackQuery): @app.on_cb("setimdb") -@ratelimiter async def imdbsetlang(_, query: CallbackQuery): _, lang, uid = query.data.split("#") if query.from_user.id != int(uid): @@ -246,7 +242,6 @@ async def imdb_search_en(kueri, message): @app.on_cb("imdbcari") -@ratelimiter async def imdbcari(_, query: CallbackQuery): BTN = [] _, lang, msg, uid = query.data.split("#") @@ -364,7 +359,6 @@ async def imdbcari(_, query: CallbackQuery): @app.on_cb("imdbres_id") -@ratelimiter async def imdb_id_callback(self: Client, query: CallbackQuery): i, userid, movie = query.data.split("#") if query.from_user.id != int(userid): @@ -523,7 +517,6 @@ async def imdb_id_callback(self: Client, query: CallbackQuery): @app.on_cb("imdbres_en") -@ratelimiter async def imdb_en_callback(self: Client, query: CallbackQuery): i, userid, movie = query.data.split("#") if query.from_user.id != int(userid): diff --git a/misskaty/plugins/inkick_user.py b/misskaty/plugins/inkick_user.py index 8666621e..3973b680 100644 --- a/misskaty/plugins/inkick_user.py +++ b/misskaty/plugins/inkick_user.py @@ -10,7 +10,6 @@ from pyrogram.errors.exceptions.bad_request_400 import ( from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.vars import COMMAND_HANDLER __MODULE__ = "Inkick" @@ -23,7 +22,6 @@ __HELP__ = """" @app.on_message( filters.incoming & ~filters.private & filters.command(["inkick"], COMMAND_HANDLER) ) -@ratelimiter @app.adminsOnly("can_restrict_members") async def inkick(_, message): if message.sender_chat: @@ -81,7 +79,6 @@ async def inkick(_, message): @app.on_message( filters.incoming & ~filters.private & filters.command(["uname"], COMMAND_HANDLER) ) -@ratelimiter @app.adminsOnly("can_restrict_members") async def uname(_, message): if message.sender_chat: @@ -132,7 +129,6 @@ async def uname(_, message): & ~filters.private & filters.command(["ban_ghosts"], COMMAND_HANDLER) ) -@ratelimiter @app.adminsOnly("can_restrict_members") async def rm_delacc(_, message): if message.sender_chat: @@ -178,7 +174,6 @@ async def rm_delacc(_, message): @app.on_message( filters.incoming & ~filters.private & filters.command(["instatus"], COMMAND_HANDLER) ) -@ratelimiter @app.adminsOnly("can_restrict_members") async def instatus(client, message): if message.sender_chat: diff --git a/misskaty/plugins/inline_search.py b/misskaty/plugins/inline_search.py index c4d32eb6..2d0ac648 100644 --- a/misskaty/plugins/inline_search.py +++ b/misskaty/plugins/inline_search.py @@ -26,7 +26,6 @@ from pyrogram.types import ( ) from misskaty import BOT_USERNAME, app, user -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import GENRES_EMOJI, fetch, post_to_telegraph, search_jw from misskaty.plugins.dev import shell_exec from misskaty.vars import USER_SESSION @@ -560,7 +559,6 @@ async def inline_menu(self, inline_query: InlineQuery): @app.on_callback_query(filters.regex(r"prvtmsg\((.+)\)")) -@ratelimiter async def prvt_msg(_, c_q): msg_id = str(c_q.matches[0].group(1)) @@ -577,7 +575,6 @@ async def prvt_msg(_, c_q): @app.on_callback_query(filters.regex(r"destroy\((.+)\)")) -@ratelimiter async def destroy_msg(_, c_q): msg_id = str(c_q.matches[0].group(1)) @@ -596,7 +593,6 @@ async def destroy_msg(_, c_q): @app.on_callback_query(filters.regex("^imdbinl#")) -@ratelimiter async def imdb_inl(_, query): i, cbuser, movie = query.data.split("#") if cbuser == f"{query.from_user.id}": diff --git a/misskaty/plugins/json.py b/misskaty/plugins/json.py index aa47eaec..eff4e57f 100644 --- a/misskaty/plugins/json.py +++ b/misskaty/plugins/json.py @@ -10,12 +10,10 @@ import os from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter # View Structure Telegram Message As JSON @app.on_cmd("json") -@ratelimiter async def jsonify(_, message: Message): the_real_message = None reply_to_id = None diff --git a/misskaty/plugins/media_extractor.py b/misskaty/plugins/media_extractor.py index 209c0452..2b7b085e 100644 --- a/misskaty/plugins/media_extractor.py +++ b/misskaty/plugins/media_extractor.py @@ -22,7 +22,6 @@ from pyrogram.types import ( from misskaty import app from misskaty.core.decorator.errors import capture_err -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.core.misskaty_patch.listen.listen import ListenerTimeout from misskaty.helper.human_read import get_readable_time from misskaty.helper.localization import use_chat_lang @@ -72,7 +71,6 @@ def get_subname(lang, url, ext): @app.on_message(filters.command(["ceksub", "extractmedia"], COMMAND_HANDLER)) -@ratelimiter @use_chat_lang() async def ceksub(_, ctx: Message, strings): if len(ctx.command) == 1: @@ -128,7 +126,6 @@ async def ceksub(_, ctx: Message, strings): @app.on_message(filters.command(["converttosrt", "converttoass"], COMMAND_HANDLER)) @capture_err -@ratelimiter @use_chat_lang() async def convertsrt(self: Client, ctx: Message, strings): reply = ctx.reply_to_message @@ -168,7 +165,6 @@ async def convertsrt(self: Client, ctx: Message, strings): @app.on_callback_query(filters.regex(r"^streamextract#")) -@ratelimiter @use_chat_lang() async def stream_extract(self: Client, update: CallbackQuery, strings): cb_data = update.data diff --git a/misskaty/plugins/mediainfo.py b/misskaty/plugins/mediainfo.py index 1a51bd3e..dedb5e41 100644 --- a/misskaty/plugins/mediainfo.py +++ b/misskaty/plugins/mediainfo.py @@ -15,7 +15,6 @@ from pyrogram.file_id import FileId from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import post_to_telegraph, progress_for_pyrogram, runcmd from misskaty.helper.localization import use_chat_lang from misskaty.helper.mediainfo_paste import mediainfo_paste @@ -24,7 +23,6 @@ from utils import get_file_id @app.on_message(filters.command(["mediainfo"], COMMAND_HANDLER)) -@ratelimiter @use_chat_lang() async def mediainfo(_, ctx: Message, strings): if not ctx.from_user: diff --git a/misskaty/plugins/misc_tools.py b/misskaty/plugins/misc_tools.py index 49327bb4..39342d33 100644 --- a/misskaty/plugins/misc_tools.py +++ b/misskaty/plugins/misc_tools.py @@ -35,7 +35,6 @@ from pyrogram.types import ( from misskaty import BOT_USERNAME, app from misskaty.core.decorator.errors import capture_err -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.http import fetch from misskaty.helper.tools import rentry from misskaty.vars import COMMAND_HANDLER @@ -125,7 +124,6 @@ async def carbon_make(self: Client, ctx: Message): @app.on_message(filters.command("readqr", COMMAND_HANDLER)) -@ratelimiter async def readqr(c, m): if not m.reply_to_message: return await m.reply("Please reply photo that contain valid QR Code.") @@ -145,7 +143,6 @@ async def readqr(c, m): @app.on_message(filters.command("createqr", COMMAND_HANDLER)) -@ratelimiter async def makeqr(c, m): if m.reply_to_message and m.reply_to_message.text: teks = m.reply_to_message.text @@ -193,7 +190,6 @@ async def stackoverflow(_, message): @app.on_message(filters.command(["google"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def gsearch(_, message): if len(message.command) == 1: return await message.reply("Give a query to search in Google!") @@ -241,7 +237,6 @@ async def gsearch(_, message): @app.on_message(filters.command(["tr", "trans", "translate"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def translate(_, message): if message.reply_to_message and ( message.reply_to_message.text or message.reply_to_message.caption @@ -273,7 +268,6 @@ async def translate(_, message): @app.on_message(filters.command(["tts"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def tts_convert(_, message): if message.reply_to_message and ( message.reply_to_message.text or message.reply_to_message.caption @@ -307,7 +301,6 @@ async def tts_convert(_, message): @app.on_message(filters.command(["tosticker"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def tostick(client, message): try: if not message.reply_to_message or not message.reply_to_message.photo: @@ -324,7 +317,6 @@ async def tostick(client, message): @app.on_message(filters.command(["toimage"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def topho(client, message): try: if not message.reply_to_message or not message.reply_to_message.sticker: @@ -352,7 +344,6 @@ async def topho(client, message): @app.on_message(filters.command(["id"], COMMAND_HANDLER)) -@ratelimiter async def showid(_, message): chat_type = message.chat.type.value if chat_type == "private": @@ -392,7 +383,6 @@ async def showid(_, message): @app.on_message(filters.command(["info"], COMMAND_HANDLER)) -@ratelimiter async def who_is(client, message): # https://github.com/SpEcHiDe/PyroGramBot/blob/master/pyrobot/plugins/admemes/whois.py#L19 if message.sender_chat: @@ -464,7 +454,6 @@ async def who_is(client, message): @app.on_callback_query(filters.regex("^close")) -@ratelimiter async def close_callback(_, query: CallbackQuery): _, userid = query.data.split("#") if query.from_user.id != int(userid): @@ -489,7 +478,6 @@ async def mdlapi(title): @app.on_message(filters.command(["mdl"], COMMAND_HANDLER)) @capture_err -@ratelimiter async def mdlsearch(_, message): if " " in message.text: _, title = message.text.split(None, 1) @@ -516,7 +504,6 @@ async def mdlsearch(_, message): @app.on_callback_query(filters.regex("^mdls")) -@ratelimiter async def mdl_callback(_, query: CallbackQuery): _, user, _, slug = query.data.split("#") if user == f"{query.from_user.id}": diff --git a/misskaty/plugins/nightmodev2.py b/misskaty/plugins/nightmodev2.py index eb322000..5f367137 100644 --- a/misskaty/plugins/nightmodev2.py +++ b/misskaty/plugins/nightmodev2.py @@ -22,7 +22,6 @@ from pyrogram.types import ChatPermissions, InlineKeyboardButton, InlineKeyboard from database.locale_db import get_db_lang from misskaty import BOT_NAME, app, scheduler from misskaty.core.decorator.permissions import require_admin -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.localization import langdict, use_chat_lang from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, TZ @@ -256,7 +255,6 @@ async def nightmode_handler(_, msg, strings): @app.on_callback_query(filters.regex(r"^nightmd$")) -@ratelimiter @use_chat_lang() async def callbackanightmd(c, q, strings): await q.answer( @@ -264,4 +262,5 @@ async def callbackanightmd(c, q, strings): bname=c.me.first_name, ver=__version__, pyver=platform.python_version() ), show_alert=True, + cache_time=10, ) diff --git a/misskaty/plugins/notes.py b/misskaty/plugins/notes.py index ca6d119e..4e387ec5 100644 --- a/misskaty/plugins/notes.py +++ b/misskaty/plugins/notes.py @@ -29,7 +29,6 @@ from database.notes_db import delete_note, get_note, get_note_names, save_note from misskaty import app from misskaty.core.decorator.errors import capture_err from misskaty.core.decorator.permissions import adminsOnly -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.core.keyboard import ikb from misskaty.helper.functions import extract_text_and_keyb @@ -46,7 +45,6 @@ __HELP__ = """/notes To Get All The Notes In The Chat. @app.on_message(filters.command(["addnote", "save"]) & ~filters.private) @adminsOnly("can_change_info") -@ratelimiter async def save_notee(_, message): if len(message.command) < 2 or not message.reply_to_message: await message.reply( @@ -73,7 +71,6 @@ async def save_notee(_, message): @app.on_message(filters.command("notes") & ~filters.private) @capture_err -@ratelimiter async def get_notes(_, message): chat_id = message.chat.id @@ -90,7 +87,6 @@ async def get_notes(_, message): @app.on_message(filters.regex(r"^#.+") & filters.text & ~filters.private) @capture_err -@ratelimiter async def get_one_note(_, message): name = message.text.replace("#", "", 1) if not name: @@ -115,7 +111,6 @@ async def get_one_note(_, message): @app.on_message(filters.command(["delnote", "clear"]) & ~filters.private) @adminsOnly("can_change_info") -@ratelimiter async def del_note(_, message): if len(message.command) == 1: return await message.reply("**Usage**\n__/delnote [NOTE_NAME]__") diff --git a/misskaty/plugins/ocr.py b/misskaty/plugins/ocr.py index 7342cf48..1e9adadb 100644 --- a/misskaty/plugins/ocr.py +++ b/misskaty/plugins/ocr.py @@ -14,7 +14,6 @@ from telegraph.aio import Telegraph from misskaty import app from misskaty.core.decorator.errors import capture_err -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import fetch, use_chat_lang from misskaty.vars import COMMAND_HANDLER @@ -24,7 +23,6 @@ __HELP__ = "/ocr [reply to photo] - Read Text From Image" @app.on_message(filters.command(["ocr"], COMMAND_HANDLER)) @capture_err -@ratelimiter @use_chat_lang() async def ocr(_, ctx: Message, strings): reply = ctx.reply_to_message diff --git a/misskaty/plugins/paste.py b/misskaty/plugins/paste.py index a5b5231c..24044a89 100644 --- a/misskaty/plugins/paste.py +++ b/misskaty/plugins/paste.py @@ -12,7 +12,6 @@ from pyrogram import filters from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import fetch, post_to_telegraph, rentry from misskaty.vars import COMMAND_HANDLER @@ -66,7 +65,6 @@ pattern = compiles(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$|x-subrip @app.on_message(filters.command(["tgraph"], COMMAND_HANDLER)) -@ratelimiter async def telegraph_paste(_, message): reply = message.reply_to_message if not reply and len(message.command) < 2: @@ -166,7 +164,6 @@ async def telegraph_paste(_, message): # Default Paste to Wastebin using Deta @app.on_message(filters.command(["paste"], COMMAND_HANDLER)) -@ratelimiter async def wastepaste(_, message): reply = message.reply_to_message target = str(message.command[0]).split("@", maxsplit=1)[0] @@ -239,7 +236,6 @@ async def wastepaste(_, message): # Nekobin Paste @app.on_message(filters.command(["neko"], COMMAND_HANDLER)) -@ratelimiter async def nekopaste(_, message): reply = message.reply_to_message target = str(message.command[0]).split("@", maxsplit=1)[0] @@ -309,7 +305,6 @@ async def nekopaste(_, message): # Paste as spacebin @app.on_message(filters.command(["sbin"], COMMAND_HANDLER)) -@ratelimiter async def spacebinn(_, message): reply = message.reply_to_message target = str(message.command[0]).split("@", maxsplit=1)[0] @@ -379,7 +374,6 @@ async def spacebinn(_, message): # Rentry paste @app.on_message(filters.command(["rentry"], COMMAND_HANDLER)) -@ratelimiter async def rentrypaste(_, message): reply = message.reply_to_message target = str(message.command[0]).split("@", maxsplit=1)[0] @@ -446,7 +440,6 @@ async def rentrypaste(_, message): # Tempaste pastebin @app.on_message(filters.command(["temp_paste"], COMMAND_HANDLER)) -@ratelimiter async def tempaste(_, message): reply = message.reply_to_message target = str(message.command[0]).split("@", maxsplit=1)[0] diff --git a/misskaty/plugins/ping.py b/misskaty/plugins/ping.py index 0282c30c..420b21d7 100644 --- a/misskaty/plugins/ping.py +++ b/misskaty/plugins/ping.py @@ -15,13 +15,11 @@ from pyrogram import filters from pyrogram.types import Message from misskaty import app, botStartTime, misskaty_version -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.human_read import get_readable_time from misskaty.vars import COMMAND_HANDLER @app.on_message(filters.command(["ping"], COMMAND_HANDLER)) -@ratelimiter async def ping(_, ctx: Message): currentTime = get_readable_time(time.time() - botStartTime) start_t = time.time() @@ -34,7 +32,6 @@ async def ping(_, ctx: Message): @app.on_message(filters.command(["ping_dc"], COMMAND_HANDLER)) -@ratelimiter async def ping_handler(_, ctx: Message): m = await ctx.reply_msg("Pinging datacenters...") async with Lock(): diff --git a/misskaty/plugins/pypi_search.py b/misskaty/plugins/pypi_search.py index 6272b9f9..ca0c6264 100644 --- a/misskaty/plugins/pypi_search.py +++ b/misskaty/plugins/pypi_search.py @@ -10,7 +10,6 @@ from pyrogram.errors import QueryIdInvalid from pyrogram.types import CallbackQuery, Message from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper import Cache, fetch from misskaty.plugins.web_scraper import split_arr from misskaty.vars import COMMAND_HANDLER @@ -43,7 +42,6 @@ async def getDataPypi(msg, kueri, CurrentPage, user): @app.on_message(filters.command(["pypi"], COMMAND_HANDLER)) -@ratelimiter async def pypi_s(_, ctx: Message): kueri = " ".join(ctx.command[1:]) if not kueri: @@ -68,7 +66,6 @@ async def pypi_s(_, ctx: Message): @app.on_callback_query(filters.create(lambda _, __, query: "page_pypi#" in query.data)) -@ratelimiter async def pypipage_callback(_, callback_query: CallbackQuery): if callback_query.from_user.id != int(callback_query.data.split("#")[3]): return await callback_query.answer("Not yours..", True) @@ -103,7 +100,6 @@ async def pypipage_callback(_, callback_query: CallbackQuery): @app.on_callback_query(filters.create(lambda _, __, query: "pypidata#" in query.data)) -@ratelimiter async def pypi_getdata(_, callback_query: CallbackQuery): if callback_query.from_user.id != int(callback_query.data.split("#")[3]): return await callback_query.answer("Not yours..", True) diff --git a/misskaty/plugins/quotly.py b/misskaty/plugins/quotly.py index 3ff5882c..a672f790 100644 --- a/misskaty/plugins/quotly.py +++ b/misskaty/plugins/quotly.py @@ -8,7 +8,6 @@ from pyrogram import Client, filters from pyrogram.types import Message from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.http import fetch __MODULE__ = "Fun" @@ -251,7 +250,6 @@ def isArgInt(txt) -> list: @app.on_message(filters.command(["q", "qr"]) & filters.reply) -@ratelimiter async def msg_quotly_cmd(self: Client, ctx: Message): is_reply = False if ctx.command[0].endswith("r"): diff --git a/misskaty/plugins/sangmata.py b/misskaty/plugins/sangmata.py index 461ef5cb..32fac460 100644 --- a/misskaty/plugins/sangmata.py +++ b/misskaty/plugins/sangmata.py @@ -15,7 +15,6 @@ from database.sangmata_db import ( ) from misskaty import app from misskaty.core.decorator.permissions import adminsOnly -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.localization import use_chat_lang from misskaty.vars import COMMAND_HANDLER @@ -97,7 +96,6 @@ async def cek_mataa(_, ctx: Message, strings): & ~filters.via_bot ) @adminsOnly("can_change_info") -@ratelimiter @use_chat_lang() async def set_mataa(_, ctx: Message, strings): if len(ctx.command) == 1: diff --git a/misskaty/plugins/sed.py b/misskaty/plugins/sed.py index e4d86ca9..ec4123de 100644 --- a/misskaty/plugins/sed.py +++ b/misskaty/plugins/sed.py @@ -9,11 +9,9 @@ from pyrogram.errors import MessageEmpty from pyrogram.types import Message from misskaty import app -from misskaty.core.decorator.ratelimiter import ratelimiter @app.on_message(filters.regex(r"^s/(.+)?/(.+)?(/.+)?") & filters.reply) -@ratelimiter async def sed(self: Client, ctx: Message): exp = regex.split(r"(? 1 else None @@ -549,7 +547,6 @@ async def same_search(_, msg, strings): # Terbit21 CMD @app.on_cmd("terbit21", no_channel=True) -@ratelimiter @use_chat_lang() async def terbit21_s(_, message, strings): kueri = " ".join(message.command[1:]) @@ -574,7 +571,6 @@ async def terbit21_s(_, message, strings): # LK21 CMD @app.on_cmd("lk21", no_channel=True) -@ratelimiter @use_chat_lang() async def lk21_s(_, message, strings): kueri = " ".join(message.command[1:]) @@ -597,7 +593,6 @@ async def lk21_s(_, message, strings): # Pahe CMD @app.on_cmd("pahe", no_channel=True) -@ratelimiter @use_chat_lang() async def pahe_s(_, message, strings): kueri = " ".join(message.command[1:]) @@ -620,7 +615,6 @@ async def pahe_s(_, message, strings): # Gomov CMD @app.on_cmd("gomov", no_channel=True) -@ratelimiter @use_chat_lang() async def gomov_s(_, message, strings): kueri = " ".join(message.command[1:]) @@ -647,7 +641,6 @@ async def gomov_s(_, message, strings): # MelongMovie CMD @app.on_cmd("melongmovie", no_channel=True) -@ratelimiter @use_chat_lang() async def melong_s(_, message, strings): kueri = " ".join(message.command[1:]) @@ -681,7 +674,6 @@ async def melong_s(_, message, strings): # Savefilm21 CMD @app.on_cmd("savefilm21", no_channel=True) -@ratelimiter @use_chat_lang() async def savefilm_s(_, message, strings): kueri = " ".join(message.command[1:]) @@ -710,7 +702,6 @@ async def savefilm_s(_, message, strings): # Kusonime CMD @app.on_cmd("kusonime", no_channel=True) -@ratelimiter @use_chat_lang() async def kusonime_s(_, message, strings): kueri = " ".join(message.command[1:]) @@ -739,7 +730,6 @@ async def kusonime_s(_, message, strings): # Lendrive CMD @app.on_cmd("lendrive", no_channel=True) -@ratelimiter @use_chat_lang() async def lendrive_s(_, ctx: Message, strings): kueri = ctx.input @@ -766,7 +756,6 @@ async def lendrive_s(_, ctx: Message, strings): # Movieku CMD @app.on_cmd("movieku", no_channel=True) -@ratelimiter @use_chat_lang() async def movieku_s(_, ctx: Message, strings): kueri = ctx.input @@ -791,7 +780,6 @@ async def movieku_s(_, ctx: Message, strings): # Savefillm21 Page Callback @app.on_cb("page_sf21#") -@ratelimiter @use_chat_lang() async def sf21page_callback(_, callback_query, strings): try: @@ -836,7 +824,6 @@ async def sf21page_callback(_, callback_query, strings): # Kuso Page Callback @app.on_cb("page_kuso#") -@ratelimiter @use_chat_lang() async def kusopage_callback(_, callback_query, strings): try: @@ -881,7 +868,6 @@ async def kusopage_callback(_, callback_query, strings): # Lendrive Page Callback @app.on_cb("page_lendrive#") -@ratelimiter @use_chat_lang() async def lendrivepage_callback(_, callback_query, strings): try: @@ -924,7 +910,6 @@ async def lendrivepage_callback(_, callback_query, strings): # Movieku Page Callback @app.on_cb("page_movieku#") -@ratelimiter @use_chat_lang() async def moviekupage_callback(_, callback_query, strings): try: @@ -961,7 +946,6 @@ async def moviekupage_callback(_, callback_query, strings): # Samehada Page Callback @app.on_cb("page_same#") -@ratelimiter @use_chat_lang() async def samepg(_, query, strings): try: @@ -993,7 +977,6 @@ async def samepg(_, query, strings): # Terbit21 Page Callback @app.on_cb("page_terbit21#") -@ratelimiter @use_chat_lang() async def terbit21page_callback(_, callback_query, strings): try: @@ -1030,7 +1013,6 @@ async def terbit21page_callback(_, callback_query, strings): # Page Callback Melong @app.on_cb("page_melong#") -@ratelimiter @use_chat_lang() async def melongpage_callback(_, callback_query, strings): try: @@ -1073,7 +1055,6 @@ async def melongpage_callback(_, callback_query, strings): # Lk21 Page Callback @app.on_cb("page_lk21#") -@ratelimiter @use_chat_lang() async def lk21page_callback(_, callback_query, strings): try: @@ -1110,7 +1091,6 @@ async def lk21page_callback(_, callback_query, strings): # Pahe Page Callback @app.on_cb("page_pahe#") -@ratelimiter @use_chat_lang() async def pahepage_callback(_, callback_query, strings): try: @@ -1147,7 +1127,6 @@ async def pahepage_callback(_, callback_query, strings): # Gomov Page Callback @app.on_cb("page_gomov#") -@ratelimiter @use_chat_lang() async def gomovpage_callback(_, callback_query, strings): try: @@ -1191,7 +1170,6 @@ async def gomovpage_callback(_, callback_query, strings): ### Scrape DDL Link From Web ### # Kusonime DDL @app.on_cb("kusoextract#") -@ratelimiter @use_chat_lang() async def kusonime_scrap(client, callback_query, strings): try: @@ -1244,7 +1222,6 @@ async def kusonime_scrap(client, callback_query, strings): # Savefilm21 DDL @app.on_cb("sf21extract#") -@ratelimiter @use_chat_lang() async def savefilm21_scrap(_, callback_query, strings): try: @@ -1281,7 +1258,6 @@ async def savefilm21_scrap(_, callback_query, strings): # Scrape Link Download Movieku.CC @app.on_cmd("movieku_scrap#") -@ratelimiter @use_chat_lang() async def muviku_scrap(_, message, strings): try: @@ -1310,7 +1286,6 @@ async def muviku_scrap(_, message, strings): # Scrape DDL Link Melongmovie @app.on_cb("melongextract#") -@ratelimiter @use_chat_lang() async def melong_scrap(_, callback_query, strings): try: @@ -1350,7 +1325,6 @@ async def melong_scrap(_, callback_query, strings): # Scrape DDL Link Gomov @app.on_cb("gomovextract#") -@ratelimiter @use_chat_lang() async def gomov_dl(_, callback_query, strings): try: @@ -1390,7 +1364,6 @@ async def gomov_dl(_, callback_query, strings): @app.on_cb("lendriveextract#") -@ratelimiter @use_chat_lang() async def lendrive_dl(_, callback_query, strings): if callback_query.from_user.id != int(callback_query.data.split("#")[3]): diff --git a/misskaty/plugins/webss.py b/misskaty/plugins/webss.py index b99ca565..e9a9d6ff 100644 --- a/misskaty/plugins/webss.py +++ b/misskaty/plugins/webss.py @@ -10,7 +10,6 @@ from pySmartDL import SmartDL from misskaty import app from misskaty.core.decorator import new_task -from misskaty.core.decorator.ratelimiter import ratelimiter from misskaty.helper.localization import use_chat_lang __MODULE__ = "WebSS" @@ -20,7 +19,6 @@ __HELP__ = """ @app.on_cmd("webss") -@ratelimiter @new_task @use_chat_lang() async def take_ss(_, ctx: Message, strings): diff --git a/misskaty/plugins/ytdl_plugins.py b/misskaty/plugins/ytdl_plugins.py index d112a021..722b6ac4 100644 --- a/misskaty/plugins/ytdl_plugins.py +++ b/misskaty/plugins/ytdl_plugins.py @@ -26,7 +26,7 @@ from pyrogram.types import ( from misskaty import app from misskaty.core import pyro_cooldown -from misskaty.core.decorator import capture_err, new_task, ratelimiter +from misskaty.core.decorator import capture_err, new_task from misskaty.helper import fetch, use_chat_lang from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO @@ -40,7 +40,6 @@ def rand_key(): @app.on_cmd("ytsearch", no_channel=True) -@ratelimiter @use_chat_lang() async def ytsearch(_, ctx: Message, strings): if len(ctx.command) == 1: @@ -91,7 +90,6 @@ async def ytsearch(_, ctx: Message, strings): & pyro_cooldown.wait(60) ) @capture_err -@ratelimiter @use_chat_lang() async def ytdownv2(_, ctx: Message, strings): if not ctx.from_user: @@ -133,7 +131,6 @@ async def ytdownv2(_, ctx: Message, strings): @app.on_cb(filters.regex(r"^yt_listall")) -@ratelimiter @use_chat_lang() async def ytdl_listall_callback(_, cq: CallbackQuery, strings): if cq.from_user.id != cq.message.reply_to_message.from_user.id: @@ -149,7 +146,6 @@ async def ytdl_listall_callback(_, cq: CallbackQuery, strings): @app.on_callback_query(filters.regex(r"^yt_extract_info")) -@ratelimiter @use_chat_lang() async def ytdl_extractinfo_callback(_, cq: CallbackQuery, strings): if cq.from_user.id != cq.message.reply_to_message.from_user.id: @@ -187,7 +183,6 @@ async def ytdl_extractinfo_callback(_, cq: CallbackQuery, strings): @app.on_callback_query(filters.regex(r"^yt_(gen|dl)")) -@ratelimiter @use_chat_lang() @new_task async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings): @@ -245,7 +240,6 @@ async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings): @app.on_callback_query(filters.regex(r"^yt_cancel")) -@ratelimiter @use_chat_lang() async def ytdl_cancel_callback(_, cq: CallbackQuery, strings): if cq.from_user.id != cq.message.reply_to_message.from_user.id: @@ -264,7 +258,6 @@ async def ytdl_cancel_callback(_, cq: CallbackQuery, strings): @app.on_callback_query(filters.regex(r"^ytdl_scroll")) -@ratelimiter @use_chat_lang() async def ytdl_scroll_callback(_, cq: CallbackQuery, strings): if cq.from_user.id != cq.message.reply_to_message.from_user.id: