Treat usernames of length 4 as valid.

This commit is contained in:
levlam 2022-10-25 19:25:15 +03:00
parent eadf411679
commit 0bf3e7f0e6
2 changed files with 3 additions and 2 deletions

View File

@ -1322,7 +1322,7 @@ vector<Slice> find_mentions(Slice str) {
auto mentions = match_mentions(str); auto mentions = match_mentions(str);
td::remove_if(mentions, [](Slice mention) { td::remove_if(mentions, [](Slice mention) {
mention.remove_prefix(1); mention.remove_prefix(1);
if (mention.size() >= 5) { if (mention.size() >= 4) {
return false; return false;
} }
auto lowered_mention = to_lower(mention); auto lowered_mention = to_lower(mention);

View File

@ -49,7 +49,8 @@ TEST(MessageEntities, mention) {
check_mention("нет@mention", {}); check_mention("нет@mention", {});
check_mention( check_mention(
"@ya @gif @wiki @vid @bing @pic @bold @imdb @ImDb @coub @like @vote @giff @cap ya cap @y @yar @bingg @bin", "@ya @gif @wiki @vid @bing @pic @bold @imdb @ImDb @coub @like @vote @giff @cap ya cap @y @yar @bingg @bin",
{"@gif", "@wiki", "@vid", "@bing", "@pic", "@bold", "@imdb", "@ImDb", "@coub", "@like", "@vote", "@bingg"}); {"@gif", "@wiki", "@vid", "@bing", "@pic", "@bold", "@imdb", "@ImDb", "@coub", "@like", "@vote", "@giff",
"@bingg"});
} }
static void check_bot_command(const td::string &str, const td::vector<td::string> &expected) { static void check_bot_command(const td::string &str, const td::vector<td::string> &expected) {