What do Russians think about the war? Telegram data

The Details

First, get a Telegram API key and API hash. Then download a json archive of posts for the time period you’re interested in. Get the channel id from it, remembering to preface it with -100 (important!) in your code. Then, in Python>3.6, use your package manager to get pyrogram, a high-level library for dealing with Telegram’s API. Then do something like this:

from pyrogram import Client
from pyrogram.raw.functions.messages import GetMessageReactionsList
file=open(“russian_out_new.txt”,”w”, encoding=”utf-8")app = Client(
“my_account”,
api_id=YOUR ID HERE,
api_hash=’YOUR HAS HERE’
)
chat_id = -100NNNNNNN # YOUR CHANNEL HERE, PRECEDED BY -100 IF IT’S A PUBLIC GROUP
number_of_results=10 #the number of messages to return
with app:
peer = app.resolve_peer(chatid)
file.write(“id;date;react;\n”)
for message in app.get_chat_history(chatid, number_of_results):
file.write(str(message.id)+”;”)
file.write(str(message.date)[0:10]+”;”)
file.write(str(message.reactions)+”;\n”)
#This writes the data as a ; separated CSV.file.close()
I recommend not using Excel!

The Results

What I did was the following: I made lists of the most interacted with, most thumbs-upped, and most thumbs-downed posts for the time period I was interested in for the Russian TASS channel. Let’s consider these latter two categories.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matthew McKeever

Matthew McKeever

Novella "Coming From Nothing" at @zer0books (bitly.com/cfnextract). Academic philosophy at: http://mipmckeever.weebly.com/