From 91224d8a1ca7325da251bd5d2ede88043db487e4 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Sun, 6 Jul 2025 18:50:10 +0300 Subject: [PATCH] fix: use tgdatabase bot again --- README.md | 3 +-- .../ayu/utils/telegram_helpers.cpp | 27 +++++++++---------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 41b5d1aab5..4f7987ef61 100644 --- a/README.md +++ b/README.md @@ -125,5 +125,4 @@ Enjoy using **AyuGram**? Consider sending us a tip! ### Bots -- [TelegramDB](https://t.me/tgdatabase) for username lookup by ID (until closing free inline mode at 25 May 2025) -- [usinfobot](https://t.me/usinfobot) for username lookup by ID +- [TelegramDB](https://t.me/tgdatabase) for username lookup by ID diff --git a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp index 66632715ca..478d393fdd 100644 --- a/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp +++ b/Telegram/SourceFiles/ayu/utils/telegram_helpers.cpp @@ -40,9 +40,9 @@ namespace { -constexpr auto usernameResolverBotId = 189165596L; -const auto usernameResolverBotUsername = QString("usinfobot"); -const auto usernameResolverEmpty = QString("¯\\_(ツ)_/¯"); +constexpr auto usernameResolverBotId = 8001593505L; +const auto usernameResolverBotUsername = QString("TgDBSearchBot"); +const auto usernameResolverEmpty = QString("Error, username or id invalid/not found."); } @@ -656,22 +656,21 @@ void searchUser(long long userId, Main::Session *session, bool searchUserFlag, c return QString(); }); - if (text.isEmpty() || text.startsWith(usernameResolverEmpty)) { + if (text.isEmpty() || text.contains(usernameResolverEmpty)) { continue; } - ID id = 0; // 👤 - QString title; // 👦🏻 - QString username; // 🌐 + ID id = 0; // 🆔 + QString title; // 🏷 + QString username; // 📧 for (auto &line : text.split('\n')) { - line = line.replace("⁣", ""); - if (line.startsWith("👤")) { - id = line.mid(line.indexOf(' ') + 1).toLongLong(); - } else if (line.startsWith("👦🏻")) { - title = line.mid(line.indexOf(' ') + 1); - } else if (line.startsWith("🌐")) { - username = line.mid(line.indexOf(' ') + 1); + if (line.startsWith("🆔")) { + id = line.mid(line.indexOf(": ") + 2).toLongLong(); + } else if (line.startsWith("🏷")) { + title = line.mid(line.indexOf(": ") + 2); + } else if (line.startsWith("📧")) { + username = line.mid(line.indexOf(": ") + 2); } }