Skip to content

Commit

Permalink
ip: make inline translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Jul 25, 2021
1 parent 2d9cc1f commit eafd9aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 5 additions & 4 deletions eduu/plugins/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ async def ip_cmd(c: Client, m: Message, strings):


@Client.on_inline_query(filters.regex(r"^ip"))
async def ip_inline(c: Client, q: InlineQuery):
@use_chat_lang()
async def ip_inline(c: Client, q: InlineQuery, strings):
if len(q.query.split()) > 1:
text = q.query.split(maxsplit=1)[1]
url: str = DOMAIN_RE.findall(text)[0]
Expand All @@ -50,7 +51,7 @@ async def ip_inline(c: Client, q: InlineQuery):
await q.answer(
[
InlineQueryResultArticle(
title=f"click here to see the ip of {text}",
title=strings("ip_info_inline").format(domain=url),
input_message_content=InputTextMessageContent(x),
)
]
Expand All @@ -59,9 +60,9 @@ async def ip_inline(c: Client, q: InlineQuery):
await q.answer(
[
InlineQueryResultArticle(
title="You must specify the url",
title=strings("ip_no_url"),
input_message_content=InputTextMessageContent(
f"You must specify the url, E.g.: <code>@{c.me.username} ip example.com</code>",
strings("ip_no_url_example").format(bot_username=c.me.username),
),
)
]
Expand Down
5 changes: 4 additions & 1 deletion locales/en-GB/ip.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"ip_err_no_ip": "You must specify the url, E.g.: <code>/ip example.com</code>"
"ip_err_no_ip": "You must specify the url, E.g.: <code>/ip example.com</code>",
"ip_info_inline": "Click here to see the IP info of {domain}.",
"ip_no_url": "You must specify the url.",
"ip_no_url_example": "You must specify the url, e.g.: <code>@{bot_username} ip example.com</code>."
}

0 comments on commit eafd9aa

Please sign in to comment.