Skip to content

Commit

Permalink
type annotate translation func
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Jun 15, 2024
1 parent bd8662f commit 222898b
Show file tree
Hide file tree
Showing 37 changed files with 127 additions and 127 deletions.
10 changes: 5 additions & 5 deletions eduu/plugins/admins/bans.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from eduu.utils import commands, extract_time, get_reason_text, get_target_user
from eduu.utils.consts import ADMIN_STATUSES
from eduu.utils.decorators import require_admin
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("ban", PREFIXES))
@use_chat_lang
@require_admin(ChatPrivileges(can_restrict_members=True))
async def ban(c: Client, m: Message, s):
async def ban(c: Client, m: Message, s: Strings):
target_user = await get_target_user(c, m)
reason = get_reason_text(c, m)
check_admin = await m.chat.get_member(target_user.id)
Expand All @@ -36,7 +36,7 @@ async def ban(c: Client, m: Message, s):
@Client.on_message(filters.command("kick", PREFIXES))
@use_chat_lang
@require_admin(ChatPrivileges(can_restrict_members=True))
async def kick(c: Client, m: Message, s):
async def kick(c: Client, m: Message, s: Strings):
target_user = await get_target_user(c, m)
reason = get_reason_text(c, m)
check_admin = await m.chat.get_member(target_user.id)
Expand All @@ -59,7 +59,7 @@ async def kick(c: Client, m: Message, s):
@Client.on_message(filters.command("unban", PREFIXES))
@use_chat_lang
@require_admin(ChatPrivileges(can_restrict_members=True))
async def unban(c: Client, m: Message, s):
async def unban(c: Client, m: Message, s: Strings):
target_user = await get_target_user(c, m)
reason = get_reason_text(c, m)
await m.chat.unban_member(target_user.id)
Expand All @@ -76,7 +76,7 @@ async def unban(c: Client, m: Message, s):
@Client.on_message(filters.command("tban", PREFIXES))
@use_chat_lang
@require_admin(ChatPrivileges(can_restrict_members=True))
async def tban(c: Client, m: Message, s):
async def tban(c: Client, m: Message, s: Strings):
if len(m.command) == 1:
await m.reply_text(s("admins_error_must_specify_time").format(command=m.command[0]))
return
Expand Down
6 changes: 3 additions & 3 deletions eduu/plugins/admins/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from eduu.database.admins import check_if_del_service, toggle_del_service
from eduu.utils import commands
from eduu.utils.decorators import require_admin
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("purge", PREFIXES))
@require_admin(ChatPrivileges(can_delete_messages=True), allow_in_private=True)
@use_chat_lang
async def purge(c: Client, m: Message, s):
async def purge(c: Client, m: Message, s: Strings):
"""Purge upto the replied message."""
status_message = await m.reply_text(s("purge_in_progress"), quote=True)
await m.delete()
Expand All @@ -40,7 +40,7 @@ async def purge(c: Client, m: Message, s):
@Client.on_message(filters.command("cleanservice", PREFIXES))
@require_admin(ChatPrivileges(can_delete_messages=True))
@use_chat_lang
async def delservice(c: Client, m: Message, s):
async def delservice(c: Client, m: Message, s: Strings):
if len(m.text.split()) > 1:
if m.command[1] == "on":
await toggle_del_service(m.chat.id, True)
Expand Down
8 changes: 4 additions & 4 deletions eduu/plugins/admins/mutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from eduu.utils import commands, extract_time, get_reason_text, get_target_user
from eduu.utils.consts import ADMIN_STATUSES
from eduu.utils.decorators import require_admin
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("mute", PREFIXES))
@use_chat_lang
@require_admin(ChatPrivileges(can_restrict_members=True))
async def mute(c: Client, m: Message, s):
async def mute(c: Client, m: Message, s: Strings):
target_user = await get_target_user(c, m)
reason = get_reason_text(c, m)
check_admin = await m.chat.get_member(target_user.id)
Expand All @@ -36,7 +36,7 @@ async def mute(c: Client, m: Message, s):
@Client.on_message(filters.command("unmute", PREFIXES))
@use_chat_lang
@require_admin(ChatPrivileges(can_restrict_members=True))
async def unmute(c: Client, m: Message, s):
async def unmute(c: Client, m: Message, s: Strings):
target_user = await get_target_user(c, m)
reason = get_reason_text(c, m)
await m.chat.unban_member(target_user.id)
Expand All @@ -53,7 +53,7 @@ async def unmute(c: Client, m: Message, s):
@Client.on_message(filters.command("tmute", PREFIXES))
@use_chat_lang
@require_admin(ChatPrivileges(can_restrict_members=True))
async def tmute(c: Client, m: Message, s):
async def tmute(c: Client, m: Message, s: Strings):
if len(m.command) == 1:
await m.reply_text(s("admins_error_must_specify_time").format(command=m.command[0]))
return
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/admins/pins.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
from eduu.database.admins import check_if_antichannelpin, toggle_antichannelpin
from eduu.utils import commands
from eduu.utils.decorators import require_admin
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("antichannelpin", PREFIXES))
@require_admin(ChatPrivileges(can_pin_messages=True))
@use_chat_lang
async def setantichannelpin(c: Client, m: Message, s):
async def setantichannelpin(c: Client, m: Message, s: Strings):
if len(m.text.split()) == 1:
check_acp = await check_if_antichannelpin(m.chat.id)
if not check_acp:
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/cats.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from config import PREFIXES
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("cat", PREFIXES))
@use_chat_lang
async def cat(c: Client, m: Message, s):
async def cat(c: Client, m: Message, s: Strings):
r = await http.get("https://api.thecatapi.com/v1/images/search")
rj = r.json()

Expand Down
10 changes: 5 additions & 5 deletions eduu/plugins/cmds_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from eduu.utils import commands
from eduu.utils.decorators import stop_here
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


def gen_categories_kb(strings_manager):
Expand All @@ -32,7 +32,7 @@ def gen_categories_kb(strings_manager):

@Client.on_callback_query(filters.regex("^commands$"))
@use_chat_lang
async def cmds_list(c: Client, m: CallbackQuery, s):
async def cmds_list(c: Client, m: CallbackQuery, s: Strings):
keyboard = InlineKeyboardMarkup(
inline_keyboard=[
*gen_categories_kb(s),
Expand All @@ -45,7 +45,7 @@ async def cmds_list(c: Client, m: CallbackQuery, s):
@Client.on_message(filters.command(["help", "start help"]) & filters.private)
@use_chat_lang
@stop_here
async def show_private_help(c: Client, m: Message, s):
async def show_private_help(c: Client, m: Message, s: Strings):
keyboard = InlineKeyboardMarkup(
inline_keyboard=[
*gen_categories_kb(s),
Expand All @@ -63,7 +63,7 @@ async def show_private_help(c: Client, m: Message, s):
@Client.on_message(filters.command(["help", "start help"]))
@use_chat_lang
@stop_here
async def show_help(c: Client, m: Message, s):
async def show_help(c: Client, m: Message, s: Strings):
keyboard = InlineKeyboardMarkup(
inline_keyboard=[
[
Expand All @@ -79,7 +79,7 @@ async def show_help(c: Client, m: Message, s):

@Client.on_callback_query(filters.regex("^view_category .+"))
@use_chat_lang
async def get_category(c: Client, m: CallbackQuery, s):
async def get_category(c: Client, m: CallbackQuery, s: Strings):
msg = commands.get_commands_message(s, m.data.split(maxsplit=1)[1])
keyboard = InlineKeyboardMarkup(
inline_keyboard=[[InlineKeyboardButton(s("general_back_btn"), callback_data="commands")]]
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/coub.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

from config import PREFIXES
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("coub", PREFIXES))
@use_chat_lang
async def coub(c: Client, m: Message, s):
async def coub(c: Client, m: Message, s: Strings):
if len(m.command) == 1:
await m.reply_text(s("coub_usage"))
return
Expand Down
8 changes: 4 additions & 4 deletions eduu/plugins/custom_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)
from eduu.utils import button_parser, commands, split_quotes
from eduu.utils.decorators import require_admin
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


async def check_for_filters(chat_id, trigger):
Expand All @@ -31,7 +31,7 @@ async def check_for_filters(chat_id, trigger):
@Client.on_message(filters.command(["filter", "savefilter"], PREFIXES))
@require_admin(allow_in_private=True)
@use_chat_lang
async def save_filter(c: Client, m: Message, s):
async def save_filter(c: Client, m: Message, s: Strings):
args = m.text.markdown.split(maxsplit=1)
split_text = split_quotes(args[1])
trigger = split_text[0].lower()
Expand Down Expand Up @@ -93,7 +93,7 @@ async def save_filter(c: Client, m: Message, s):
@Client.on_message(filters.command(["delfilter", "rmfilter", "stop"], PREFIXES))
@require_admin(allow_in_private=True)
@use_chat_lang
async def delete_filter(c: Client, m: Message, s):
async def delete_filter(c: Client, m: Message, s: Strings):
args = m.text.markdown.split(maxsplit=1)
trigger = args[1].lower()
chat_id = m.chat.id
Expand All @@ -109,7 +109,7 @@ async def delete_filter(c: Client, m: Message, s):

@Client.on_message(filters.command("filters", PREFIXES))
@use_chat_lang
async def get_all_filter(c: Client, m: Message, s):
async def get_all_filter(c: Client, m: Message, s: Strings):
chat_id = m.chat.id
reply_text = s("filters_list")
all_filters = await get_all_filters(chat_id)
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/dice.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from config import PREFIXES
from eduu.utils import commands
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command(["dice", "dados"], PREFIXES))
@use_chat_lang
async def dice(c: Client, m: Message, s):
async def dice(c: Client, m: Message, s: Strings):
dicen = await c.send_dice(m.chat.id, reply_to_message_id=m.id)
await dicen.reply_text(s("dice_result").format(number=dicen.dice.value), quote=True)

Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/dogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

from config import PREFIXES
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("dog", PREFIXES))
@use_chat_lang
async def dog(c: Client, m: Message, s):
async def dog(c: Client, m: Message, s: Strings):
r = await http.get("https://random.dog/woof.json")
rj = r.json()

Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/gif.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from config import PREFIXES, TENOR_API_KEY
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang

logger = logging.getLogger(__name__)

Expand All @@ -20,7 +20,7 @@

@Client.on_message(filters.command("gif", PREFIXES))
@use_chat_lang
async def gif(c: Client, m: Message, s):
async def gif(c: Client, m: Message, s: Strings):
if len(m.command) == 1:
await m.reply_text(s("gif_usage"))
return
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

from config import PREFIXES
from eduu.utils import commands, http
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("git", PREFIXES))
@use_chat_lang
async def git(c: Client, m: Message, s):
async def git(c: Client, m: Message, s: Strings):
if len(m.command) == 1:
await m.reply_text(s("git_no_username"), reply_to_message_id=m.id)
return
Expand Down
6 changes: 3 additions & 3 deletions eduu/plugins/ids.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

from config import PREFIXES
from eduu.utils import commands
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("id", PREFIXES) & filters.private)
@use_chat_lang
async def ids_private(c: Client, m: Message, s):
async def ids_private(c: Client, m: Message, s: Strings):
if len(m.command) == 2:
try:
user_data = await c.get_users(
Expand All @@ -41,7 +41,7 @@ async def ids_private(c: Client, m: Message, s):

@Client.on_message(filters.command("id", PREFIXES) & filters.group)
@use_chat_lang
async def ids(c: Client, m: Message, s):
async def ids(c: Client, m: Message, s: Strings):
if len(m.command) == 2:
try:
user_data = await c.get_users(
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

from config import PREFIXES
from eduu.utils import commands
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_message(filters.command("info", PREFIXES))
@use_chat_lang
async def user_info(c: Client, m: Message, s):
async def user_info(c: Client, m: Message, s: Strings):
if len(m.command) == 2:
try:
user = await c.get_users(
Expand Down
4 changes: 2 additions & 2 deletions eduu/plugins/inline_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
)

from eduu.utils import inline_commands
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang


@Client.on_inline_query(group=2)
@use_chat_lang
async def inline_search(c: Client, q: InlineQuery, s):
async def inline_search(c: Client, q: InlineQuery, s: Strings):
command = q.query.split(maxsplit=1)[0] if q.query else q.query

results = inline_commands.search_commands(command)
Expand Down
8 changes: 4 additions & 4 deletions eduu/plugins/inlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)

from eduu.utils import button_parser, inline_commands
from eduu.utils.localization import use_chat_lang
from eduu.utils.localization import Strings, use_chat_lang

faces_list: Iterable[str] = (
\\_(ツ)_/¯",
Expand Down Expand Up @@ -69,7 +69,7 @@ async def faces_inline(c: Client, q: InlineQuery):

@Client.on_inline_query(filters.regex(r"^markdown .+", re.IGNORECASE))
@use_chat_lang
async def markdown_inline(c: Client, q: InlineQuery, s):
async def markdown_inline(c: Client, q: InlineQuery, s: Strings):
queryinputres = q.query.split(None, 1)[1]
querytxt, querybuttons = button_parser(queryinputres)
await q.answer([
Expand All @@ -83,7 +83,7 @@ async def markdown_inline(c: Client, q: InlineQuery, s):

@Client.on_inline_query(filters.regex(r"^html .+", re.IGNORECASE))
@use_chat_lang
async def html_inline(c: Client, q: InlineQuery, s):
async def html_inline(c: Client, q: InlineQuery, s: Strings):
queryinputres = q.query.split(None, 1)[1]
querytxt, querybuttons = button_parser(queryinputres)
await q.answer([
Expand All @@ -99,7 +99,7 @@ async def html_inline(c: Client, q: InlineQuery, s):

@Client.on_inline_query(filters.regex(r"^info .+", re.IGNORECASE))
@use_chat_lang
async def info_inline(c: Client, q: InlineQuery, s):
async def info_inline(c: Client, q: InlineQuery, s: Strings):
try:
if q.query == "info":
user = q.from_user
Expand Down
Loading

0 comments on commit 222898b

Please sign in to comment.