Skip to content

Commit

Permalink
Merge pull request #280 from AnimeKaizoku/KigyoDev
Browse files Browse the repository at this point in the history
be more permissable with limits
  • Loading branch information
Dank-del authored Nov 28, 2023
2 parents 7996255 + 42ba0bf commit 3b88f6c
Show file tree
Hide file tree
Showing 51 changed files with 222 additions and 225 deletions.
6 changes: 3 additions & 3 deletions logging.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ keys=consoleHandler
keys=sampleFormatter

[logger_root]
level=DEBUG
level=INFO
handlers=consoleHandler

[logger_sampleLogger]
level=DEBUG
level=INFO
handlers=consoleHandler
qualname=sampleLogger
propagate=0

[handler_consoleHandler]
class=StreamHandler
level=INFO
level=DEBUG
formatter=sampleFormatter
args=(sys.stdout,)

Expand Down
15 changes: 7 additions & 8 deletions tg_bot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test(update: Update, _: CallbackContext):

@kigcallback(pattern=r'start_back')
@kigcmd(command='start', pass_args=True)
@rate_limit(5, 60)
@rate_limit(40, 60)
def start(update: Update, context: CallbackContext): # sourcery no-metrics
"""#TODO
Expand Down Expand Up @@ -288,7 +288,6 @@ def start(update: Update, context: CallbackContext): # sourcery no-metrics


# for test purposes
@rate_limit(5, 60)
def error_callback(_, context: CallbackContext):
"""#TODO
Expand Down Expand Up @@ -317,7 +316,7 @@ def error_callback(_, context: CallbackContext):


@kigcallback(pattern=r'help_')
@rate_limit(5, 60)
@rate_limit(40, 60)
def help_button(update: Update, context: CallbackContext):
"""#TODO
Expand Down Expand Up @@ -405,7 +404,7 @@ def help_button(update: Update, context: CallbackContext):


@kigcmd(command='help')
@rate_limit(5, 60)
@rate_limit(40, 60)
def get_help(update: Update, context: CallbackContext):
'''#TODO
Expand Down Expand Up @@ -539,7 +538,7 @@ def send_settings(chat_id: int, user_id: int, user=False):


@kigcallback(pattern=r"stngs_")
@rate_limit(5, 60)
@rate_limit(40, 60)
def settings_button(update: Update, context: CallbackContext):
'''#TODO
Expand Down Expand Up @@ -631,7 +630,7 @@ def settings_button(update: Update, context: CallbackContext):


@kigcmd(command='settings')
@rate_limit(5, 60)
@rate_limit(40, 60)
def get_settings(update: Update, context: CallbackContext):
'''#TODO
Expand Down Expand Up @@ -670,7 +669,7 @@ def get_settings(update: Update, context: CallbackContext):


@kigcmd(command='donate')
@rate_limit(5, 60)
@rate_limit(40, 60)
def donate(update: Update, _: CallbackContext):
"""#TODO
Expand All @@ -683,7 +682,7 @@ def donate(update: Update, _: CallbackContext):


@kigmsg(Filters.status_update.migrate)
@rate_limit(5, 60)
@rate_limit(40, 60)
def migrate_chats(update: Update, context: CallbackContext):
"""#TODO
Params:
Expand Down
16 changes: 8 additions & 8 deletions tg_bot/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@can_promote
@user_admin(AdminPerms.CAN_PROMOTE_MEMBERS)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def promote(update: Update, context: CallbackContext) -> Optional[str]:
bot = context.bot
args = context.args
Expand Down Expand Up @@ -110,7 +110,7 @@ def promote(update: Update, context: CallbackContext) -> Optional[str]:
@can_promote
@user_admin(AdminPerms.CAN_PROMOTE_MEMBERS)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def demote(update: Update, context: CallbackContext) -> Optional[str]:
bot = context.bot
args = context.args
Expand Down Expand Up @@ -183,7 +183,7 @@ def demote(update: Update, context: CallbackContext) -> Optional[str]:
"""
@kigcmd(command="admincache", can_disable=False)
@u_admin
@rate_limit(5, 60)
@rate_limit(40, 60)
def refresh_admin(update, _):
ADMIN_CACHE.pop(update.effective_chat.id)
update.effective_message.reply_text("Admins cache refreshed!")
Expand All @@ -195,7 +195,7 @@ def refresh_admin(update, _):
@bot_admin
@can_promote
@user_admin(AdminPerms.CAN_PROMOTE_MEMBERS)
@rate_limit(5, 60)
@rate_limit(40, 60)
def set_title(update: Update, context: CallbackContext):
bot = context.bot
args = context.args
Expand Down Expand Up @@ -261,7 +261,7 @@ def set_title(update: Update, context: CallbackContext):
@can_pin
@user_admin(AdminPerms.CAN_PIN_MESSAGES)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def pin(update: Update, context: CallbackContext) -> str:
bot = context.bot
args = context.args
Expand Down Expand Up @@ -304,7 +304,7 @@ def pin(update: Update, context: CallbackContext) -> str:
@can_pin
@user_admin(AdminPerms.CAN_PIN_MESSAGES)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def unpin(update: Update, context: CallbackContext) -> str:
bot = context.bot
chat = update.effective_chat
Expand All @@ -331,7 +331,7 @@ def unpin(update: Update, context: CallbackContext) -> str:
@bot_admin
@user_admin(AdminPerms.CAN_INVITE_USERS)
@connection_status
@rate_limit(5, 60)
@rate_limit(40, 60)
def invite(update: Update, context: CallbackContext):
bot = context.bot
chat = update.effective_chat
Expand All @@ -354,7 +354,7 @@ def invite(update: Update, context: CallbackContext):


@kigcmd(command=["admin", "admins"])
@rate_limit(5, 60)
@rate_limit(40, 60)
def adminlist(update: Update, _):
administrators = update.effective_chat.get_administrators()
text = "Admins in *{}*:".format(update.effective_chat.title or "this chat")
Expand Down
4 changes: 2 additions & 2 deletions tg_bot/modules/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@kigmsg(Filters.regex("(?i)^brb"), friendly="afk", group=3)
@kigcmd(command="afk", group=3)
@rate_limit(5, 60)
@rate_limit(40, 60)
def afk(update: Update, context: CallbackContext):
args = update.effective_message.text.split(None, 1)
user = update.effective_user
Expand Down Expand Up @@ -70,7 +70,7 @@ def no_longer_afk(update: Update, context: CallbackContext):
return

@kigmsg((Filters.entity(MessageEntity.MENTION) | Filters.entity(MessageEntity.TEXT_MENTION) & Filters.chat_type.groups), friendly='afk', group=8)
@rate_limit(5, 60)
@rate_limit(40, 60)
def reply_afk(update: Update, context: CallbackContext):
bot = context.bot
message = update.effective_message
Expand Down
6 changes: 3 additions & 3 deletions tg_bot/modules/anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def airing(update: Update, context: CallbackContext):
update.effective_message.reply_text(msg, parse_mode=ParseMode.MARKDOWN)

@kigcmd(command="anime")
@rate_limit(5, 60)
@rate_limit(40, 60)
def anime(update: Update, context: CallbackContext): # sourcery no-metrics
message = update.effective_message
search = message.text.split(" ", 1)
Expand Down Expand Up @@ -254,7 +254,7 @@ def anime(update: Update, context: CallbackContext): # sourcery no-metrics
)

@kigcmd(command="character")
@rate_limit(5, 60)
@rate_limit(40, 60)
def character(update: Update, context: CallbackContext):
message = update.effective_message
search = message.text.split(" ", 1)
Expand Down Expand Up @@ -288,7 +288,7 @@ def character(update: Update, context: CallbackContext):
)

@kigcmd(command="manga")
@rate_limit(5, 60)
@rate_limit(40, 60)
def manga(update: Update, context: CallbackContext):
message = update.effective_message
search = message.text.split(" ", 1)
Expand Down
2 changes: 1 addition & 1 deletion tg_bot/modules/announce.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@kigcmd(command="announce", pass_args=True)
@u_admin(AdminPerms.CAN_CHANGE_INFO)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def announcestat(update: Update, context: CallbackContext) -> str:
args = context.args
if len(args) > 0:
Expand Down
2 changes: 1 addition & 1 deletion tg_bot/modules/antichannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@kigcmd(command="antichannel", group=100)
@user_admin(AdminPerms.CAN_RESTRICT_MEMBERS)
@rate_limit(5, 60)
@rate_limit(40, 60)
def set_antichannel(update: Update, context: CallbackContext):
message = update.effective_message
chat = update.effective_chat
Expand Down
2 changes: 1 addition & 1 deletion tg_bot/modules/antiflood.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def check_flood(update, context) -> Optional[str]:
@user_admin_no_reply
@bot_admin
@kigcallback(pattern=r"unmute_flooder")
@rate_limit(5, 60)
@rate_limit(40, 60)
def flood_button(update: Update, context: CallbackContext):
bot = context.bot
query = update.callback_query
Expand Down
4 changes: 2 additions & 2 deletions tg_bot/modules/antilinkedchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@kigcmd(command="antilinkedchan", group=112)
@bot_can_delete
@user_admin(AdminPerms.CAN_RESTRICT_MEMBERS)
@rate_limit(5, 60)
@rate_limit(40, 60)
def set_antilinkedchannel(update: Update, context: CallbackContext):
message = update.effective_message
chat = update.effective_chat
Expand Down Expand Up @@ -52,7 +52,7 @@ def eliminate_linked_channel_msg(update: Update, _: CallbackContext):
@kigcmd(command="antichannelpin", group=114)
@bot_admin
@user_admin(AdminPerms.CAN_RESTRICT_MEMBERS)
@rate_limit(5, 60)
@rate_limit(40, 60)
def set_antipinchannel(update: Update, context: CallbackContext):
message = update.effective_message
chat = update.effective_chat
Expand Down
10 changes: 5 additions & 5 deletions tg_bot/modules/approve.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@kigcmd(command='approve', filters=Filters.chat_type.groups)
@loggable
@user_admin(AdminPerms.CAN_CHANGE_INFO)
@rate_limit(5, 60)
@rate_limit(40, 60)
def approve(update: Update, context: CallbackContext):
message = update.effective_message
chat_title = message.chat.title
Expand Down Expand Up @@ -63,7 +63,7 @@ def approve(update: Update, context: CallbackContext):
@kigcmd(command='unapprove', filters=Filters.chat_type.groups)
@loggable
@user_admin(AdminPerms.CAN_CHANGE_INFO)
@rate_limit(5, 60)
@rate_limit(40, 60)
def disapprove(update: Update, context: CallbackContext):
message = update.effective_message
chat_title = message.chat.title
Expand Down Expand Up @@ -100,7 +100,7 @@ def disapprove(update: Update, context: CallbackContext):

@kigcmd(command='approved', filters=Filters.chat_type.groups)
@user_admin(AdminPerms.CAN_CHANGE_INFO)
@rate_limit(5, 60)
@rate_limit(40, 60)
def approved(update: Update, _: CallbackContext):
message = update.effective_message
chat_title = message.chat.title
Expand All @@ -119,7 +119,7 @@ def approved(update: Update, _: CallbackContext):

@kigcmd(command='approval', filters=Filters.chat_type.groups)
@user_admin(AdminPerms.CAN_CHANGE_INFO)
@rate_limit(5, 60)
@rate_limit(40, 60)
def approval(update, context):
message = update.effective_message
chat = update.effective_chat
Expand All @@ -143,7 +143,7 @@ def approval(update, context):


@kigcmd(command='unapproveall', filters=Filters.chat_type.groups)
@rate_limit(5, 60)
@rate_limit(40, 60)
def unapproveall(update: Update, _: CallbackContext):
chat = update.effective_chat
user = update.effective_user
Expand Down
4 changes: 2 additions & 2 deletions tg_bot/modules/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_help(chat):
@kigcmd(command='import')
@user_admin(AdminPerms.CAN_CHANGE_INFO)
@typing_action
@rate_limit(5, 60)
@rate_limit(40, 60)
def import_data(update, context):
msg = update.effective_message
chat = update.effective_chat
Expand Down Expand Up @@ -122,7 +122,7 @@ def import_data(update, context):

@kigcmd(command='export')
@user_admin(AdminPerms.CAN_CHANGE_INFO)
@rate_limit(5, 60)
@rate_limit(40, 60)
def export_data(update, context): # sourcery no-metrics
chat_data = context.chat_data
msg = update.effective_message # type: Optional[Message]
Expand Down
12 changes: 6 additions & 6 deletions tg_bot/modules/bans.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@can_restrict
@user_admin(AdminPerms.CAN_RESTRICT_MEMBERS)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def ban(update: Update, context: CallbackContext) -> Optional[str]: # sourcery no-metrics
chat = update.effective_chat # type: Optional[Chat]
user = update.effective_user # type: Optional[User]
Expand Down Expand Up @@ -145,7 +145,7 @@ def ban(update: Update, context: CallbackContext) -> Optional[str]: # sourcery
@can_restrict
@user_admin(AdminPerms.CAN_RESTRICT_MEMBERS)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def temp_ban(update: Update, context: CallbackContext) -> str:
chat = update.effective_chat
user = update.effective_user
Expand Down Expand Up @@ -235,7 +235,7 @@ def temp_ban(update: Update, context: CallbackContext) -> str:
@can_restrict
@user_admin(AdminPerms.CAN_RESTRICT_MEMBERS)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def kick(update: Update, context: CallbackContext) -> str:
chat = update.effective_chat
user = update.effective_user
Expand Down Expand Up @@ -291,7 +291,7 @@ def kick(update: Update, context: CallbackContext) -> str:
@kigcmd(command='kickme', pass_args=True, filters=Filters.chat_type.groups)
@bot_admin
@can_restrict
@rate_limit(5, 60)
@rate_limit(40, 60)
def kickme(update: Update, context: CallbackContext):
user_id = update.effective_message.from_user.id
if is_user_admin(update, user_id):
Expand All @@ -311,7 +311,7 @@ def kickme(update: Update, context: CallbackContext):
@can_restrict
@user_admin(AdminPerms.CAN_RESTRICT_MEMBERS)
@loggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def unban(update: Update, context: CallbackContext) -> Optional[str]:
message = update.effective_message
user = update.effective_user
Expand Down Expand Up @@ -383,7 +383,7 @@ def unban(update: Update, context: CallbackContext) -> Optional[str]:
@bot_admin
@can_restrict
@gloggable
@rate_limit(5, 60)
@rate_limit(40, 60)
def selfunban(context: CallbackContext, update: Update) -> Optional[str]:
message = update.effective_message
user = update.effective_user
Expand Down
Loading

0 comments on commit 3b88f6c

Please sign in to comment.