mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 23:24:01 +02:00
fix: use usinfobot
for username resolving & update README
This commit is contained in:
parent
0fab18e8e8
commit
3be793032f
4 changed files with 49 additions and 27 deletions
15
README-RU.md
15
README-RU.md
|
@ -30,7 +30,7 @@
|
|||
|
||||
### Windows
|
||||
|
||||
#### Официальный вариант
|
||||
#### Официальная версия
|
||||
|
||||
Вы можете скачать готовый бинарный файл со вкладки [Releases](https://github.com/AyuGram/AyuGramDesktop/releases) или из
|
||||
[Телеграм канала](https://t.me/AyuGramReleases).
|
||||
|
@ -55,8 +55,16 @@ scoop install ayugram
|
|||
|
||||
### macOS
|
||||
|
||||
#### Официальная версия
|
||||
|
||||
Вы можете скачать подписанный пакет со вкладки [Releases](https://github.com/AyuGram/AyuGramDesktop/releases).
|
||||
|
||||
#### Homebrew
|
||||
|
||||
```bash
|
||||
brew install --cask ayugram
|
||||
```
|
||||
|
||||
### Arch Linux
|
||||
|
||||
Вы можете установить `ayugram-desktop` из [AUR](https://aur.archlinux.org/packages?O=0&K=ayugram).
|
||||
|
@ -101,3 +109,8 @@ scoop install ayugram
|
|||
### Иконки
|
||||
|
||||
- [Solar Icon Set](https://www.figma.com/community/file/1166831539721848736)
|
||||
|
||||
### Боты
|
||||
|
||||
- [TelegramDB](https://t.me/tgdatabase) для получения юзернейма по ID (до закрытия бесплатной версии 25 мая 2025)
|
||||
- [usinfobot](https://t.me/usinfobot) для получения юзернейма по ID
|
||||
|
|
|
@ -110,3 +110,8 @@ Enjoy using **AyuGram**? Consider sending us a tip!
|
|||
### Icons
|
||||
|
||||
- [Solar Icon Set](https://www.figma.com/community/file/1166831539721848736)
|
||||
|
||||
### 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
|
||||
|
|
|
@ -38,6 +38,14 @@
|
|||
#include "ayu/ayu_state.h"
|
||||
#include "ayu/data/messages_storage.h"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr auto usernameResolverBotId = 189165596L;
|
||||
const auto usernameResolverBotUsername = QString("usinfobot");
|
||||
const auto usernameResolverEmpty = QString("¯\\_(ツ)_/¯");
|
||||
|
||||
}
|
||||
|
||||
Main::Session *getSession(ID userId) {
|
||||
for (const auto &[index, account] : Core::App().domain().accounts()) {
|
||||
if (const auto session = account->maybeSession()) {
|
||||
|
@ -526,7 +534,7 @@ void processMessageDelete(not_null<HistoryItem*> item) {
|
|||
}
|
||||
}
|
||||
|
||||
void resolveUser(ID userId, const QString &username, Main::Session *session, const Callback &callback) {
|
||||
void resolveUser(ID userId, const QString &username, Main::Session *session, const UsernameResolverCallback &callback) {
|
||||
auto normalized = username.trimmed().toLower();
|
||||
if (normalized.isEmpty()) {
|
||||
callback(QString(), nullptr);
|
||||
|
@ -566,19 +574,18 @@ void resolveUser(ID userId, const QString &username, Main::Session *session, con
|
|||
}).send();
|
||||
}
|
||||
|
||||
void searchUser(long long userId, Main::Session *session, bool searchUserFlag, const Callback &callback) {
|
||||
void searchUser(long long userId, Main::Session *session, bool searchUserFlag, const UsernameResolverCallback &callback) {
|
||||
if (!session) {
|
||||
callback(QString(), nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr auto botId = 1696868284;
|
||||
const auto bot = session->data().userLoaded(botId);
|
||||
const auto bot = session->data().userLoaded(usernameResolverBotId);
|
||||
|
||||
if (!bot) {
|
||||
if (searchUserFlag) {
|
||||
resolveUser(botId,
|
||||
"tgdb_bot",
|
||||
resolveUser(usernameResolverBotId,
|
||||
usernameResolverBotUsername,
|
||||
session,
|
||||
[=](const QString &title, UserData *data)
|
||||
{
|
||||
|
@ -649,29 +656,26 @@ void searchUser(long long userId, Main::Session *session, bool searchUserFlag, c
|
|||
return QString();
|
||||
});
|
||||
|
||||
if (text.isEmpty()) {
|
||||
if (text.isEmpty() || text.startsWith(usernameResolverEmpty)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ID id = 0; // 🆔
|
||||
QString title; // 🏷
|
||||
QString username; // 📧
|
||||
ID id = 0; // 👤
|
||||
QString title; // 👦🏻
|
||||
QString username; // 🌐
|
||||
|
||||
for (const auto &line : text.split('\n')) {
|
||||
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);
|
||||
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 (id == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (id != userId) {
|
||||
if (id == 0 || id != userId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -702,7 +706,7 @@ void searchUser(long long userId, Main::Session *session, bool searchUserFlag, c
|
|||
}).handleAllErrors().send();
|
||||
}
|
||||
|
||||
void searchById(ID userId, Main::Session *session, const Callback &callback) {
|
||||
void searchById(ID userId, Main::Session *session, const UsernameResolverCallback &callback) {
|
||||
if (userId == 0 || !session) {
|
||||
callback(QString(), nullptr);
|
||||
return;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "info/profile/info_profile_badge.h"
|
||||
#include "main/main_domain.h"
|
||||
|
||||
using Callback = Fn<void(const QString &, UserData *)>;
|
||||
using UsernameResolverCallback = Fn<void(const QString &, UserData *)>;
|
||||
|
||||
Main::Session *getSession(ID userId);
|
||||
void dispatchToMainThread(std::function<void()> callback, int delay = 0);
|
||||
|
@ -51,7 +51,7 @@ int getScheduleTime(int64 sumSize);
|
|||
bool isMessageSavable(not_null<HistoryItem *> item);
|
||||
void processMessageDelete(not_null<HistoryItem *> item);
|
||||
|
||||
void searchById(ID userId, Main::Session *session, bool retry, const Callback &callback);
|
||||
void searchById(ID userId, Main::Session *session, const Callback &callback);
|
||||
void searchById(ID userId, Main::Session *session, bool retry, const UsernameResolverCallback &callback);
|
||||
void searchById(ID userId, Main::Session *session, const UsernameResolverCallback &callback);
|
||||
|
||||
ID getUserIdFromPackId(uint64 id);
|
||||
|
|
Loading…
Add table
Reference in a new issue