I need to save all text-data from a public channel of telegram in a text file. (so I can do some analysis on it later) is it possible to write a bot that can do such thing?
is there any way to save all text-data from a telegram channel using a bot?
Asked Answered
I'm sorry but I did not understand what you meant, maybe my question was vague, It's like copy and paste from a public channel but I want to do it automatically. my question is if a telegram bot can help. @wogsland –
Flycatcher
There is a project https://github.com/xtrime-ru/TelegramApiServer that allows you to fetch Telegram public channel in forms of JSON.
Its testing site is https://tg.i-c-a.su/
exactly what I was looking for, thank you for this. –
Countersignature
Follow the instruction below:
- Open the group in the Telegram Desktop app.
- Click on three dots on the top-right corner.
- Choose Export chat history
- Select everything you want (in checkmark list)
- Choose the maximum size of videos and pictures you want
- Choose a folder by clicking on the destination in the link bottom
- Start to export
Everything (Docs, Medias, Chats, ...) will be exported in the desired folder.
Done!
OP is asking to export the chat history using a bot, not manually through the GUI –
Rigsdaler
Using a bot can be done if there is some API for accessing telegram content as a developer. Is there any!? So, it's better to have all data outside of the source then try to create a bot to do whatever is needed. –
Chow
It's possible only for groups. If you disable privacy mode for the bot. But channels don't allow it. You can add bot as administrator of channel, but bot won't receive messages sending by other administrators.
Yes. There are two methods:
- 1 - Telegram desktop.
Go to chat > Click on three dots on the top-right corner > Export chat history. - 2 - Telegram API frameworks
If you usepython
, I recommend pyrogram.
from pyrogram import Client
app = Client(
"YOUR_BOT",
api_id='YOUR_API_ID',
api_hash='YOUR_API_HASH',
)
async def main():
async with app:
async for message in app.get_chat_history(chat_id):
print(message.text)
app.run(main())
© 2022 - 2024 — McMap. All rights reserved.