Skip to content

1997alireza/Persian-Telegram-WordCloud

 
 

Repository files navigation

licence

Persian Telegram WordCloud

You can make the word cloud of the messages of your chat with your friend or a group of which you are a member. Or you can see which words a channel uses most.

Use Python 3.6+.

Example

The word cloud of the channel @mamlekate

Installation

First install the packages

sh setup.sh

Then you need to get your own Telegram API ID and hash:

  1. Login to your Telegram account with the phone number of the developer account to use.
  2. Click under API Development tools.
  3. A Create new application window will appear. Fill in your application details. There is no need to enter any URL, and only the first two fields (App title and Short name) can currently be changed later.
  4. Click on Create application at the end.

Usage

Edit and configure config.json. (How?)

Run the main file to get your word cloud:

python3 main.py

Configuration

First the configuration file is as follows:

{
	"api_id": 12345,
	"api_hash": "<api_hash>",
	"phone_number": "<phone_number>",

	"dialogs_name": ["<dialog name>"],
	"target_identifier": "<phone_number> | @<username> | me | ",

	"crawl_all_of_dialog": false,
	"max_dialog_count": 20,
	"ignore_english_characters": true,
	"ignore_forwarded_messages": true,

	"color_map": "PuBu",
	"background_color": "black"
}

  • Fill in "api_id", "api_hash" and "phone_number" using your Telegram account details.
"api_id": 12345,
"api_hash": "################################",
"phone_number": "+980000000000",

  • If you want to crawl several selected channels, groups or private chats, write their names (not their IDs) in the "dialogs_name" array.
    If you leave the array empty the program crawls your first "max_dialog_count" groups and private chats.
"dialogs_name": ["Pavel Durov", "BBCPersian"],

or

"dialogs_name": [],

  • If you want to crawl messages which are sent from only one account, fill in "target_identifier" with the account's phone number or ID. If the target is yourself, you can just write "me" instead of your identifier.
    If you leave it empty, the messages from all senders will be crawled.
"target_identifier": "+980000000000",

or

"target_identifier": "@username",

or

"target_identifier": "me",

or

"target_identifier": "",

More Options

  • Only a limited number of messages per each dialog are crawled. Set "crawl_all_of_dialog" to true to crawl all of the messages in each dialog. It takes more time.
  • "max_dialog_count" is the number of dialogs that are crawled when the "dialogs_name" array is empty.
  • Set "ignore_english_characters" to false to not ignore the English characters in the messages.
  • Set "ignore_forwarded_messages" to false to not ignore the forwarded messages.
  • To change the color of texts and background of the word cloud use "color_map" and "background_color" parameters.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 98.9%
  • Shell 1.1%