Answer the question
In order to leave comments, you need to log in
How to collect all hashtags from a Telegram chat?
You need to get, upon request, a list of all hashtags from a particular chat.
How to do it? The telethon library comes to mind. Collect the entire history of messages and if there is a sign there #
, then this is a tag.
But when I do:
It still prints all the messages.
Then I decided this:client.get_messages(chat, 10, search='#')
while True:
history = await client(GetHistoryRequest(
peer=channel,
offset_id=offset_msg,
offset_date=None, add_offset=0,
limit=limit_msg, max_id=0, min_id=0,
hash=0))
if not history.messages:
break
messages = history.messages
for message in messages:
# ...Если есть решётка, значит это хештег,
# извлекаем, возможно, регулярным выражением
#добавляем его в список
Sources: 1 2
Answer the question
In order to leave comments, you need to log in
Check/filter messages when searching by entity type - in your case hashtag
https://core.telegram.org/bots/api#messageentity
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question