9

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?

zmeftah
  • 148
  • 1
  • 2
  • 10
  • 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 – zmeftah Nov 22 '15 at 15:52

4 Answers4

4

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/

Angus
  • 41
  • 1
3

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!

Reza K Ghazi
  • 347
  • 2
  • 9
  • OP is asking to export the chat history using a bot, not manually through the GUI – Marc Sances Oct 14 '20 at 21:44
  • 1
    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. – Reza K Ghazi Oct 27 '20 at 19:37
1

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.

Stas Parshin
  • 7,973
  • 3
  • 24
  • 43
1

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 use python, 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())
mo1ein
  • 535
  • 4
  • 18