is there any way to save all text-data from a telegram channel using a bot?
Asked Answered
F

4

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?

Flycatcher answered 22/11, 2015 at 15:44 Comment(1)
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. @wogslandFlycatcher
G
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/

Gertie answered 16/7, 2021 at 9:9 Comment(1)
exactly what I was looking for, thank you for this.Countersignature
C
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!

Chow answered 14/10, 2020 at 19:42 Comment(2)
OP is asking to export the chat history using a bot, not manually through the GUIRigsdaler
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
U
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.

Underground answered 22/11, 2015 at 20:20 Comment(0)
P
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())
Polyethylene answered 10/7, 2022 at 18:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.