From 16798e63bb5dd242938c2edfd2d86010b8f0bd7f Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Sun, 22 Oct 2023 22:27:27 +0500 Subject: [PATCH 01/24] Added timeout to listen/ask methods calls (probably fix bot updates) --- main.py | 118 ++++++++++++++++++++++++++++++---------------- utypes/bclient.py | 10 ++-- 2 files changed, 83 insertions(+), 45 deletions(-) diff --git a/main.py b/main.py index 5002ba8..c5f9a45 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,5 @@ import asyncio +from asyncio.exceptions import TimeoutError import datetime as dt import json from typing import Callable @@ -401,7 +402,10 @@ async def user_profile_info(client: BClient, session: UserSession, text = session.locale.steam_url_example if last_error is None else last_error text += '\n\n' + session.locale.bot_use_cancel - steam_url = await client.ask_message_silently(callback_query, text) + try: + steam_url = await client.ask_message_silently(callback_query, text, timeout=300) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_message(client, session, steam_url) @@ -471,11 +475,14 @@ async def user_game_stats(client: BClient, session: UserSession, callback_query: text = session.locale.steam_url_example if last_error is None else last_error text += '\n\n' + session.locale.bot_use_cancel - steam_url = await client.ask_message_silently(callback_query, text) + try: + steam_url = await client.ask_message_silently(callback_query, text, timeout=300) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_message(client, session, steam_url) - if steam_url.text == "/cancel": + if steam_url.text == '/cancel': await steam_url.delete() return await profile_info(client, session, callback_query) @@ -565,11 +572,14 @@ async def decode_crosshair(client: BClient, session: UserSession, text = session.locale.crosshair_decode_example if last_error is None else last_error text += '\n\n' + session.locale.bot_use_cancel - decode_input = await client.ask_message_silently(callback_query, text) + try: + decode_input = await client.ask_message_silently(callback_query, text) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_message(client, session, decode_input) - if decode_input.text == "/cancel": + if decode_input.text == '/cancel': await decode_input.delete() return await crosshair(client, session, callback_query) @@ -660,8 +670,11 @@ async def send_game_leaderboard(client: BClient, session: UserSession, callback_ await callback_query.edit_message_text(text, reply_markup=keyboards.leaderboard_markup(session.locale)) - chosen_region = await client.listen_callback(callback_query.message.chat.id, - callback_query.message.id) + try: + chosen_region = await client.listen_callback(callback_query.message.chat.id, + callback_query.message.id, timeout=300) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_callback(client, session, chosen_region) @@ -684,13 +697,17 @@ async def guns(_, session: UserSession, callback_query: CallbackQuery): @bot.on_callback_request(LK.gun_pistols) @bot.came_from(guns, 4) async def pistols(client: BClient, session: UserSession, callback_query: CallbackQuery, loop: bool = False): - if loop: - chosen_gun = await client.listen_callback(callback_query.message.chat.id, - callback_query.message.id) - else: - chosen_gun = await client.ask_callback_silently(callback_query, - session.locale.gun_select_pistol, - reply_markup=keyboards.pistols_markup(session.locale)) + try: + if loop: + chosen_gun = await client.listen_callback(callback_query.message.chat.id, + callback_query.message.id, timeout=300) + else: + chosen_gun = await client.ask_callback_silently(callback_query, + session.locale.gun_select_pistol, + reply_markup=keyboards.pistols_markup(session.locale), + timeout=300) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_callback(client, session, chosen_gun) @@ -708,13 +725,17 @@ async def pistols(client: BClient, session: UserSession, callback_query: Callbac @bot.on_callback_request(LK.gun_heavy) @bot.came_from(guns) async def heavy(client: BClient, session: UserSession, callback_query: CallbackQuery, loop: bool = False): - if loop: - chosen_gun = await client.listen_callback(callback_query.message.chat.id, - callback_query.message.id) - else: - chosen_gun = await client.ask_callback_silently(callback_query, - session.locale.gun_select_heavy, - reply_markup=keyboards.heavy_markup(session.locale)) + try: + if loop: + chosen_gun = await client.listen_callback(callback_query.message.chat.id, + callback_query.message.id, timeout=300) + else: + chosen_gun = await client.ask_callback_silently(callback_query, + session.locale.gun_select_heavy, + reply_markup=keyboards.heavy_markup(session.locale), + timeout=300) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_callback(client, session, chosen_gun) @@ -732,13 +753,17 @@ async def heavy(client: BClient, session: UserSession, callback_query: CallbackQ @bot.on_callback_request(LK.gun_smgs) @bot.came_from(guns) async def smgs(client: BClient, session: UserSession, callback_query: CallbackQuery, loop: bool = False): - if loop: - chosen_gun = await client.listen_callback(callback_query.message.chat.id, - callback_query.message.id) - else: - chosen_gun = await client.ask_callback_silently(callback_query, - session.locale.gun_select_smg, - reply_markup=keyboards.smgs_markup(session.locale)) + try: + if loop: + chosen_gun = await client.listen_callback(callback_query.message.chat.id, + callback_query.message.id, timeout=300) + else: + chosen_gun = await client.ask_callback_silently(callback_query, + session.locale.gun_select_smg, + reply_markup=keyboards.smgs_markup(session.locale), + timeout=300) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_callback(client, session, chosen_gun) @@ -755,13 +780,17 @@ async def smgs(client: BClient, session: UserSession, callback_query: CallbackQu @bot.on_callback_request(LK.gun_rifles) @bot.came_from(guns) async def rifles(client: BClient, session: UserSession, callback_query: CallbackQuery, loop: bool = False): - if loop: - chosen_gun = await client.listen_callback(callback_query.message.chat.id, - callback_query.message.id) - else: - chosen_gun = await client.ask_callback_silently(callback_query, - session.locale.gun_select_rifle, - reply_markup=keyboards.rifles_markup(session.locale)) + try: + if loop: + chosen_gun = await client.listen_callback(callback_query.message.chat.id, + callback_query.message.id, timeout=300) + else: + chosen_gun = await client.ask_callback_silently(callback_query, + session.locale.gun_select_rifle, + reply_markup=keyboards.rifles_markup(session.locale), + timeout=300) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_callback(client, session, chosen_gun) @@ -811,11 +840,15 @@ async def settings(_, session: UserSession, callback_query: CallbackQuery): async def language(client: BClient, session: UserSession, callback_query: CallbackQuery): keyboards.language_settings_markup.select_button_by_key(session.locale.lang_code) - chosen_lang = await client.ask_callback_silently( - callback_query, - session.locale.settings_language_choose.format(AVAILABLE_LANGUAGES.get(session.locale.lang_code)), - reply_markup=keyboards.language_settings_markup(session.locale) - ) + try: + chosen_lang = await client.ask_callback_silently( + callback_query, + session.locale.settings_language_choose.format(AVAILABLE_LANGUAGES.get(session.locale.lang_code)), + reply_markup=keyboards.language_settings_markup(session.locale), + timeout=300 + ) + except TimeoutError: + return await main_menu(client, session, callback_query, session_timeout=True) await log_callback(client, session, chosen_lang) @@ -851,7 +884,10 @@ async def leave_feedback(client: BClient, session: UserSession, message: Message text = session.locale.bot_feedback_text + '\n\n' + session.locale.bot_use_cancel - feedback = await client.ask_message(message.chat.id, text) + try: + feedback = await client.ask_message(message.chat.id, text) + except TimeoutError: + return await client.send_message(message.chat.id, 'Timed out.') # todo: добавить строку локализации if feedback.text == '/cancel': await feedback.delete() diff --git a/utypes/bclient.py b/utypes/bclient.py index c714712..412b1c9 100644 --- a/utypes/bclient.py +++ b/utypes/bclient.py @@ -250,15 +250,17 @@ async def listen_callback(self, timeout) async def ask_message_silently(self, callback_query: CallbackQuery, - text: str, *args, reply_markup: ExtendedIKM = None, **kwargs) -> Message: + text: str, *args, + reply_markup: ExtendedIKM = None, timeout: int = None, **kwargs) -> Message: """Asks for a message in the same message.""" await callback_query.edit_message_text(text, *args, reply_markup=reply_markup, **kwargs) - return await self.listen_message(callback_query.message.chat.id) + return await self.listen_message(callback_query.message.chat.id, timeout=timeout) async def ask_callback_silently(self, callback_query: CallbackQuery, - text: str, *args, reply_markup: ExtendedIKM = None, **kwargs) -> CallbackQuery: + text: str, *args, + reply_markup: ExtendedIKM = None, timeout: int = None, **kwargs) -> CallbackQuery: """Asks for a callback query in the same message.""" await callback_query.edit_message_text(text, *args, reply_markup=reply_markup, **kwargs) - return await self.listen_callback(callback_query.message.chat.id, callback_query.message.id) + return await self.listen_callback(callback_query.message.chat.id, callback_query.message.id, timeout=timeout) From d52f61decf7d5498b292c1ff91c4b7a1c0a456c0 Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 25 Oct 2023 15:53:40 +0500 Subject: [PATCH 02/24] Preserve formatting in /echo output --- plugins/incs2chat.py | 62 +++++++++++++++++++++++++++++--------------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/plugins/incs2chat.py b/plugins/incs2chat.py index c68dc83..c87da1d 100644 --- a/plugins/incs2chat.py +++ b/plugins/incs2chat.py @@ -1,14 +1,31 @@ import asyncio from pyrogram import Client, filters -from pyrogram.enums import ChatMembersFilter -from pyrogram.types import Message +from pyrogram.enums import ChatMembersFilter, MessageEntityType +from pyrogram.types import Message, MessageEntity # noinspection PyUnresolvedReferences import env import config +def correct_message_entity(entities: list[MessageEntity] | None, + original_text: str, new_text: str) -> list[MessageEntity] | None: + """Correct message entities (a.k.a. Markdown formatting) for edited text.""" + + if entities is None: + return + + length_diff = len(original_text) - len(new_text) + for entity in entities: + if entity.type == MessageEntityType.BOT_COMMAND: + del entity + else: + entity.offset -= length_diff + + return entities + + @Client.on_message(filters.chat(config.INCS2CHAT) & filters.command("ban")) async def ban(client: Client, message: Message): chat = await client.get_chat(config.INCS2CHAT) @@ -55,7 +72,7 @@ async def warn(client: Client, message: Message): await message.delete() -@Client.on_message(filters.chat(config.INCS2CHAT) & filters.command("echo")) +@Client.on_message(filters.chat(config.INCS2CHAT) & filters.command('echo')) async def echo(client: Client, message: Message): # todo: more attachments? chat = await client.get_chat(config.INCS2CHAT) admins = chat.get_members(filter=ChatMembersFilter.ADMINISTRATORS) @@ -65,6 +82,8 @@ async def echo(client: Client, message: Message): # todo: more attachments? if message.from_user.id not in admins: return + print(message) + if message.reply_to_message: reply_to = message.reply_to_message should_reply = True @@ -72,35 +91,36 @@ async def echo(client: Client, message: Message): # todo: more attachments? reply_to = message should_reply = False + if message.text: + text = message.text.removeprefix('/echo').strip() + entities = correct_message_entity(message.entities, message.text, text) + + if not text: + msg = await message.reply('Пустой текст.', quote=False) + await asyncio.sleep(5) + await msg.delete() + return + + return await reply_to.reply(text, entities=entities, quote=should_reply) + + caption = message.caption.removeprefix('/echo').strip() + entities = correct_message_entity(message.entities, message.caption, caption) + if message.animation: animation = message.animation.file_id - caption = message.caption.removeprefix('/echo').strip() - return await reply_to.reply_animation(animation, quote=should_reply, caption=caption) + return await reply_to.reply_animation(animation, quote=should_reply, caption=caption, caption_entities=entities) if message.audio: audio = message.audio.file_id - caption = message.caption.removeprefix('/echo').strip() - return await reply_to.reply_audio(audio, quote=should_reply, caption=caption) + return await reply_to.reply_audio(audio, quote=should_reply, caption=caption, caption_entities=entities) if message.photo: photo = message.photo.file_id - caption = message.caption.removeprefix('/echo').strip() - return await reply_to.reply_photo(photo, quote=should_reply, caption=caption) - - if message.text: - text = message.text.removeprefix('/echo').strip() - if not text: - msg = await message.reply("Пустой текст.", quote=False) - await asyncio.sleep(5) - await msg.delete() - return - - return await reply_to.reply(text, quote=should_reply) + return await reply_to.reply_photo(photo, quote=should_reply, caption=caption, caption_entities=entities) if message.video: video = message.video.file_id - caption = message.caption.removeprefix('/echo').strip() - return await reply_to.reply_video(video, quote=should_reply, caption=caption) + return await reply_to.reply_video(video, quote=should_reply, caption=caption, caption_entities=entities) @Client.on_message(filters.linked_channel & filters.chat(config.INCS2CHAT)) From a7c97d6d06069a5b6a672577db4f782eef271ef1 Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 25 Oct 2023 15:57:59 +0500 Subject: [PATCH 03/24] Disable web page previews in /echo text --- plugins/incs2chat.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/incs2chat.py b/plugins/incs2chat.py index c87da1d..f841b0e 100644 --- a/plugins/incs2chat.py +++ b/plugins/incs2chat.py @@ -82,8 +82,6 @@ async def echo(client: Client, message: Message): # todo: more attachments? if message.from_user.id not in admins: return - print(message) - if message.reply_to_message: reply_to = message.reply_to_message should_reply = True @@ -101,7 +99,7 @@ async def echo(client: Client, message: Message): # todo: more attachments? await msg.delete() return - return await reply_to.reply(text, entities=entities, quote=should_reply) + return await reply_to.reply(text, entities=entities, quote=should_reply, disable_web_page_preview=False) caption = message.caption.removeprefix('/echo').strip() entities = correct_message_entity(message.entities, message.caption, caption) From b8d88b64df680e4520992fc1b97091c72f497f0f Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 25 Oct 2023 16:00:39 +0500 Subject: [PATCH 04/24] Disable web page previews in /echo text (fr) --- plugins/incs2chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/incs2chat.py b/plugins/incs2chat.py index f841b0e..1cf0468 100644 --- a/plugins/incs2chat.py +++ b/plugins/incs2chat.py @@ -99,7 +99,7 @@ async def echo(client: Client, message: Message): # todo: more attachments? await msg.delete() return - return await reply_to.reply(text, entities=entities, quote=should_reply, disable_web_page_preview=False) + return await reply_to.reply(text, entities=entities, quote=should_reply, disable_web_page_preview=True) caption = message.caption.removeprefix('/echo').strip() entities = correct_message_entity(message.entities, message.caption, caption) From 0be7b10d7280998f148e9d0944e9792ad578ed29 Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 1 Nov 2023 22:45:09 +0500 Subject: [PATCH 05/24] Fixed uncaught exception at decode_crosshair, removed wake_up (now it's useless) --- main.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/main.py b/main.py index c5f9a45..5c246cf 100644 --- a/main.py +++ b/main.py @@ -9,7 +9,7 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler from babel.dates import format_datetime from csxhair import Crosshair -from pyrogram import filters, idle, raw +from pyrogram import filters, idle from pyrogram.enums import ChatType, ChatAction, ParseMode from pyrogram.errors import MessageDeleteForbidden, MessageNotModified from pyrogram.types import CallbackQuery, Message @@ -585,8 +585,9 @@ async def decode_crosshair(client: BClient, session: UserSession, await callback_query.edit_message_text(session.locale.bot_loading) - _crosshair = Crosshair.decode(decode_input.text) - if _crosshair is None: + try: + _crosshair = Crosshair.decode(decode_input.text) + except ValueError: await decode_input.delete() return await decode_crosshair(client, session, callback_query, last_error=session.locale.crosshair_decode_error) @@ -961,17 +962,9 @@ async def log_ping(_, __, callback_query: CallbackQuery): await callback_query.answer('Yes, I AM working!') -async def wake_up(client: BClient): - # just to be safe - if dt.datetime.now() - client.last_update_time > dt.timedelta(seconds=client.UPDATES_WATCHDOG_INTERVAL): - await client.invoke(raw.functions.updates.GetState()) - - async def main(): scheduler = AsyncIOScheduler() scheduler.add_job(bot.clear_timeout_sessions, 'interval', minutes=30) - scheduler.add_job(wake_up, 'interval', seconds=bot.UPDATES_WATCHDOG_INTERVAL, - args=(bot,)) scheduler.add_job(log, 'interval', hours=8, args=(bot, "Report: I\'m still active!"), kwargs={'reply_markup': keyboards.log_ping_markup}) From dd2a5cdd4c42c84a46519bdc16f19f66c73f9f29 Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 1 Nov 2023 23:02:20 +0500 Subject: [PATCH 06/24] Regular bot stats --- functions/info_formatters.py | 30 ++++++++++++++++++++++++++++++ main.py | 24 +++++++++++++++++++++--- plugins/inline.py | 1 + utypes/bclient.py | 23 +++++++++++++++++++++++ 4 files changed, 75 insertions(+), 3 deletions(-) diff --git a/functions/info_formatters.py b/functions/info_formatters.py index 35d22b4..ba56b44 100644 --- a/functions/info_formatters.py +++ b/functions/info_formatters.py @@ -11,6 +11,13 @@ from utypes import States, LeaderboardStats +MINUTE = 60 +HOUR = 60 * MINUTE +DAY = 24 * HOUR +MONTH = 30 * DAY +YEAR = 365 * DAY + + VALVE_TIMEZONE = ZoneInfo('America/Los_Angeles') CLOCKS = ('🕛', '🕐', '🕑', '🕒', '🕓', '🕔', '🕕', '🕖', '🕗', '🕘', '🕙', '🕚') @@ -28,6 +35,29 @@ 'southamerica': 'sa'} +def format_timedelta(td) -> str: + time_elapsed = int(td.total_seconds()) + + time_elapsed_strf = [] + if (elapsed_years := time_elapsed // YEAR) != 0: + time_elapsed_strf.append(f'{elapsed_years} {"year" if elapsed_years == 1 else "years"}') + if (elapsed_months := time_elapsed % YEAR // MONTH) != 0: + time_elapsed_strf.append(f'{elapsed_months} {"month" if elapsed_months == 1 else "months"}') + if (elapsed_days := time_elapsed % MONTH // DAY) != 0: + time_elapsed_strf.append(f'{elapsed_days} {"day" if elapsed_days == 1 else "days"}') + if (elapsed_hours := time_elapsed % DAY // HOUR) != 0: + time_elapsed_strf.append(f'{elapsed_hours} {"hour" if elapsed_hours == 1 else "hours"}') + if (elapsed_minutes := time_elapsed % HOUR // MINUTE) != 0: + time_elapsed_strf.append(f'{elapsed_minutes} {"minute" if elapsed_minutes == 1 else "minutes"}') + elapsed_seconds = time_elapsed % MINUTE // 1 + time_elapsed_strf.append(f'{elapsed_seconds} {"second" if elapsed_seconds == 1 else "seconds"}') + + if len(time_elapsed_strf) > 1: + time_elapsed_strf = time_elapsed_strf[:-2] + [" and ".join(time_elapsed_strf[-2:])] + + return f'{"~" if elapsed_years or elapsed_months else ""}{", ".join(time_elapsed_strf)}' + + def format_server_status(data, locale: Locale) -> str: if data is States.UNKNOWN: return locale.error_internal diff --git a/main.py b/main.py index 5c246cf..a3d6a25 100644 --- a/main.py +++ b/main.py @@ -66,6 +66,7 @@ async def inner(client: BClient, session: UserSession, callback_query: CallbackQ logging.exception('Caught exception!') await client.send_message(config.LOGCHANNEL, f'❗️ {traceback.format_exc()}', disable_notification=True, parse_mode=ParseMode.DISABLED) + client.rstats.exceptions_caught += 1 await something_went_wrong(client, session, callback_query) return inner @@ -962,12 +963,29 @@ async def log_ping(_, __, callback_query: CallbackQuery): await callback_query.answer('Yes, I AM working!') +async def regular_stats_report(client: BClient): + now = dt.datetime.now(dt.UTC) + + text = (f'📊 **Some stats for the past 8 hours:**\n' + f'\n' + f'• Unique users served: {client.rstats.unique_users_served}\n' + f'• Callback queries handled: {client.rstats.callback_queries_handled}\n' + f'• Inline queries handled: {client.rstats.inline_queries_handled}\n' + f'• Exceptions caught: {client.rstats.exceptions_caught}\n' + f'\n' + f'📁 **Other stats:**\n' + f'\n' + f'• Bot started up at: {now:%Y-%m-%d %H:%M:%S} (UTC)\n' + f'• Is working for: {info_formatters.format_timedelta(now - client.startup_dt)}') + await log(client, text, reply_markup=keyboards.log_ping_markup) + client.rstats.clear() + + async def main(): scheduler = AsyncIOScheduler() scheduler.add_job(bot.clear_timeout_sessions, 'interval', minutes=30) - scheduler.add_job(log, 'interval', hours=8, - args=(bot, "Report: I\'m still active!"), - kwargs={'reply_markup': keyboards.log_ping_markup}) + scheduler.add_job(regular_stats_report, 'interval', hours=8, + args=(bot,)) scheduler.start() diff --git a/plugins/inline.py b/plugins/inline.py index b81f5d8..d87a4ad 100644 --- a/plugins/inline.py +++ b/plugins/inline.py @@ -64,6 +64,7 @@ async def sync_user_data_inline(client: BClient, inline_query: InlineQuery): query = inline_query.query.strip() + client.rstats.inline_queries_handled += 1 # if-chain because it's a plugin if is_user_stats_page(inline_query): return await share_inline(client, session, inline_query) diff --git a/utypes/bclient.py b/utypes/bclient.py index 412b1c9..5841fa3 100644 --- a/utypes/bclient.py +++ b/utypes/bclient.py @@ -1,3 +1,4 @@ +from dataclasses import dataclass, fields import datetime as dt from functools import wraps import logging @@ -71,6 +72,18 @@ async def sync_with_db(self): await db_sess.commit() +@dataclass(slots=True) +class BotRegularStats: + callback_queries_handled: int = 0 + inline_queries_handled: int = 0 + unique_users_served: int = 0 + exceptions_caught: int = 0 + + def clear(self): + for field in fields(self): + setattr(self, field.name, 0) + + class BClient(Client): """ Custom pyrogram.Client class to add custom properties and methods and stop PyCharm annoy me. @@ -89,6 +102,9 @@ def __init__(self, *args, **kwargs): self.sessions_timeout = dt.timedelta(hours=1) self.latest_log_dt = dt.datetime.now() # todo: implement logs functions in BClient? + self.startup_dt = None + self.rstats = BotRegularStats() + @property def sessions(self) -> UserSessions: return self._sessions @@ -101,6 +117,10 @@ def can_log(self) -> bool: def can_log_after_time(self) -> dt.timedelta: return self.LOGS_TIMEOUT - (dt.datetime.now() - self.latest_log_dt) + async def start(self): + await super().start() + self.startup_dt = dt.datetime.now(dt.UTC) + async def register_session(self, user: User, *, force_lang: str = None) -> UserSession: logging.info(f'Registering session with user {user.id=}, {user.username=}, {user.language_code=}') @@ -119,6 +139,7 @@ async def register_session(self, user: User, *, force_lang: str = None) -> UserS logging.info(f'Got existing record in db. {dbuser=}') self._sessions[user.id] = UserSession(dbuser, force_lang=force_lang) + self.rstats.unique_users_served += 1 return self._sessions[user.id] async def clear_timeout_sessions(self): @@ -170,6 +191,8 @@ async def get_func_by_callback(self, session: UserSession, callback_query: Callb if '_' not in self._available_functions: return func, args, kwargs = self._available_functions['_'] + + self.rstats.callback_queries_handled += 1 return await func(self, session, callback_query, *args, **kwargs) def came_from(self, f: callable, _id: int = None): From 276383696c321c6720c140de314a8576764464ab Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 1 Nov 2023 23:10:07 +0500 Subject: [PATCH 07/24] Little correction in Russian language --- l10n/data/ru.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/l10n/data/ru.json b/l10n/data/ru.json index 7a24bda..cca752d 100644 --- a/l10n/data/ru.json +++ b/l10n/data/ru.json @@ -387,7 +387,7 @@ "Количество игроков: {:,}" ], "notifs_new_monthlyunique": [ - "📊 Количество ежемесячных уникальных игроков Counter-Strike было обновлено!", + "📊 Количество ежемесячных уникальных игроков Counter-Strike было обновлено.", "", "{:,} ➡️ {:,}" ], From 7122e9ea0e6f078586cd43d86410e515ff077fca Mon Sep 17 00:00:00 2001 From: aquaismissing Date: Fri, 3 Nov 2023 22:52:28 +0000 Subject: [PATCH 08/24] Updated Indian DCs --- collectors/core.py | 5 +++-- l10n/data/be.json | 1 + l10n/data/en.json | 1 + l10n/data/fa.json | 1 + l10n/data/it.json | 1 + l10n/data/ru.json | 1 + l10n/data/tags.json | 1 + l10n/data/tr.json | 1 + l10n/data/uk.json | 1 + l10n/data/uz.json | 1 + l10n/l10n.py | 1 + utypes/datacenters.py | 4 ++++ 12 files changed, 17 insertions(+), 2 deletions(-) diff --git a/collectors/core.py b/collectors/core.py index d2d88bb..dc91c80 100644 --- a/collectors/core.py +++ b/collectors/core.py @@ -44,8 +44,9 @@ ('peru', 'lima'): 'Peru', ('argentina', 'buenos_aires'): 'Argentina', 'hongkong': 'Hong Kong', - ('india', 'mumbai'): 'India', - ('india', 'chennai'): 'India East', + ('india', 'mumbai'): 'India Mumbai', + ('india', 'chennai'): 'India Chennai', + ('india', 'bombay'): 'India Bombay', ('china', 'shanghai'): 'China Shanghai', ('china', 'tianjin'): 'China Tianjin', ('china', 'guangzhou'): 'China Guangzhou', diff --git a/l10n/data/be.json b/l10n/data/be.json index 2e06acd..d8c980e 100644 --- a/l10n/data/be.json +++ b/l10n/data/be.json @@ -163,6 +163,7 @@ "dc_india_title": "дата-цэнтраў Індыі", "dc_india_inline_title": "Індыйскія ДЦ", "dc_india_mumbai": "Мумбаі", + "dc_india_bombay": "Bombay", "dc_india_chennai": "Чэннай", "dc_japan": "Японія", "dc_japan_title": "дата-цэнтра Японіі", diff --git a/l10n/data/en.json b/l10n/data/en.json index 49f907f..56d33f5 100644 --- a/l10n/data/en.json +++ b/l10n/data/en.json @@ -164,6 +164,7 @@ "dc_india_inline_title": "Indian DC", "dc_india_mumbai": "Mumbai", "dc_india_chennai": "Chennai", + "dc_india_bombay": "Bombay", "dc_japan": "Japan", "dc_japan_title": "Japanʼs DC", "dc_japan_inline_title": "Japanese DC", diff --git a/l10n/data/fa.json b/l10n/data/fa.json index 302ed3d..2a4b3cc 100644 --- a/l10n/data/fa.json +++ b/l10n/data/fa.json @@ -163,6 +163,7 @@ "dc_india_title": "هندوستان", "dc_india_inline_title": "دیتا سنتر هند", "dc_india_mumbai": "مامبی", + "dc_india_bombay": "Bombay", "dc_india_chennai": "چنای", "dc_japan": "ژاپن", "dc_japan_title": "ژاپن", diff --git a/l10n/data/it.json b/l10n/data/it.json index 4dc1861..d717ef0 100644 --- a/l10n/data/it.json +++ b/l10n/data/it.json @@ -163,6 +163,7 @@ "dc_india_title": "del CED dell’ India", "dc_india_inline_title": "CED Indiano", "dc_india_mumbai": "Mumbai", + "dc_india_bombay": "Bombay", "dc_india_chennai": "Chennai", "dc_japan": "Giappone", "dc_japan_title": "del CED del Giappone", diff --git a/l10n/data/ru.json b/l10n/data/ru.json index cca752d..09b2868 100644 --- a/l10n/data/ru.json +++ b/l10n/data/ru.json @@ -163,6 +163,7 @@ "dc_india_title": "дата-центров Индии", "dc_india_inline_title": "Индийские ДЦ", "dc_india_mumbai": "Мумбаи", + "dc_india_bombay": "Bombay", "dc_india_chennai": "Ченнай", "dc_japan": "Япония", "dc_japan_title": "дата-центра Японии", diff --git a/l10n/data/tags.json b/l10n/data/tags.json index 3dfe888..cf74217 100644 --- a/l10n/data/tags.json +++ b/l10n/data/tags.json @@ -341,6 +341,7 @@ "🇮🇳", "india", "mumbai", + "bombay", "chennai", "индия", "мумбаи", diff --git a/l10n/data/tr.json b/l10n/data/tr.json index ff44f78..391486d 100644 --- a/l10n/data/tr.json +++ b/l10n/data/tr.json @@ -163,6 +163,7 @@ "dc_india_title": "Hindistan'daki veri merkezleri", "dc_india_inline_title": "Hint DC'leri", "dc_india_mumbai": "Bombay", + "dc_india_bombay": "Bombay", "dc_india_chennai": "Chennai", "dc_japan": "Japonya", "dc_japan_title": "Japonya'daki veri merkezi", diff --git a/l10n/data/uk.json b/l10n/data/uk.json index 2f4e775..7a2e194 100644 --- a/l10n/data/uk.json +++ b/l10n/data/uk.json @@ -163,6 +163,7 @@ "dc_india_title": "дата-центрів Індії", "dc_india_inline_title": "Індійські ДЦ", "dc_india_mumbai": "Мумбаї", + "dc_india_bombay": "Bombay", "dc_india_chennai": "Ченнай", "dc_japan": "Японія", "dc_japan_title": "дата-центру Японії", diff --git a/l10n/data/uz.json b/l10n/data/uz.json index f75ad1c..3fd917e 100644 --- a/l10n/data/uz.json +++ b/l10n/data/uz.json @@ -163,6 +163,7 @@ "dc_india_title": "Hindistondagi data-centre", "dc_india_inline_title": "Hindiston DC", "dc_india_mumbai": "Mumbay", + "dc_india_bombay": "Bombay", "dc_india_chennai": "Chennai", "dc_japan": "Yaponiya", "dc_japan_title": "Yaponiyadagi data-centre", diff --git a/l10n/l10n.py b/l10n/l10n.py index f709583..27eb4e9 100644 --- a/l10n/l10n.py +++ b/l10n/l10n.py @@ -171,6 +171,7 @@ class Locale(SLocale): dc_india_title: str # Indiaʼs DC dc_india_inline_title: str # Indian DC dc_india_mumbai: str # Mumbai + dc_india_bombay: str # Bombay dc_india_chennai: str # Chennai dc_japan: str # Japan dc_japan_title: str # Japanʼs DC diff --git a/utypes/datacenters.py b/utypes/datacenters.py index 21e4a90..ec998af 100644 --- a/utypes/datacenters.py +++ b/utypes/datacenters.py @@ -315,6 +315,10 @@ class DatacenterAtlas: Datacenter( "chennai", l10n_key_title=LK.dc_india_chennai + ), + Datacenter( + "bombay", + l10n_key_title=LK.dc_india_bombay ) ], "🇮🇳", From 72fc3eeac4db73fdf9fa013b795afd4a31ab3e82 Mon Sep 17 00:00:00 2001 From: aquaismissing Date: Sat, 4 Nov 2023 01:02:04 +0000 Subject: [PATCH 09/24] Updated USA DCs --- collectors/core.py | 12 ++--- functions/datacenter_handlers.py | 8 +-- keyboards.py | 6 +-- l10n/data/be.json | 29 +++++------ l10n/data/en.json | 31 ++++++----- l10n/data/fa.json | 29 +++++------ l10n/data/it.json | 29 +++++------ l10n/data/ru.json | 29 +++++------ l10n/data/tags.json | 69 +++---------------------- l10n/data/tr.json | 46 +++++++++++------ l10n/data/uk.json | 29 +++++------ l10n/data/uz.json | 29 +++++------ l10n/l10n.py | 29 +++++------ l10n/tags.py | 4 +- main.py | 12 ++--- plugins/inline.py | 12 ++--- utypes/datacenters.py | 89 +++++++++++--------------------- 17 files changed, 206 insertions(+), 286 deletions(-) diff --git a/collectors/core.py b/collectors/core.py index dc91c80..4802d24 100644 --- a/collectors/core.py +++ b/collectors/core.py @@ -33,12 +33,12 @@ ('netherlands', 'amsterdam'): 'EU Holland', ('austria', 'vienna'): 'EU Austria', ('poland', 'warsaw'): 'EU Poland', - ('us_north', 'northcentral', 'chicago'): 'US Chicago', - ('us_north', 'northeast', 'sterling'): 'US Virginia', - ('us_north', 'northwest', 'new_york'): 'US NewYork', - ('us_north', 'northwest', 'seattle'): 'US Seattle', - ('us_south', 'southwest', 'los_angeles'): 'US California', - ('us_south', 'southeast', 'atlanta'): 'US Atlanta', + ('us_east', 'chicago'): 'US Chicago', + ('us_east', 'sterling'): 'US Virginia', + ('us_east', 'new_york'): 'US NewYork', + ('us_east', 'atlanta'): 'US Atlanta', + ('us_west', 'seattle'): 'US Seattle', + ('us_west', 'los_angeles'): 'US California', ('brazil', 'sao_paulo'): 'Brazil', ('chile', 'santiago'): 'Chile', ('peru', 'lima'): 'Peru', diff --git a/functions/datacenter_handlers.py b/functions/datacenter_handlers.py index 6a9f59a..72f3845 100644 --- a/functions/datacenter_handlers.py +++ b/functions/datacenter_handlers.py @@ -89,12 +89,12 @@ def sweden(locale: Locale): return _format_dc_data(DatacenterAtlas.SWEDEN, locale) -def us_north(locale: Locale): - return _format_dc_data(DatacenterAtlas.US_NORTH, locale) +def us_east(locale: Locale): + return _format_dc_data(DatacenterAtlas.US_EAST, locale) -def us_south(locale: Locale): - return _format_dc_data(DatacenterAtlas.US_SOUTH, locale) +def us_west(locale: Locale): + return _format_dc_data(DatacenterAtlas.US_WEST, locale) def argentina(locale: Locale): diff --git a/keyboards.py b/keyboards.py index d0596ee..16ac94d 100644 --- a/keyboards.py +++ b/keyboards.py @@ -208,11 +208,11 @@ def select_button_by_key(self, key: str): # DC USA -_us_northwest = ExtendedIKB(LK.dc_north, LK.dc_us_north) -_us_southwest = ExtendedIKB(LK.dc_south, LK.dc_us_south) +_us_east = ExtendedIKB(LK.dc_east, LK.dc_us_east) +_us_west = ExtendedIKB(LK.dc_west, LK.dc_us_west) dc_us_markup = ExtendedIKM([ - [_us_northwest, _us_southwest], + [_us_east, _us_west], [back_button] ]) diff --git a/l10n/data/be.json b/l10n/data/be.json index d8c980e..e959c79 100644 --- a/l10n/data/be.json +++ b/l10n/data/be.json @@ -93,6 +93,8 @@ ], "dc_north": "Поўнач", "dc_south": "Поўдзень", + "dc_east": "East", + "dc_west": "West", "dc_africa_title": "дата-цэнтра Паўднёвай Афрыкі", "dc_africa_inline_title": "Афрыканскі ДЦ", "dc_africa_johannesburg": "Ёханэсбург", @@ -128,21 +130,18 @@ "dc_spain_inline_title": "Іспанскі ДЦ", "dc_spain_madrid": "Мадрыд", "dc_us": "ЗША", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "ДЦ паўночнай часткі ЗША", - "dc_us_north_central_title": "паўночна-цэнтральнага дата-цэнтра", - "dc_us_north_central_chicago": "Чыкага", - "dc_us_north_east_title": "паўночна-ўсходняга дата-цэнтра", - "dc_us_north_east_sterling": "Стэрлінг", - "dc_us_north_west_title": "паўночна-заходняга дата-цэнтра", - "dc_us_north_west_new_york": "Нью-Ёрк", - "dc_us_north_west_seattle": "Сіэтл", - "dc_us_south_inline_title": "ДЦ паўднёвай часткі ЗША", - "dc_us_south_east_title": "паўднёва-ўсходняга дата-цэнтра", - "dc_us_south_east_atlanta": "Атланта", - "dc_us_south_west_title": "паўднёва-заходняга дата-цэнтра", - "dc_us_south_west_los_angeles": "Лос-Анджэлес", + "dc_us_east": "dc_us_east / internally used key, no need to translate it", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", + "dc_us_east_title": "East USA DC", + "dc_us_east_inline_title": "Eastern USA DC", + "dc_us_chicago": "Чыкага", + "dc_us_sterling": "Стэрлінг", + "dc_us_new_york": "Нью-Ёрк", + "dc_us_atlanta": "Атланта", + "dc_us_west_title": "West USA DC", + "dc_us_west_inline_title": "Western USA DC", + "dc_us_seattle": "Сіэтл", + "dc_us_los_angeles": "Лос-Анджэлес", "dc_argentina": "Аргенціна", "dc_argentina_title": "дата-цэнтра Аргенціны", "dc_argentina_inline_title": "Аргентынскі ДЦ", diff --git a/l10n/data/en.json b/l10n/data/en.json index 56d33f5..5543d41 100644 --- a/l10n/data/en.json +++ b/l10n/data/en.json @@ -93,6 +93,8 @@ ], "dc_north": "North", "dc_south": "South", + "dc_east": "East", + "dc_west": "West", "dc_africa_title": "South Africaʼs DC", "dc_africa_inline_title": "African DC", "dc_africa_johannesburg": "Johannesburg", @@ -128,21 +130,18 @@ "dc_spain_inline_title": "Spanish DC", "dc_spain_madrid": "Madrid", "dc_us": "USA", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "Northern USA DC", - "dc_us_north_central_title": "Northcentral DC", - "dc_us_north_central_chicago": "Chicago", - "dc_us_north_east_title": "Northeast DC", - "dc_us_north_east_sterling": "Sterling", - "dc_us_north_west_title": "Northwest DC", - "dc_us_north_west_new_york": "New York", - "dc_us_north_west_seattle": "Seattle", - "dc_us_south_inline_title": "Southern USA DC", - "dc_us_south_east_title": "Southeast DC", - "dc_us_south_east_atlanta": "Atlanta", - "dc_us_south_west_title": "Southwest DC", - "dc_us_south_west_los_angeles": "Los Angeles", + "dc_us_east": "dc_us_east / internally used key, no need to translate it", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", + "dc_us_east_title": "East USA DC", + "dc_us_east_inline_title": "Eastern USA DC", + "dc_us_chicago": "Chicago", + "dc_us_sterling": "Sterling", + "dc_us_new_york": "New York", + "dc_us_atlanta": "Atlanta", + "dc_us_west_title": "West USA DC", + "dc_us_west_inline_title": "Western USA DC", + "dc_us_seattle": "Seattle", + "dc_us_los_angeles": "Los Angeles", "dc_argentina": "Argentina", "dc_argentina_title": "Argentinaʼs DC", "dc_argentina_inline_title": "Argentinian DC", @@ -163,8 +162,8 @@ "dc_india_title": "Indiaʼs DC", "dc_india_inline_title": "Indian DC", "dc_india_mumbai": "Mumbai", - "dc_india_chennai": "Chennai", "dc_india_bombay": "Bombay", + "dc_india_chennai": "Chennai", "dc_japan": "Japan", "dc_japan_title": "Japanʼs DC", "dc_japan_inline_title": "Japanese DC", diff --git a/l10n/data/fa.json b/l10n/data/fa.json index 2a4b3cc..6daae45 100644 --- a/l10n/data/fa.json +++ b/l10n/data/fa.json @@ -93,6 +93,8 @@ ], "dc_north": "شمال", "dc_south": "جنوب", + "dc_east": "East", + "dc_west": "West", "dc_africa_title": "افریقاجنوبی ", "dc_africa_inline_title": "افریقایی ", "dc_africa_johannesburg": "جواهنسنبرگ", @@ -128,21 +130,18 @@ "dc_spain_inline_title": "مرکز داده اسپانیا", "dc_spain_madrid": "مادرید", "dc_us": "آمریکا", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "آمریکای شمالی ", - "dc_us_north_central_title": "شمال مرکزی ", - "dc_us_north_central_chicago": "شیکاگو", - "dc_us_north_east_title": "شمال شرقی", - "dc_us_north_east_sterling": "استرلینگ", - "dc_us_north_west_title": "شمال غربی", - "dc_us_north_west_new_york": "نیویورک", - "dc_us_north_west_seattle": "سیاتل", - "dc_us_south_inline_title": "امریکا جنوبی", - "dc_us_south_east_title": "جنوب شرقی", - "dc_us_south_east_atlanta": "اتلانتا", - "dc_us_south_west_title": "جنوب شرقی", - "dc_us_south_west_los_angeles": "لس آنجلس", + "dc_us_east": "dc_us_east / internally used key, no need to translate it", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", + "dc_us_east_title": "East USA DC", + "dc_us_east_inline_title": "Eastern USA DC", + "dc_us_chicago": "شیکاگو", + "dc_us_sterling": "استرلینگ", + "dc_us_new_york": "نیویورک", + "dc_us_atlanta": "اتلانتا", + "dc_us_west_title": "West USA DC", + "dc_us_west_inline_title": "Western USA DC", + "dc_us_seattle": "سیاتل", + "dc_us_los_angeles": "لس آنجلس", "dc_argentina": "آرژانتین", "dc_argentina_title": "آرژانتین", "dc_argentina_inline_title": "مرکز داده آرژانتینی", diff --git a/l10n/data/it.json b/l10n/data/it.json index d717ef0..8481905 100644 --- a/l10n/data/it.json +++ b/l10n/data/it.json @@ -93,6 +93,8 @@ ], "dc_north": "Nord", "dc_south": "Sud", + "dc_east": "East", + "dc_west": "West", "dc_africa_title": "del CED del Sud Africa", "dc_africa_inline_title": "CED Africano", "dc_africa_johannesburg": "Johannesburg", @@ -128,21 +130,18 @@ "dc_spain_inline_title": "CED Spagnolo", "dc_spain_madrid": "Madrid", "dc_us": "USA", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "CED degli Stati Uniti Settentrionali", - "dc_us_north_central_title": "del CED Centro-settentrionale", - "dc_us_north_central_chicago": "Chicago", - "dc_us_north_east_title": "del CED del Nord-Est ", - "dc_us_north_east_sterling": "Sterling", - "dc_us_north_west_title": "del CED del Nord-Ovest", - "dc_us_north_west_new_york": "New York", - "dc_us_north_west_seattle": "Seattle", - "dc_us_south_inline_title": "CED degli Stati Uniti Meridionali", - "dc_us_south_east_title": "del CED del Sud-Est", - "dc_us_south_east_atlanta": "Atlanta", - "dc_us_south_west_title": "del CED del Sud-Ovest", - "dc_us_south_west_los_angeles": "Los Angeles", + "dc_us_east": "dc_us_east / internally used key, no need to translate it", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", + "dc_us_east_title": "East USA DC", + "dc_us_east_inline_title": "Eastern USA DC", + "dc_us_chicago": "Chicago", + "dc_us_sterling": "Sterling", + "dc_us_new_york": "New York", + "dc_us_atlanta": "Atlanta", + "dc_us_west_title": "West USA DC", + "dc_us_west_inline_title": "Western USA DC", + "dc_us_seattle": "Seattle", + "dc_us_los_angeles": "Los Angeles", "dc_argentina": "Argentina", "dc_argentina_title": "del CED dell’Argentina", "dc_argentina_inline_title": "CED Argentino", diff --git a/l10n/data/ru.json b/l10n/data/ru.json index 09b2868..9c91c3d 100644 --- a/l10n/data/ru.json +++ b/l10n/data/ru.json @@ -93,6 +93,8 @@ ], "dc_north": "Север", "dc_south": "Юг", + "dc_east": "Восток", + "dc_west": "Запад", "dc_africa_title": "дата-центра Южной Африки", "dc_africa_inline_title": "Африканский ДЦ", "dc_africa_johannesburg": "Йоханнесбург", @@ -128,21 +130,18 @@ "dc_spain_inline_title": "Испанский ДЦ", "dc_spain_madrid": "Мадрид", "dc_us": "США", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "ДЦ северной части США", - "dc_us_north_central_title": "северо-центрального дата-центра", - "dc_us_north_central_chicago": "Чикаго", - "dc_us_north_east_title": "северо-восточного дата-центра", - "dc_us_north_east_sterling": "Стерлинг", - "dc_us_north_west_title": "северо-западного дата-центра", - "dc_us_north_west_new_york": "Нью-Йорк", - "dc_us_north_west_seattle": "Сиэтл", - "dc_us_south_inline_title": "ДЦ южной части США", - "dc_us_south_east_title": "юго-восточного дата-центра", - "dc_us_south_east_atlanta": "Атланта", - "dc_us_south_west_title": "юго-западного дата-центра", - "dc_us_south_west_los_angeles": "Лос-Анджелес", + "dc_us_east": "dc_us_east / internally used key, no need to translate it", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", + "dc_us_east_title": "восточных дата-центров США", + "dc_us_east_inline_title": "ДЦ восточной части США", + "dc_us_chicago": "Чикаго", + "dc_us_sterling": "Стерлинг", + "dc_us_new_york": "Нью-Йорк", + "dc_us_atlanta": "Атланта", + "dc_us_west_title": "западных дата-центров США", + "dc_us_west_inline_title": "ДЦ западной части США", + "dc_us_seattle": "Сиэтл", + "dc_us_los_angeles": "Лос-Анджелес", "dc_argentina": "Аргентина", "dc_argentina_title": "дата-центра Аргентины", "dc_argentina_inline_title": "Аргентинский ДЦ", diff --git a/l10n/data/tags.json b/l10n/data/tags.json index cf74217..5e57b51 100644 --- a/l10n/data/tags.json +++ b/l10n/data/tags.json @@ -233,8 +233,6 @@ "united states of america", "америка", "амерыка", - "запад", - "захад", "соединённые штаты америки", "злучаныя штаты амерыкі", "сша", @@ -244,90 +242,37 @@ "آمریکا", "stati uniti d'america" ], - "dc_us_north": [ - "northcentral", - "northeast", - "northweast", - "north central", + "dc_us_east": [ "east", - "west", "chicago", "sterling", - "moses lake", - "северо-центр", - "северо-восток", - "северо-запад", - "северо центр", - "северо восток", - "северо запад", - "центр", - "цэнтр", + "new york", + "atlanta", "восток", "чикаго", + "атланта", "чыкага", "стерлинг", "стэрлінг", - "мозез лейк", - "мазэс лэйк", - "shimoli-markaziy", - "shimoli-sharqiy", - "shimoli-g'arbiy", - "shimoliy", - "markaziy", "sharqiy", - "g'arbiy", "chikago", - "mozes leyk", "чікаго", "کانادا", "شیکاگو", - "centro-settentrionale", - "centro settentrionale", - "nord-est", - "nord est", - "nord-ovest", - "nord ovest", - "centro-nord", - "centro nord", - "centro", - "nord", - "est", - "ovest" + "est" ], - "dc_us_south": [ - "southeast", - "southweast", - "south", - "east", + "dc_us_west": [ "west", "los angeles", - "atlanta", - "юго-запад", - "юго-восток", - "юго запад", - "юго восток", - "восток", + "seattle", "запад", "лос-анджелес", "лос анджелес", "лос-анджэлес", "лос анджэлес", - "атланта", - "janubi-sharqiy", - "janibi-g'arbiy", - "janubi sharqiy", - "janibi g'arbiy", - "janubiy", - "sharqiy", "g'arbiy", "los anjeles", "لس آنچلس", - "sud-est", - "sud est", - "sud-ovest", - "sud ovest", - "sud", - "est", "ovest" ], "dc_asia": [ diff --git a/l10n/data/tr.json b/l10n/data/tr.json index 391486d..cdf4ada 100644 --- a/l10n/data/tr.json +++ b/l10n/data/tr.json @@ -93,6 +93,8 @@ ], "dc_north": "Kuzey", "dc_south": "Güney", + "dc_east": "East", + "dc_west": "West", "dc_africa_title": "Güney Afrika'daki veri merkezi", "dc_africa_inline_title": "Afrika DC", "dc_africa_johannesburg": "Johannesburg", @@ -128,21 +130,18 @@ "dc_spain_inline_title": "İspanyol DC", "dc_spain_madrid": "Madrid", "dc_us": "ABD", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "Kuzey ABD DC", - "dc_us_north_central_title": "kuzey-merkezi veri merkezi", - "dc_us_north_central_chicago": "Chicago", - "dc_us_north_east_title": "kuzeydoğu veri merkezi", - "dc_us_north_east_sterling": "Sterlin", - "dc_us_north_west_title": "kuzeybatı veri merkezi", - "dc_us_north_west_new_york": "New York", - "dc_us_north_west_seattle": "Seattle", - "dc_us_south_inline_title": "Güney ABD DC", - "dc_us_south_east_title": "güneydoğu veri merkezi", - "dc_us_south_east_atlanta": "Atlanta", - "dc_us_south_west_title": "güneybatı veri merkezi", - "dc_us_south_west_los_angeles": "Los Angeles", + "dc_us_east": "dc_us_east / internally used key, no need to translate it", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", + "dc_us_east_title": "East USA DC", + "dc_us_east_inline_title": "Eastern USA DC", + "dc_us_chicago": "Chicago", + "dc_us_sterling": "Sterlin", + "dc_us_new_york": "New York", + "dc_us_atlanta": "Atlanta", + "dc_us_west_title": "West USA DC", + "dc_us_west_inline_title": "Western USA DC", + "dc_us_seattle": "Seattle", + "dc_us_los_angeles": "Los Angeles", "dc_argentina": "Arjantin", "dc_argentina_title": "Arjantin'deki veri merkezi", "dc_argentina_inline_title": "Arjantin DC", @@ -506,5 +505,20 @@ "valve_hqtime_inline_title": "Bellevue'deki saat", "valve_hqtime_inline_description": "Valve Genel Merkezindeki saat", "valve_hqtime_text": "{} Bellevue'deki saat (Valve Genel Merkezi): {}", - "valve_steam_maintenance_text": "🛠️ **Steam, her Salı planlı bakım nedeniyle kapatılıyor.**" + "valve_steam_maintenance_text": "🛠️ **Steam, her Salı planlı bakım nedeniyle kapatılıyor.**", + "dc_us_north": "dc_us_north / internally used key, no need to translate it", + "dc_us_south": "dc_us_south / internally used key, no need to translate it", + "dc_us_north_inline_title": "Kuzey ABD DC", + "dc_us_north_central_title": "kuzey-merkezi veri merkezi", + "dc_us_north_central_chicago": "Chicago", + "dc_us_north_east_title": "kuzeydoğu veri merkezi", + "dc_us_north_east_sterling": "Sterlin", + "dc_us_north_west_title": "kuzeybatı veri merkezi", + "dc_us_north_west_new_york": "New York", + "dc_us_north_west_seattle": "Seattle", + "dc_us_south_inline_title": "Güney ABD DC", + "dc_us_south_east_title": "güneydoğu veri merkezi", + "dc_us_south_east_atlanta": "Atlanta", + "dc_us_south_west_title": "güneybatı veri merkezi", + "dc_us_south_west_los_angeles": "Los Angeles" } \ No newline at end of file diff --git a/l10n/data/uk.json b/l10n/data/uk.json index 7a2e194..f7df4df 100644 --- a/l10n/data/uk.json +++ b/l10n/data/uk.json @@ -93,6 +93,8 @@ ], "dc_north": "Північ", "dc_south": "Південь", + "dc_east": "East", + "dc_west": "West", "dc_africa_title": "дата-центру Південної Африки", "dc_africa_inline_title": "Африканский ДЦ", "dc_africa_johannesburg": "Йоханнесбург", @@ -128,21 +130,18 @@ "dc_spain_inline_title": "Іспанський ДЦ", "dc_spain_madrid": "Мадрид", "dc_us": "США", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "ДЦ північної частини США", - "dc_us_north_central_title": "північно-центрального дата-центра", - "dc_us_north_central_chicago": "Чикаго", - "dc_us_north_east_title": "північно-східного дата-центру", - "dc_us_north_east_sterling": "Стерлінг", - "dc_us_north_west_title": "північно-західного дата-центру", - "dc_us_north_west_new_york": "Нью-Йорк", - "dc_us_north_west_seattle": "Сіетл", - "dc_us_south_inline_title": "ДЦ південної частини США", - "dc_us_south_east_title": "південно-східного дата-центру", - "dc_us_south_east_atlanta": "Атланта", - "dc_us_south_west_title": "південно-західного дата-центра", - "dc_us_south_west_los_angeles": "Лос-Анджелесс", + "dc_us_east": "dc_us_east / internally used key, no need to translate it", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", + "dc_us_east_title": "East USA DC", + "dc_us_east_inline_title": "Eastern USA DC", + "dc_us_chicago": "Чикаго", + "dc_us_sterling": "Стерлінг", + "dc_us_new_york": "Нью-Йорк", + "dc_us_atlanta": "Атланта", + "dc_us_west_title": "West USA DC", + "dc_us_west_inline_title": "Western USA DC", + "dc_us_seattle": "Сіетл", + "dc_us_los_angeles": "Лос-Анджелес", "dc_argentina": "Аргентина", "dc_argentina_title": "дата-центру Аргентини", "dc_argentina_inline_title": "Аргентинський ДЦ", diff --git a/l10n/data/uz.json b/l10n/data/uz.json index 3fd917e..ad1adbd 100644 --- a/l10n/data/uz.json +++ b/l10n/data/uz.json @@ -93,6 +93,8 @@ ], "dc_north": "Shimoliy", "dc_south": "Janubiy", + "dc_east": "East", + "dc_west": "West", "dc_africa_title": "Janubiy Afrika data-centre", "dc_africa_inline_title": "Afrika DC", "dc_africa_johannesburg": "Yoxannesburg", @@ -128,21 +130,18 @@ "dc_spain_inline_title": "Ispaniya DC", "dc_spain_madrid": "Madrid", "dc_us": "AQSh", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "Shimoliy AQSh DC", - "dc_us_north_central_title": "Shimoli-markaziy data-centre", - "dc_us_north_central_chicago": "Chikago", - "dc_us_north_east_title": "Shimoli-sharqiy data-centre", - "dc_us_north_east_sterling": "Sterling", - "dc_us_north_west_title": "Shimoli-g'arbiy data-centre", - "dc_us_north_west_new_york": "Nyu-York", - "dc_us_north_west_seattle": "Sietl", - "dc_us_south_inline_title": "DC Janubiy AQSh", - "dc_us_south_east_title": "Janubi-sharqiy data-centre", - "dc_us_south_east_atlanta": "Atlanta", - "dc_us_south_west_title": "Janibi-g'arbiy data-centre", - "dc_us_south_west_los_angeles": "Los Anjeles", + "dc_us_east": "dc_us_east / internally used key, no need to translate it", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", + "dc_us_east_title": "East USA DC", + "dc_us_east_inline_title": "Eastern USA DC", + "dc_us_chicago": "Chikago", + "dc_us_sterling": "Sterling", + "dc_us_new_york": "Nyu-York", + "dc_us_atlanta": "Atlanta", + "dc_us_west_title": "West USA DC", + "dc_us_west_inline_title": "Western USA DC", + "dc_us_seattle": "Sietl", + "dc_us_los_angeles": "Los Anjeles", "dc_argentina": "Argentina", "dc_argentina_title": "Argentinadagi data-centre", "dc_argentina_inline_title": "Argentina DC", diff --git a/l10n/l10n.py b/l10n/l10n.py index 27eb4e9..1f0001e 100644 --- a/l10n/l10n.py +++ b/l10n/l10n.py @@ -95,6 +95,8 @@ class Locale(SLocale): dc_north: str # North dc_south: str # South + dc_east: str # East + dc_west: str # West dc_africa_title: str # South Africaʼs DC dc_africa_inline_title: str # African DC @@ -134,21 +136,18 @@ class Locale(SLocale): dc_spain_madrid: str # Madrid dc_us: str # USA - dc_us_north: str # North - dc_us_south: str # South - dc_us_north_inline_title: str # Northern USA DC - dc_us_north_central_title: str # Northcentral DC - dc_us_north_central_chicago: str # Chicago - dc_us_north_east_title: str # Northeast DC - dc_us_north_east_sterling: str # Sterling - dc_us_north_west_title: str # Northwest DC - dc_us_north_west_new_york: str # New York - dc_us_north_west_seattle: str # Seattle - dc_us_south_inline_title: str # Southern USA DC - dc_us_south_east_title: str # Southeast DC - dc_us_south_east_atlanta: str # Atlanta - dc_us_south_west_title: str # Southwest DC - dc_us_south_west_los_angeles: str # Los Angeles + dc_us_east: str # East + dc_us_east_title: str # East USA DC + dc_us_east_inline_title: str # Eastern USA DC + dc_us_chicago: str # Chicago + dc_us_sterling: str # Sterling + dc_us_new_york: str # New York + dc_us_atlanta: str # Atlanta + dc_us_west: str # West + dc_us_west_title: str # West USA DC + dc_us_west_inline_title: str # Western USA DC + dc_us_seattle: str # Seattle + dc_us_los_angeles: str # Los Angeles dc_argentina: str # Argentina dc_argentina_title: str # Argentinaʼs DC diff --git a/l10n/tags.py b/l10n/tags.py index 3fb6700..e89eb3e 100644 --- a/l10n/tags.py +++ b/l10n/tags.py @@ -46,8 +46,8 @@ class Tags(NamedTuple): dc_europe_sweden: list # Sweden dc_us: list # USA - dc_us_north: list # North - dc_us_south: list # South + dc_us_east: list # East + dc_us_west: list # West dc_asia: list # Asia dc_asia_india: list # India diff --git a/main.py b/main.py index a3d6a25..f60636a 100644 --- a/main.py +++ b/main.py @@ -269,16 +269,16 @@ async def dc_us(_, session: UserSession, callback_query: CallbackQuery): reply_markup=keyboards.dc_us_markup(session.locale)) -@bot.on_callback_request(LK.dc_us_north) +@bot.on_callback_request(LK.dc_us_east) @bot.came_from(datacenters) -async def send_dc_us_north(client: BClient, session: UserSession, callback_query: CallbackQuery): - await send_dc_state(client, session, callback_query, datacenter_handlers.us_north, keyboards.dc_us_markup) +async def send_dc_us_east(client: BClient, session: UserSession, callback_query: CallbackQuery): + await send_dc_state(client, session, callback_query, datacenter_handlers.us_east, keyboards.dc_us_markup) -@bot.on_callback_request(LK.dc_us_south) +@bot.on_callback_request(LK.dc_us_west) @bot.came_from(datacenters) -async def send_dc_us_south(client: BClient, session: UserSession, callback_query: CallbackQuery): - await send_dc_state(client, session, callback_query, datacenter_handlers.us_south, keyboards.dc_us_markup) +async def send_dc_us_west(client: BClient, session: UserSession, callback_query: CallbackQuery): + await send_dc_state(client, session, callback_query, datacenter_handlers.us_west, keyboards.dc_us_markup) @bot.on_callback_request(LK.regions_southamerica) diff --git a/plugins/inline.py b/plugins/inline.py index d87a4ad..ab40d98 100644 --- a/plugins/inline.py +++ b/plugins/inline.py @@ -194,14 +194,14 @@ async def inline_datacenters(_, session: UserSession, inline_query: InlineQuery) 'https://telegra.ph/file/f552dc251f2c0a4e5be53.png', datacenter_handlers.sweden, TAGS.dc_europe_sweden), - DatacenterInlineResult(session.locale.dc_us_north_inline_title, + DatacenterInlineResult(session.locale.dc_us_east_inline_title, 'https://telegra.ph/file/06119c30872031d1047d0.jpg', - datacenter_handlers.us_north, - TAGS.dc_us_north), - DatacenterInlineResult(session.locale.dc_us_south_inline_title, + datacenter_handlers.us_east, + TAGS.dc_us_east), + DatacenterInlineResult(session.locale.dc_us_west_inline_title, 'https://telegra.ph/file/06119c30872031d1047d0.jpg', - datacenter_handlers.us_south, - TAGS.dc_us_south), + datacenter_handlers.us_west, + TAGS.dc_us_west), DatacenterInlineResult(session.locale.dc_australia_inline_title, 'https://telegra.ph/file/5dc6beef1556ea852284c.jpg', datacenter_handlers.australia, diff --git a/utypes/datacenters.py b/utypes/datacenters.py index ec998af..90c74f2 100644 --- a/utypes/datacenters.py +++ b/utypes/datacenters.py @@ -173,77 +173,46 @@ class DatacenterAtlas: LK.dc_sweden_title ) - US_NORTH = DatacenterGroup( - "us_north", + US_EAST = DatacenterRegion( + "us_east", [ - DatacenterRegion( - "northcentral", - [ - Datacenter( - "chicago", - l10n_key_title=LK.dc_us_north_central_chicago - ), - ], - symbol="🇺🇸", - l10n_key_title=LK.dc_us_north_central_title + Datacenter( + "chicago", + l10n_key_title=LK.dc_us_chicago + ), + Datacenter( + "sterling", + l10n_key_title=LK.dc_us_sterling ), - DatacenterRegion( - "northeast", - [ - Datacenter( - "sterling", - l10n_key_title=LK.dc_us_north_east_sterling - ), - ], - symbol="🇺🇸", - l10n_key_title=LK.dc_us_north_east_title + Datacenter( + "new_york", + l10n_key_title=LK.dc_us_new_york ), - DatacenterRegion( - "northwest", - [ - Datacenter( - "new_york", - l10n_key_title=LK.dc_us_north_west_new_york - ), - Datacenter( - "seattle", - l10n_key_title=LK.dc_us_north_west_seattle - ), - ], - symbol="🇺🇸", - l10n_key_title=LK.dc_us_north_west_title + Datacenter( + "atlanta", + l10n_key_title=LK.dc_us_atlanta ) ], - LK.dc_north + "🇺🇸", + LK.dc_east, + LK.dc_us_east_title ) - US_SOUTH = DatacenterGroup( - "us_south", + US_WEST = DatacenterRegion( + "us_west", [ - DatacenterRegion( - "southwest", - [ - Datacenter( - "los_angeles", - l10n_key_title=LK.dc_us_south_west_los_angeles - ), - ], - symbol="🇺🇸", - l10n_key_title=LK.dc_us_south_west_title + Datacenter( + "los_angeles", + l10n_key_title=LK.dc_us_los_angeles ), - DatacenterRegion( - "southeast", - [ - Datacenter( - "atlanta", - l10n_key_title=LK.dc_us_south_east_atlanta - ), - ], - symbol="🇺🇸", - l10n_key_title=LK.dc_us_south_east_title + Datacenter( + "seattle", + l10n_key_title=LK.dc_us_seattle ) ], - LK.dc_south + "🇺🇸", + LK.dc_west, + LK.dc_us_west_title ) ARGENTINA = DatacenterRegion( From a59c5eedebabc61bbc35fafaf6dac566925c1d7c Mon Sep 17 00:00:00 2001 From: Aquarius <31861541+aquaismissing@users.noreply.github.com> Date: Sat, 4 Nov 2023 01:21:59 +0000 Subject: [PATCH 10/24] Update README.md --- l10n/README.md | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/l10n/README.md b/l10n/README.md index 5cabb5e..9189411 100644 --- a/l10n/README.md +++ b/l10n/README.md @@ -9,16 +9,29 @@ Then check [Contributing](#contributing) section to know how to start translatin Here you can see translations' progress and contributors' list: -| Code | Language | Progress | Summary | Contributors | -|:----:|--------------|:---------------:|:----------------------------------------------:|:--------------------------:| -| gb | English | ██████████ 100% | built in | | -| ru | Russian | ██████████ 100% | built in | | -| fa | Persian | █████████▒ 80% | settings, leaderboard missing | [@A460N] (telegram) | -| tr | Turkish | ███████▒▒▒ 70% | settings, leaderboard, tags missing | [@ITMiroN] (telegram) | -| uz | Uzbek | ███████▒▒▒ 70% | user game stats, settings, leaderboard missing | [@d1az1337] (telegram) | -| uk | Ukrainian | █████████▒ 90% | leaderboard missing | [akimerslys], [Agent47Dev] | -| be | Belarusian | █████████▒ 90% | leaderboard missing | [HiddenDeath] | -| it | Italian | █████████▒ 90% | leaderboard missing | [MrJiavo] | +| Code | Language | Progress | Summary | Contributors | +|:----:|--------------|:---------------:|:----------------------------------------------------------------:|:--------------------------:| +| en | English | ██████████ 100% | built in | | +| ru | Russian | ██████████ 100% | built in | | +| ar | Arabic | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| be | Belarusian | ████████▒▒ 80% | missing: leaderboard, USA DC | [HiddenDeath] | +| da | Danish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| de | German | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| es | Spanish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| fa | Persian | ████████▒▒ 80% | missing: settings, leaderboard, USA DC | [@A460N] | +| fi | Finnish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| fr | French | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| hi | Hindi | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| ja | Japanese | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| no | Norwegian | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| pl | Polish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| pt | Portuguese | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| sv | Swedish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| tr | Turkish | ███████▒▒▒ 70% | missing: settings, leaderboard, tags, USA DC | [@ITMiroN] | +| uk | Ukrainian | ████████▒▒ 80% | missing: leaderboard, USA DC | [akimerslys], [Agent47Dev] | +| uz | Uzbek | ███████▒▒▒ 70% | missing: user game stats, settings, leaderboard, USA DC | [@d1az1337] | +| zh | Chinese | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | + ## Contributing From 3015c82483752df97612e85b72c58a7d3c3d74db Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Sat, 4 Nov 2023 14:13:15 +0500 Subject: [PATCH 11/24] Fixed bot startup datetime showing incorrectly in regular_stats_report --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index f60636a..6bcf2aa 100644 --- a/main.py +++ b/main.py @@ -975,7 +975,7 @@ async def regular_stats_report(client: BClient): f'\n' f'📁 **Other stats:**\n' f'\n' - f'• Bot started up at: {now:%Y-%m-%d %H:%M:%S} (UTC)\n' + f'• Bot started up at: {client.startup_dt:%Y-%m-%d %H:%M:%S} (UTC)\n' f'• Is working for: {info_formatters.format_timedelta(now - client.startup_dt)}') await log(client, text, reply_markup=keyboards.log_ping_markup) client.rstats.clear() From 1e193e5405ab5f65ce92373670ca2b08bf1c7758 Mon Sep 17 00:00:00 2001 From: Aquarius <31861541+aquaismissing@users.noreply.github.com> Date: Mon, 20 Nov 2023 21:35:27 +0000 Subject: [PATCH 12/24] Update README.md --- l10n/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/l10n/README.md b/l10n/README.md index 9189411..74ad27d 100644 --- a/l10n/README.md +++ b/l10n/README.md @@ -22,6 +22,7 @@ Here you can see translations' progress and contributors' list: | fi | Finnish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | fr | French | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | hi | Hindi | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | +| it | Italian | ████████▒▒ 80% | missing: leaderboard, USA DC | [MrJiavo] | | ja | Japanese | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | no | Norwegian | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | pl | Polish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | From f379eaff83151428fd840c451332d2c6617ab46c Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 29 Nov 2023 18:32:41 +0500 Subject: [PATCH 13/24] Fixed drop_cap_reset_timer sometimes showing incorrect days count --- utypes/game_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utypes/game_data.py b/utypes/game_data.py index 2f7065c..b7cd772 100644 --- a/utypes/game_data.py +++ b/utypes/game_data.py @@ -351,7 +351,7 @@ def drop_cap_reset_timer(): time_left = wanted_datetime - now - days_left = time_left.days + days_left = time_left.days % 7 hours_left = time_left.seconds // HOUR minutes_left = time_left.seconds % HOUR // MINUTE seconds_left = time_left.seconds % MINUTE From 4a2c9e0a23d4db9560457fc1f63c807386c9a012 Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 29 Nov 2023 18:41:00 +0500 Subject: [PATCH 14/24] Some type hints (cuz why not) --- utypes/game_data.py | 8 +++++--- utypes/states.py | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/utypes/game_data.py b/utypes/game_data.py index b7cd772..dd05d0c 100644 --- a/utypes/game_data.py +++ b/utypes/game_data.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import datetime as dt import json from typing import NamedTuple @@ -325,16 +327,16 @@ def asdict(self): return self._asdict() -def get_monthly_unique_players(): +def get_monthly_unique_players() -> int: response = requests.get(MONTHLY_UNIQUE_PLAYERS_API, headers=HEADERS, timeout=15).json() return int(response['result']['players']) -def is_pdt(_datetime: dt.datetime): +def is_pdt(_datetime: dt.datetime) -> bool: return _datetime.strftime('%Z') == 'PDT' -def drop_cap_reset_timer(): +def drop_cap_reset_timer() -> tuple[int, int, int, int]: """Get drop cap reset time""" wanted_weekday = 1 diff --git a/utypes/states.py b/utypes/states.py index db6b596..2a7905d 100644 --- a/utypes/states.py +++ b/utypes/states.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from typing import NamedTuple # noinspection PyPep8Naming @@ -30,7 +32,7 @@ class States: UNKNOWN = State('unknown', LK.states_unknown) @staticmethod - def get(data): + def get(data) -> State | None: data = data.replace(' ', '_').upper() try: return vars(States)[data] From 437e45b2120fa9da54a9dcd21f36890280796e13 Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 29 Nov 2023 18:43:38 +0500 Subject: [PATCH 15/24] Update l10n/README.md --- l10n/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/l10n/README.md b/l10n/README.md index 74ad27d..35aee06 100644 --- a/l10n/README.md +++ b/l10n/README.md @@ -43,7 +43,7 @@ Here you can see translations' progress and contributors' list: ### Steps -1. Fork this repository. [100%] +1. Fork this repository. \ ![forking repository](../media/fork_repo.png) 2. Open Git Bash and clone the forked repository: `git clone {your fork link}`. @@ -60,8 +60,8 @@ Here you can see translations' progress and contributors' list: Just copy `en.json` and rename it with ISO 639-1 code of prefered language (e.g. `de.json`). - [List of ISO 639-1 codes](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) 5. Open the file and start translating it based on string keys and original text. - - We highly recommend checking the bot functionality to have more text context. -6. You can also add some tags in your language to `tags.json`. + - We highly recommend checking the bot functionality to have more context. +6. Remember to add some tags in your language to `tags.json`. 7. In Git, add new files, then commit and push all the changes. \ ![commiting changes](../media/commit_changes.png) From f0db0cf719cfa3ed77c8275a3752bcc1c9948504 Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Wed, 29 Nov 2023 18:45:10 +0500 Subject: [PATCH 16/24] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0fa705e..ea521a1 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ and most of the codebase was rewritten to be more modular and perfomant. Here are some noteworthy changes: - Bot now uses inline keyboards instead of reply ones -- Most of the bot messages stay in one, reducing the clutter in messages +- Most of the bot messages stay in one, reducing the clutter in message history - More user-friendly approach for inline queries with the help of tags - Personal settings (only language settings available for now) - Translated on **8** different languages, thanks to our beloved community @@ -31,7 +31,7 @@ We also have plans on adding more functionality and QoL features. - Extended Inline Keyboard Markups (**ExtendedIKM**s), made to integrate extra functionality into regular **IKM**s (e.g. localization, selection indicators) - Use of decorators to support transitions between menus and clean up the codebase -- Using sqlite instead of csv for database! +- Using sqlite instead of csv for a database! ### How can I contribute? From 932710db9f41207ca14dec3b930fa557438bbff8 Mon Sep 17 00:00:00 2001 From: Akim Slys Date: Tue, 12 Dec 2023 23:06:15 +0000 Subject: [PATCH 17/24] finally fixed proyobs --- l10n/data/uk.json | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/l10n/data/uk.json b/l10n/data/uk.json index f7df4df..fee5ae7 100644 --- a/l10n/data/uk.json +++ b/l10n/data/uk.json @@ -2,19 +2,19 @@ "lang": "🇺🇦 Український", "bot_start_text": [ "👋🏼 Привітики, {}!", - "Цей бот призначенний для перевiрки кiлькостi гравцiв у онлайнi та доступнiсть серверiв Counter-Strike.", + "Цей бот призначенний для перевiрки кiлькостi гравцiв онлайн, доступнiсть серверiв Counter-Strike, та багато іншого", "", - "Для деталей використовуйте /help." + "Для більшого використовуйте /help." ], "bot_help_text": [ "[‎](https://telegra.ph/Detalnij-opis-08-14)ℹ️ Цей бот розроблений каналом @INCS2. Програмний код можна знайти на [GitHub](https://github.com/aquaismissing/INCS2bot).", "", "https://telegra.ph/Detalnij-opis-08-14" ], - "bot_feedback_text": "💬 Будь ласка, розповідь про ваші побажання чи проблеми, з якими ви зіткнулися під час використання бота.", + "bot_feedback_text": "💬 Будь ласка, напишіть нам ваші враження від користування ботом", "bot_choose_cmd": "📖 Використовуйте одну з запропонованих команд:", "bot_choose_func": "🔖 Оберіть бажану функцію:", - "bot_choose_setting": "⚙️ Воспользуйтесь одной из приведённых настроек:", + "bot_choose_setting": "⚙️ Використовуйте одну з запропонованих налаштувань:", "bot_use_cancel": "Використовуйте /cancel, щоб скасувати запит.", "bot_feedback_success": "Чудово! Ваше повідомлення надісланно.", "bot_pmonly_text": "Ця команда працює тільки в приватних повідомленнях.", @@ -32,7 +32,7 @@ "crosshair_decode_example": "📖 Будь ласка, введіть код приціла (напр.: `CSGO-O4Jsi-V36wY-rTMGK-9w7qF-jQ8WB`).", "crosshair_decode_error": "⚠️ Невірний код, спробуйте ще раз.", "crosshair_decode_result": [ - "🧬 Розшифровка коду приціла:", + "🧬 Розшифрування коду приціла:", "", "`{}`" ], @@ -78,7 +78,7 @@ "currencies_tags": "`{}` - {} (доступні теги: {})", "dc_status_title": "Стан дата-центрів", "dc_status_inline_description": "Перевірити стан дата-центрів", - "dc_status_choose_region": "📶 Виберіть регіон, який Вам цікавий, щоб отримати інформацію про стан дата-центрів:", + "dc_status_choose_region": "📶 Виберіть регіон, дата-центрів:", "dc_status_specify_region": "📍 Виберіть регіон:", "dc_status_specify_country": "📍 Виберіть країну:", "dc_status_text_title": "{} Стан {}:", @@ -188,13 +188,13 @@ "dc_southkorea_title": "дата-центру Південної Кореї", "dc_southkorea_inline_title": "південнокорейський ДЦ", "dc_southkorea_seoul": "Сеул", - "error_internal": "🧐 Пробачте, щось пішло не так. Будь ласка, спробуйте пізніше.", + "error_internal": "🧐 Вибачаємось, щось пішло не так. Будь ласка, спробуйте пізніше.", "error_unknownrequest": "⚠️ Нічого не знайдено, будь ласка, використовуйте одну з запропонованних команд:", "error_wip": "💤 Розробляється...", - "error_session_timeout": "⚠️ Cессія була прервана, час очікування вийшов.", + "error_session_timeout": "⚠️ Cессія була скасована, час очікування вийшов.", "exchangerate_button_title": "Курс CS", "exchangerate_text": [ - "💸 Вартість одного ключа в Counter-Strike:", + "💸 Вартість одного ключа у Counter-Strike:", "", "🇺🇸 USD: $ {}", "🇬🇧 GBP: £ {}", @@ -412,7 +412,7 @@ "🔗 Будь ласка, введіть один із запропонованих варіантів:", "", "• Посилання на профіль (напр.: `https://steamcommunity.com/id/unavenyyy`)", - "• Єдине посилання на профіль (напр.: `https://steamcommunity.com/profiles/76561199029594485`)", + "• Незмінне посилання на профіль (напр.: `https://steamcommunity.com/profiles/76561199029594485`)", "• SteamID (напр.: `76561199029594485`)", "• Персональне посилання (напр.: `unavenyyy`)" ], @@ -420,7 +420,7 @@ "settings_language_choose": [ "🔖 Оберіть бажану мову:", "", - "Ваша поточна мова: {}." + "Ваша мова: {}." ], "user_gamestats_button_title": "Статистика CS", "user_gamestats_inline_title": "Ваша статистика", @@ -466,8 +466,8 @@ "user_gamestats_pistols_stats": "🔫 Статистика пістолетів:", "user_gamestats_heavy_stats": "🔫 Статистика важкої зброї:", "user_gamestats_smgs_stats": "🔫 Статистика пістолетів-кулеметів:", - "user_gamestats_rifles_stats": "🔫 Статистика штурмових винтовок:", - "user_gamestats_snipers_stats": "🔫 Статистика снайперських винтовок:", + "user_gamestats_rifles_stats": "🔫 Статистика штурмових гвинтівок:", + "user_gamestats_snipers_stats": "🔫 Статистика снайперських гвинтівок:", "user_gamestats_share": "Поділитися", "user_invalidlink_error": "⚠️ Посилання недійсне, перевірте її та спробуйте знову.", "user_invalidrequest_error": "⚠️ Невірний запит.", @@ -497,13 +497,13 @@ "• Блокування в спільноті: {}", "• Обмеження на обмін: {}" ], - "user_profileinfo_notset": "не вказана", - "user_profileinfo_notfound": "не знайдена", - "user_profileinfo_none": "нема", + "user_profileinfo_notset": "не вказано", + "user_profileinfo_notfound": "не знайдено", + "user_profileinfo_none": "немає", "user_profileinfo_banned": "заблоковано", "valve_hqtime_button_title": "Час у штаб-кв. Valve", "valve_hqtime_inline_title": "Час у Белвью", - "valve_hqtime_inline_description": "Час в штаб-кв. Valve", - "valve_hqtime_text": "{} Час в Белвью (штаб-кв. Valve): {}", - "valve_steam_maintenance_text": "🛠️ **Steam вимикається на короткочасне технічне обслуговування кожен вівторок.**" + "valve_hqtime_inline_description": "Час у штаб-кв. Valve", + "valve_hqtime_text": "{} Час у Белвью (штаб-кв. Valve): {}", + "valve_steam_maintenance_text": "🛠️ **Steam вимикається на короткочасне технічне обслуговування щовівторка.**" } \ No newline at end of file From df0801a32e2308765903694c045f035f7228e6fc Mon Sep 17 00:00:00 2001 From: Akim Slys Date: Tue, 12 Dec 2023 23:14:40 +0000 Subject: [PATCH 18/24] finally fixed proyobs v2 --- l10n/data/uk.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/l10n/data/uk.json b/l10n/data/uk.json index fee5ae7..701c704 100644 --- a/l10n/data/uk.json +++ b/l10n/data/uk.json @@ -14,7 +14,7 @@ "bot_feedback_text": "💬 Будь ласка, напишіть нам ваші враження від користування ботом", "bot_choose_cmd": "📖 Використовуйте одну з запропонованих команд:", "bot_choose_func": "🔖 Оберіть бажану функцію:", - "bot_choose_setting": "⚙️ Використовуйте одну з запропонованих налаштувань:", + "bot_choose_setting": "⚙️ Використовуйте одне з запроповонованих налаштувань:", "bot_use_cancel": "Використовуйте /cancel, щоб скасувати запит.", "bot_feedback_success": "Чудово! Ваше повідомлення надісланно.", "bot_pmonly_text": "Ця команда працює тільки в приватних повідомленнях.", @@ -23,9 +23,9 @@ "bot_author_text": "🔫 Оновлення Counter-Strike", "bot_author_link": "https://t.me/INCS2", "bot_servers_stats": "Статистика серверів", - "bot_profile_info": "Інформация про користувача", + "bot_profile_info": "Інформація про гравця", "bot_extras": "Додаткові функції", - "bot_settings": "🆕 Настройки", + "bot_settings": "🆕 Налаштування", "crosshair": "Приціл", "crosshair_generate": "Створити", "crosshair_decode": "Розшифрувати", @@ -78,7 +78,7 @@ "currencies_tags": "`{}` - {} (доступні теги: {})", "dc_status_title": "Стан дата-центрів", "dc_status_inline_description": "Перевірити стан дата-центрів", - "dc_status_choose_region": "📶 Виберіть регіон, дата-центрів:", + "dc_status_choose_region": "📶 Виберіть регіон дата-центрів:", "dc_status_specify_region": "📍 Виберіть регіон:", "dc_status_specify_country": "📍 Виберіть країну:", "dc_status_text_title": "{} Стан {}:", @@ -395,9 +395,9 @@ "stats_matchmaking_text": [ "⁠📊 **Статистика матчмейкінгу:**", "", - "• Сервери онлайн: {:,}", + "• Сервера онлайн: {:,}", "• Гравці онлайн: {:,}", - "• Активі гравці: {:,}", + "• Активні гравці: {:,}", "• Гравці в черзі: {:,}", "• Приблизний час пошуку гри: {} с." ], @@ -472,7 +472,7 @@ "user_invalidlink_error": "⚠️ Посилання недійсне, перевірте її та спробуйте знову.", "user_invalidrequest_error": "⚠️ Невірний запит.", "user_telegraph_error": "⚠️ Помилка Telegraph, будь ласка, спробуйте знову.", - "user_privateprofile_error": "❕ Цей аккаунт приватний, неможливо отримати статистику. Будь ласка, змініть настройки приватності.", + "user_privateprofile_error": "❕ Цей аккаунт приватний, неможливо отримати статистику. Будь ласка, змініть налаштування приватності.", "user_profileinfo_title": "Блокування та обмеження", "user_profileinfo_text": [ "🔍 **Загальна Інформація профілю:**", From 1e7fb052396161570b460303a11906bb63ba5c05 Mon Sep 17 00:00:00 2001 From: aquaismissing Date: Tue, 12 Dec 2023 23:38:03 +0000 Subject: [PATCH 19/24] Updated Turkish localisation --- l10n/data/tr.json | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/l10n/data/tr.json b/l10n/data/tr.json index cdf4ada..8b9564c 100644 --- a/l10n/data/tr.json +++ b/l10n/data/tr.json @@ -131,13 +131,13 @@ "dc_spain_madrid": "Madrid", "dc_us": "ABD", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_east_title": "East USA DC", "dc_us_east_inline_title": "Eastern USA DC", "dc_us_chicago": "Chicago", "dc_us_sterling": "Sterlin", "dc_us_new_york": "New York", "dc_us_atlanta": "Atlanta", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_west_title": "West USA DC", "dc_us_west_inline_title": "Western USA DC", "dc_us_seattle": "Seattle", @@ -505,20 +505,5 @@ "valve_hqtime_inline_title": "Bellevue'deki saat", "valve_hqtime_inline_description": "Valve Genel Merkezindeki saat", "valve_hqtime_text": "{} Bellevue'deki saat (Valve Genel Merkezi): {}", - "valve_steam_maintenance_text": "🛠️ **Steam, her Salı planlı bakım nedeniyle kapatılıyor.**", - "dc_us_north": "dc_us_north / internally used key, no need to translate it", - "dc_us_south": "dc_us_south / internally used key, no need to translate it", - "dc_us_north_inline_title": "Kuzey ABD DC", - "dc_us_north_central_title": "kuzey-merkezi veri merkezi", - "dc_us_north_central_chicago": "Chicago", - "dc_us_north_east_title": "kuzeydoğu veri merkezi", - "dc_us_north_east_sterling": "Sterlin", - "dc_us_north_west_title": "kuzeybatı veri merkezi", - "dc_us_north_west_new_york": "New York", - "dc_us_north_west_seattle": "Seattle", - "dc_us_south_inline_title": "Güney ABD DC", - "dc_us_south_east_title": "güneydoğu veri merkezi", - "dc_us_south_east_atlanta": "Atlanta", - "dc_us_south_west_title": "güneybatı veri merkezi", - "dc_us_south_west_los_angeles": "Los Angeles" + "valve_steam_maintenance_text": "🛠️ **Steam, her Salı planlı bakım nedeniyle kapatılıyor.**" } \ No newline at end of file From bba41c28698e4370a86eeca1f595dacd10aa05ea Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Sun, 17 Dec 2023 00:53:30 +0500 Subject: [PATCH 20/24] Fixed exception on CS2 stats not being available --- l10n/data/be.json | 3 ++- l10n/data/en.json | 3 ++- l10n/data/fa.json | 3 ++- l10n/data/it.json | 3 ++- l10n/data/ru.json | 3 ++- l10n/data/tr.json | 1 + l10n/data/uk.json | 3 ++- l10n/data/uz.json | 3 ++- l10n/l10n.py | 1 + main.py | 2 ++ utypes/profiles.py | 4 ++++ 11 files changed, 22 insertions(+), 7 deletions(-) diff --git a/l10n/data/be.json b/l10n/data/be.json index e959c79..8b08cf8 100644 --- a/l10n/data/be.json +++ b/l10n/data/be.json @@ -131,13 +131,13 @@ "dc_spain_madrid": "Мадрыд", "dc_us": "ЗША", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_east_title": "East USA DC", "dc_us_east_inline_title": "Eastern USA DC", "dc_us_chicago": "Чыкага", "dc_us_sterling": "Стэрлінг", "dc_us_new_york": "Нью-Ёрк", "dc_us_atlanta": "Атланта", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_west_title": "West USA DC", "dc_us_west_inline_title": "Western USA DC", "dc_us_seattle": "Сіэтл", @@ -495,6 +495,7 @@ "user_gamestats_share": "Падзяліцца", "user_invalidlink_error": "⚠️ Адпраўленая вамі спасылка несапраўдная, праверце яе правільнасць і паспрабуйце яшчэ раз.", "user_invalidrequest_error": "⚠️ Няправільны запыт.", + "user_nostatsavailable_error": "⚠️ Для данного профиля нет доступной статистики CS2.", "user_telegraph_error": "⚠️ Адбылася ўнутраная памылка Telegraph, калі ласка, увядзіце спасылку нанова.", "user_privateprofile_error": "❕ Гэты акаўнт прыватны, немагчыма атрымаць статыстыку. Калі ласка, змяніце настройкі прыватнасці.", "user_profileinfo_title": "Блакіроўкі і абмежаванні", diff --git a/l10n/data/en.json b/l10n/data/en.json index 5543d41..d89851b 100644 --- a/l10n/data/en.json +++ b/l10n/data/en.json @@ -131,13 +131,13 @@ "dc_spain_madrid": "Madrid", "dc_us": "USA", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_east_title": "East USA DC", "dc_us_east_inline_title": "Eastern USA DC", "dc_us_chicago": "Chicago", "dc_us_sterling": "Sterling", "dc_us_new_york": "New York", "dc_us_atlanta": "Atlanta", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_west_title": "West USA DC", "dc_us_west_inline_title": "Western USA DC", "dc_us_seattle": "Seattle", @@ -470,6 +470,7 @@ "user_gamestats_share": "Share", "user_invalidlink_error": "⚠️ The link you sent is invalid, please check if it's correct and try again.", "user_invalidrequest_error": "⚠️ Invalid request.", + "user_nostatsavailable_error": "⚠️ There are no available CS2 stats for this account.", "user_telegraph_error": "⚠️ Internal Telegraph error, please re-enter your link.", "user_privateprofile_error": "❕ This account is private, statistics are not available. Please, change your privacy settings.", "user_profileinfo_title": "Bans and restrictions", diff --git a/l10n/data/fa.json b/l10n/data/fa.json index 6daae45..5d11b0a 100644 --- a/l10n/data/fa.json +++ b/l10n/data/fa.json @@ -131,13 +131,13 @@ "dc_spain_madrid": "مادرید", "dc_us": "آمریکا", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_east_title": "East USA DC", "dc_us_east_inline_title": "Eastern USA DC", "dc_us_chicago": "شیکاگو", "dc_us_sterling": "استرلینگ", "dc_us_new_york": "نیویورک", "dc_us_atlanta": "اتلانتا", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_west_title": "West USA DC", "dc_us_west_inline_title": "Western USA DC", "dc_us_seattle": "سیاتل", @@ -470,6 +470,7 @@ "user_gamestats_share": "اشتراک گذاری", "user_invalidlink_error": "⚠️ لینکی که ارسال کردید نامعتبر است، لطفاً بررسی کنید که درست است و دوباره امتحان کنید.", "user_invalidrequest_error": "⚠️ درخواست نامعتبر.", + "user_nostatsavailable_error": "⚠️ There are no available CS2 stats for this account.", "user_telegraph_error": "⚠️ خطا از طرف تلگرام لطفا لینک خود را دوباره وارد کنید.", "user_privateprofile_error": "❕ این اکانت خصوصی است برای نشان داده شدن آمار آن را به حالت عمومی تغییر دهید.", "user_profileinfo_title": "بن و محدودیت ها", diff --git a/l10n/data/it.json b/l10n/data/it.json index 8481905..fa9ebb9 100644 --- a/l10n/data/it.json +++ b/l10n/data/it.json @@ -131,13 +131,13 @@ "dc_spain_madrid": "Madrid", "dc_us": "USA", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_east_title": "East USA DC", "dc_us_east_inline_title": "Eastern USA DC", "dc_us_chicago": "Chicago", "dc_us_sterling": "Sterling", "dc_us_new_york": "New York", "dc_us_atlanta": "Atlanta", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_west_title": "West USA DC", "dc_us_west_inline_title": "Western USA DC", "dc_us_seattle": "Seattle", @@ -470,6 +470,7 @@ "user_gamestats_share": "Condividi", "user_invalidlink_error": "⚠️ Il link inviato non è valido, controlla se è corretto e riprova.", "user_invalidrequest_error": "⚠️ Richiesta non valida.", + "user_nostatsavailable_error": "⚠️ There are no available CS2 stats for this account.", "user_telegraph_error": "⚠️ Errore telegrafico interno, inserisci nuovamente il link.", "user_privateprofile_error": "❕ Questo account è privato, le statistiche non sono disponibili. Per favore, modifica le tue impostazioni sulla privacy.", "user_profileinfo_title": "Ban e restrizioni", diff --git a/l10n/data/ru.json b/l10n/data/ru.json index 9c91c3d..cee2798 100644 --- a/l10n/data/ru.json +++ b/l10n/data/ru.json @@ -131,13 +131,13 @@ "dc_spain_madrid": "Мадрид", "dc_us": "США", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_east_title": "восточных дата-центров США", "dc_us_east_inline_title": "ДЦ восточной части США", "dc_us_chicago": "Чикаго", "dc_us_sterling": "Стерлинг", "dc_us_new_york": "Нью-Йорк", "dc_us_atlanta": "Атланта", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_west_title": "западных дата-центров США", "dc_us_west_inline_title": "ДЦ западной части США", "dc_us_seattle": "Сиэтл", @@ -495,6 +495,7 @@ "user_gamestats_share": "Поделиться", "user_invalidlink_error": "⚠️ Отправленная вами ссылка недействительна, проверьте ее правильность и повторите попытку.", "user_invalidrequest_error": "⚠️ Неверный запрос.", + "user_nostatsavailable_error": "⚠️ Для данного профиля нет доступной статистики CS2.", "user_telegraph_error": "⚠️ Произошла внутренняя ошибка Telegraph, пожалуйста, введите ссылку заново.", "user_privateprofile_error": "❕ Этот аккаунт приватный, невозможно получить статистику. Пожалуйста, поменяйте настройки приватности.", "user_profileinfo_title": "Блокировки и ограничения", diff --git a/l10n/data/tr.json b/l10n/data/tr.json index 8b9564c..2997a51 100644 --- a/l10n/data/tr.json +++ b/l10n/data/tr.json @@ -471,6 +471,7 @@ "user_gamestats_share": "Paylaşmak", "user_invalidlink_error": "⚠️ Gönderdiğiniz bağlantı geçersiz, lütfen doğruluğunu kontrol edin ve tekrar deneyin.", "user_invalidrequest_error": "⚠️ Geçersiz istek.", + "user_nostatsavailable_error": "⚠️ There are no available CS2 stats for this account.", "user_telegraph_error": "⚠️ Internal Telegraph error, please re-enter your link.", "user_privateprofile_error": "❕ Bu hesap gizlidir, istatistik almak imkansızdır. Lütfen gizlilik ayarlarınızı değiştirin.", "user_profileinfo_title": "Bloklar ve kısıtlamalar", diff --git a/l10n/data/uk.json b/l10n/data/uk.json index f7df4df..78f6b4e 100644 --- a/l10n/data/uk.json +++ b/l10n/data/uk.json @@ -131,13 +131,13 @@ "dc_spain_madrid": "Мадрид", "dc_us": "США", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_east_title": "East USA DC", "dc_us_east_inline_title": "Eastern USA DC", "dc_us_chicago": "Чикаго", "dc_us_sterling": "Стерлінг", "dc_us_new_york": "Нью-Йорк", "dc_us_atlanta": "Атланта", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_west_title": "West USA DC", "dc_us_west_inline_title": "Western USA DC", "dc_us_seattle": "Сіетл", @@ -471,6 +471,7 @@ "user_gamestats_share": "Поділитися", "user_invalidlink_error": "⚠️ Посилання недійсне, перевірте її та спробуйте знову.", "user_invalidrequest_error": "⚠️ Невірний запит.", + "user_nostatsavailable_error": "⚠️ Для данного профиля нет доступной статистики CS2.", "user_telegraph_error": "⚠️ Помилка Telegraph, будь ласка, спробуйте знову.", "user_privateprofile_error": "❕ Цей аккаунт приватний, неможливо отримати статистику. Будь ласка, змініть настройки приватності.", "user_profileinfo_title": "Блокування та обмеження", diff --git a/l10n/data/uz.json b/l10n/data/uz.json index ad1adbd..8c7d405 100644 --- a/l10n/data/uz.json +++ b/l10n/data/uz.json @@ -131,13 +131,13 @@ "dc_spain_madrid": "Madrid", "dc_us": "AQSh", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_east_title": "East USA DC", "dc_us_east_inline_title": "Eastern USA DC", "dc_us_chicago": "Chikago", "dc_us_sterling": "Sterling", "dc_us_new_york": "Nyu-York", "dc_us_atlanta": "Atlanta", + "dc_us_west": "dc_us_west / internally used key, no need to translate it", "dc_us_west_title": "West USA DC", "dc_us_west_inline_title": "Western USA DC", "dc_us_seattle": "Sietl", @@ -471,6 +471,7 @@ "user_gamestats_share": "Repost", "user_invalidlink_error": "⚠️ Siz yuborgan havola yaroqsiz, uning toʻgʻriligini tekshiring va qaytadan urinib koʻring.", "user_invalidrequest_error": "⚠️ So‘rov noto‘g‘ri.", + "user_nostatsavailable_error": "⚠️ Для данного профиля нет доступной статистики CS2.", "user_telegraph_error": "⚠️ Произошла внутренняя ошибка Telegraph, пожалуйста, введите ссылку заново.", "user_privateprofile_error": "❕ Bu akkaunt shaxsiydir, statistikani olish mumkin emas. Iltimos, maxfiylik sozlamalaringizni o'zgartiring.", "user_profileinfo_title": "Bloklar va cheklovlar", diff --git a/l10n/l10n.py b/l10n/l10n.py index 1f0001e..31e845d 100644 --- a/l10n/l10n.py +++ b/l10n/l10n.py @@ -376,6 +376,7 @@ class Locale(SLocale): user_gamestats_share: str user_invalidlink_error: str user_invalidrequest_error: str + user_nostatsavailable_error: str user_telegraph_error: str user_privateprofile_error: str user_profileinfo_title: str diff --git a/main.py b/main.py index 6bcf2aa..5f64ff2 100644 --- a/main.py +++ b/main.py @@ -533,6 +533,8 @@ async def user_info_handle_error(_, session: UserSession, user_input: Message, e elif exc.code == ErrorCode.PROFILE_IS_PRIVATE: error_msg = '' + \ session.locale.user_privateprofile_error + elif exc.code == ErrorCode.NO_STATS_AVAILABLE: + error_msg = session.locale.user_nostatsavailable_error return error_msg diff --git a/utypes/profiles.py b/utypes/profiles.py index b251296..4284702 100644 --- a/utypes/profiles.py +++ b/utypes/profiles.py @@ -36,6 +36,7 @@ class ErrorCode(StrEnum): INVALID_LINK = 'INVALID_LINK' PROFILE_IS_PRIVATE = 'PROFILE_IS_PRIVATE' UNKNOWN_ERROR = 'UNKNOWN_ERROR' + NO_STATS_AVAILABLE = 'NO_STATS_AVAILABLE' class ParseUserStatsError(Exception): @@ -245,6 +246,9 @@ def get(cls, data): if not response: raise ParseUserStatsError(ErrorCode.PROFILE_IS_PRIVATE) + logging.info(response) + if response.get('playerstats') is None or response['playerstats'].get('stats') is None: + raise ParseUserStatsError(ErrorCode.NO_STATS_AVAILABLE) stats_dict = {stat['name']: stat['value'] for stat in response['playerstats']['stats']} stats_dict['steamid'] = steam64 From 2f40beade8775e4ab3d9900f33e7e2d60438c410 Mon Sep 17 00:00:00 2001 From: HiddenDeath Date: Sun, 31 Dec 2023 13:54:17 +0300 Subject: [PATCH 21/24] Updated Belorussian lang --- l10n/data/be.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/l10n/data/be.json b/l10n/data/be.json index 8b08cf8..c0d8fd9 100644 --- a/l10n/data/be.json +++ b/l10n/data/be.json @@ -131,15 +131,15 @@ "dc_spain_madrid": "Мадрыд", "dc_us": "ЗША", "dc_us_east": "dc_us_east / internally used key, no need to translate it", - "dc_us_east_title": "East USA DC", - "dc_us_east_inline_title": "Eastern USA DC", + "dc_us_east_title": "усходніх дата-цэнтраў ЗША", + "dc_us_east_inline_title": "ДЦ усходняй часткі ЗША", "dc_us_chicago": "Чыкага", "dc_us_sterling": "Стэрлінг", "dc_us_new_york": "Нью-Ёрк", "dc_us_atlanta": "Атланта", "dc_us_west": "dc_us_west / internally used key, no need to translate it", - "dc_us_west_title": "West USA DC", - "dc_us_west_inline_title": "Western USA DC", + "dc_us_west_title": "заходніх дата-цэнтраў ЗША", + "dc_us_west_inline_title": "ДЦ заходняй часткі ЗША", "dc_us_seattle": "Сіэтл", "dc_us_los_angeles": "Лос-Анджэлес", "dc_argentina": "Аргенціна", @@ -245,7 +245,7 @@ "exchangerate_inline_text_default": [ "Выкарыстуйце код або назву валюты: ", "`@INCS2bot price {валюта}`", - "(например, `@INCS2bot price rub` або `@INCS2bot price рубель`)" + "(напрыклад, `@INCS2bot price rub` або `@INCS2bot price рубель`)" ], "exchangerate_inline_title_selected": "Паглядзець кошт ключа ў {}", "exchangerate_inline_description_selected": "1x Ключ ад кейса ў Counter-Strike каштуе {} {}", @@ -276,11 +276,11 @@ "game_dropcaptimer_inline_title": "Скід абмежаванняў", "game_dropcaptimer_inline_description": "Час да скіду абмежаванняў вопыту і дропу", "game_dropcaptimer_text": "⏳ Час да скіду абмежаванняў вопыту і дропу: {} д. {} г. {} мін. {} сек.", - "game_leaderboard_button_title": "🆕 Таблица лидеров CS2", + "game_leaderboard_button_title": "🆕 Табліца лідэраў CS2", "game_leaderboard_world": "Свет", - "game_leaderboard_header_world": "Лучшие игроки CS2 по миру:", - "game_leaderboard_header_regional": "Лучшие игроки CS2 по этому региону:", - "game_leaderboard_detailed_link": "Полную таблицу лидеров, а также подробную статистику игроков можно посмотреть [тут]({}).", + "game_leaderboard_header_world": "Лепшыя гульцы CS2 па свеце:", + "game_leaderboard_header_regional": "Лепшыя гульцы CS2 па гэтым рэгіёне:", + "game_leaderboard_detailed_link": "Поўную табліцу лідэраў, а таксама падрабязную статыстыку гульцоў можна паглядзець [тут]({}).", "gun_button_text": "Дадзеныя аб зброі", "gun_select_category": "#️⃣ Выберыце катэгорыю, якая Вас цікавіць:", "gun_pistols": "Пісталеты", @@ -330,7 +330,7 @@ "gun_origin_uk": "Злучанае Каралеўства", "gun_origin_south_africa": "Паўднёвая Афрыка", "latest_data_update": "Апошняе абнаўленне дадзеных: {}", - "data_not_found": "Данные не найдены.", + "data_not_found": "Дадзеныя не знойдзены.", "notifs_build_public": [ "⚡️ [Публічная зборка](https://t.me/cstracker/28) Counter-Strike была абноўлена.", "", @@ -396,7 +396,7 @@ "regions_australia": "Аўстралія", "regions_china": "Кітай", "regions_europe": "Еўропа", - "regions_northamerica": "Северная Америка", + "regions_northamerica": "Паўночная Амерыка", "regions_southamerica": "Паўднёвая Амерыка", "states_low": "нізкая", "states_medium": "сярэдняя", @@ -464,7 +464,7 @@ "user_gamestats_shots": "Стрэлаў:", "user_gamestats_hits": "Пападанняў:", "user_gamestats_aim_accuracy": "Дакладнасць стральбы:", - "user_gamestats_hs_percentage": "Працэнт пападанняў ў галаву:", + "user_gamestats_hs_percentage": "Працэнт пападанняў у галаву:", "user_gamestats_maps_stats": "🗺️ Статыстыка карт:", "user_gamestats_best_map": "Найлепшая карта:", "user_gamestats_misc_stats": "🔰 Іншае:", @@ -495,7 +495,7 @@ "user_gamestats_share": "Падзяліцца", "user_invalidlink_error": "⚠️ Адпраўленая вамі спасылка несапраўдная, праверце яе правільнасць і паспрабуйце яшчэ раз.", "user_invalidrequest_error": "⚠️ Няправільны запыт.", - "user_nostatsavailable_error": "⚠️ Для данного профиля нет доступной статистики CS2.", + "user_nostatsavailable_error": "⚠️ Для дадзенага профіля няма даступнай статыстыкі CS2.", "user_telegraph_error": "⚠️ Адбылася ўнутраная памылка Telegraph, калі ласка, увядзіце спасылку нанова.", "user_privateprofile_error": "❕ Гэты акаўнт прыватны, немагчыма атрымаць статыстыку. Калі ласка, змяніце настройкі прыватнасці.", "user_profileinfo_title": "Блакіроўкі і абмежаванні", From ce3f3d257451d76551c8ac098e04c55f4d81fe91 Mon Sep 17 00:00:00 2001 From: SyberiaK <97897772+SyberiaK@users.noreply.github.com> Date: Mon, 1 Jan 2024 02:27:39 +0500 Subject: [PATCH 22/24] Update README.md --- l10n/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/l10n/README.md b/l10n/README.md index 35aee06..4b8a4f9 100644 --- a/l10n/README.md +++ b/l10n/README.md @@ -14,7 +14,7 @@ Here you can see translations' progress and contributors' list: | en | English | ██████████ 100% | built in | | | ru | Russian | ██████████ 100% | built in | | | ar | Arabic | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | -| be | Belarusian | ████████▒▒ 80% | missing: leaderboard, USA DC | [HiddenDeath] | +| be | Belarusian | ██████████ 100% | fully done | [HiddenDeath] | | da | Danish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | de | German | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | es | Spanish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | @@ -22,14 +22,14 @@ Here you can see translations' progress and contributors' list: | fi | Finnish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | fr | French | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | hi | Hindi | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | -| it | Italian | ████████▒▒ 80% | missing: leaderboard, USA DC | [MrJiavo] | +| it | Italian | ████████▒▒ 80% | missing: leaderboard, USA DC | [MrJiavo] | | ja | Japanese | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | no | Norwegian | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | pl | Polish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | pt | Portuguese | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | sv | Swedish | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | | tr | Turkish | ███████▒▒▒ 70% | missing: settings, leaderboard, tags, USA DC | [@ITMiroN] | -| uk | Ukrainian | ████████▒▒ 80% | missing: leaderboard, USA DC | [akimerslys], [Agent47Dev] | +| uk | Ukrainian | ████████▒▒ 80% | missing: leaderboard, USA DC | [akimerslys], [Agent47Dev] | | uz | Uzbek | ███████▒▒▒ 70% | missing: user game stats, settings, leaderboard, USA DC | [@d1az1337] | | zh | Chinese | ▒▒▒▒▒▒▒▒▒▒ 0% | contributors needed | | From 0ef8a52fab9ccf5dde203053a982e2543a15fceb Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Fri, 12 Jan 2024 19:30:07 +0500 Subject: [PATCH 23/24] Tried to fix leaderboard formatting so it doesn't look like trash on mobile --- functions/info_formatters.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/functions/info_formatters.py b/functions/info_formatters.py index ba56b44..5efb970 100644 --- a/functions/info_formatters.py +++ b/functions/info_formatters.py @@ -156,7 +156,10 @@ def format_game_world_leaderboard(data: list[LeaderboardStats], locale: Locale) for person in data: name = person.name.replace('`', r"'") # escape for formatting - text += f'`{person.rank:2d}.` `{name:<35} {person.rating:,}` {person.region}\n' + name_span_limit = 19 + if len(name) > name_span_limit: + name = name[:name_span_limit - 2] = '...' + text += f'`{person.rank:2d}.` `{name:<{name_span_limit}}` `{person.rating:>6,}` `{person.region}`\n' text += f'\n{link_text}' return text @@ -173,7 +176,10 @@ def format_game_regional_leaderboard(region: str, data: list[LeaderboardStats], for person in data: name = person.name.replace('`', r"'") # escape for formatting - text += f'`{person.rank:2d}.` `{name:<35} {person.rating:,}`\n' + name_span_limit = 21 + if len(name) > name_span_limit: + name = name[:name_span_limit - 2] = '...' + text += f'`{person.rank:2d}.` `{name:<{name_span_limit}}` `{person.rating:>6,}`\n' text += f'\n{link_text}' return text From 2580bd1629eeb729ab46282151bc00c72038847c Mon Sep 17 00:00:00 2001 From: SyberiaK Date: Fri, 12 Jan 2024 19:31:23 +0500 Subject: [PATCH 24/24] Null-safety fixes --- collectors/core.py | 3 +++ main.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/collectors/core.py b/collectors/core.py index 4802d24..86460d7 100644 --- a/collectors/core.py +++ b/collectors/core.py @@ -166,6 +166,9 @@ async def unique_monthly(): with open(config.CACHE_FILE_PATH, encoding='utf-8') as f: cache = json.load(f) + if cache.get('monthly_unique_players') is None: + cache['monthly_unique_players'] = data + if data != cache.get('monthly_unique_players'): await send_alert('monthly_unique_players', (cache['monthly_unique_players'], data)) diff --git a/main.py b/main.py index 5f64ff2..2ff51de 100644 --- a/main.py +++ b/main.py @@ -387,7 +387,7 @@ async def profile_info(client: BClient, session: UserSession, callback_query: Ca with open(config.CACHE_FILE_PATH, encoding='utf-8') as f: cache_file = json.load(f) - if cache_file['webapi'] != 'normal': + if cache_file.get('webapi') != 'normal': return await send_about_maintenance(client, session, callback_query) await callback_query.edit_message_text(session.locale.bot_choose_cmd,