Skip to content

Instantly share code, notes, and snippets.

@HookedBehemoth
Last active April 10, 2023 22:05
Show Gist options
  • Save HookedBehemoth/355e55f082c6adb8b1f3cfa9f313750c to your computer and use it in GitHub Desktop.
Save HookedBehemoth/355e55f082c6adb8b1f3cfa9f313750c to your computer and use it in GitHub Desktop.
Telegram patch to hide aliexpress ads
diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp
index 5b965667b..6fd2e6eb4 100644
--- a/Telegram/SourceFiles/history/history.cpp
+++ b/Telegram/SourceFiles/history/history.cpp
@@ -435,6 +435,9 @@ std::vector<not_null<HistoryItem*>> History::createItems(
const auto detachExistingItem = true;
for (auto i = data.cend(), e = data.cbegin(); i != e;) {
const auto &data = *--i;
+ if (data.type() == mtpc_message &&
+ qs(data.c_message().vmessage()).contains("https://s.click.aliexpress.com/"))
+ continue;
result.emplace_back(createItem(
IdFromMessage(data),
data,
diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp
index 2a312bb4a..447d39517 100644
--- a/Telegram/SourceFiles/history/history_item.cpp
+++ b/Telegram/SourceFiles/history/history_item.cpp
@@ -303,12 +303,17 @@ HistoryItem::HistoryItem(
createServiceFromMtp(data);
applyTTL(data);
} else {
+ auto msg = qs(data.vmessage());
+
+ if (msg.contains("https://s.click.aliexpress.com/"))
+ return;
+
createComponents(data);
if (const auto media = data.vmedia()) {
setMedia(*media);
}
auto textWithEntities = TextWithEntities{
- qs(data.vmessage()),
+ msg,
Api::EntitiesFromMTP(
&history->session(),
data.ventities().value_or_empty())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment