2020-08-10 07:23:19 +00:00
# Telegram Index
> Python Web App which indexes a telegram channel(or a chat) and serves its files for download.
2020-08-20 10:52:08 +05:30
[](.) [](LICENSE)
2020-08-10 07:23:19 +00:00
2020-08-20 10:52:08 +05:30
## Highlights
* Index one or more telegram channels/chats.
* View messages and media files on the browser.
* Search through the channel/chat.
* Download media files through browser/download managers.
2020-08-10 07:23:19 +00:00
## Deploy Guide
2020-08-17 13:14:02 +05:30
* **Clone to local machine.**
2020-08-10 07:23:19 +00:00
2020-12-12 22:01:59 +05:30
``` bash
git clone https://github.com/odysseusmax/tg-index.git
cd tg-index
2020-08-10 07:23:19 +00:00
```
2020-08-17 13:14:02 +05:30
* **Create and activate virtual environment.**
2020-08-10 07:23:19 +00:00
2020-12-12 22:01:59 +05:30
``` bash
pip3 install virtualenv
virtualenv venv
source venv/bin/activate
2020-08-10 07:23:19 +00:00
```
2020-08-17 13:14:02 +05:30
* **Install dependencies.**
2020-08-10 07:23:19 +00:00
2020-12-12 22:01:59 +05:30
``` bash
pip3 install -U -r requirements.txt
2020-08-10 07:23:19 +00:00
```
2020-08-17 13:14:02 +05:30
* **Environment Variables.**
2020-08-10 07:23:19 +00:00
2020-08-17 13:14:02 +05:30
| Variable Name | Value
2020-08-10 07:24:30 +00:00
|------------- | -------------
2020-12-12 22:01:59 +05:30
| `API_ID` (required) | Telegram api_id obtained from < https: // my . telegram . org / apps > .
| `API_HASH` (required) | Telegram api_hash obtained from < https: // my . telegram . org / apps > .
2020-08-17 13:14:02 +05:30
| `INDEX_SETTINGS` (required) | See the below description.
2020-08-10 07:23:19 +00:00
| `SESSION_STRING` (required) | String obtained by running `$ python3 app/generate_session_string.py` . (Login with the telegram account which is a participant of the given channel (or chat).
| `PORT` (optional) | Port on which app should listen to, defaults to 8080.
| `HOST` (optional) | Host name on which app should listen to, defaults to 0.0.0.0.
2021-05-22 19:30:08 +05:30
| `DEBUG` (optional) | Give `true` to set logging level to debug, info by default.
| `BLOCK_DOWNLOADS` (optional) | Enable downloads or not. If any value is provided, downloads will be disabled.
2020-12-12 22:01:59 +05:30
| `RESULTS_PER_PAGE` (optional) | Number of results to be returned per page defaults to 20.
2021-06-06 17:41:41 +05:30
| `TGINDEX_USERNAME` (optional) | Username for authentication, defaults to `''` .
2021-06-10 08:58:25 +05:30
| `PASSWORD` (optional) | Password for authentication, defaults to `''` .
2021-06-06 18:12:06 +05:30
| `SHORT_URL_LEN` (optional) | Url length for aliases
2021-05-22 19:30:08 +05:30
| `SESSION_COOKIE_LIFETIME` (optional) | Number of minutes, for which authenticated session is valid for, after which user has to login again. defaults to 60.
2021-06-13 16:31:23 +05:30
| `SECRET_KEY` (optional) | 32 characters long string for signing the session cookies, required if authentication is enabled.
2020-08-10 07:23:19 +00:00
2020-08-17 13:14:02 +05:30
* **Setting value for `INDEX_SETTINGS` **
2020-08-24 17:21:19 +05:30
This is the general format, change the values of corresponding fields as your requirements. Remember to remove spaces.
2020-08-17 13:14:02 +05:30
2020-12-12 22:01:59 +05:30
``` json
2020-08-17 13:14:02 +05:30
{
"index_all": true,
"index_private":false,
"index_group": false,
"index_channel": true,
2020-08-18 10:34:35 +05:30
"exclude_chats": [],
2020-12-12 22:01:59 +05:30
"include_chats": []
2020-08-17 13:14:02 +05:30
}
```
2020-12-12 22:01:59 +05:30
>
2020-08-20 10:52:08 +05:30
> * `index_all` - Whether to consider all the chats associated with the telegram account. Value should either be `true` or `false`.
> * `index_private` - Whether to index private chats. Only considered if `index_all` is set to `true`. Value should either be `true` or `false`.
> * `index_group` - Whether to index group chats. Only considered if `index_all` is set to `true`. Value should either be `true` or `false`.
> * `index_channel` - Whether to index channels. Only considered if `index_all` is set to `true`. Value should either be `true` or `false`.
2020-09-19 16:58:02 +05:30
> * `exclude_chats` - An array/list of chat id's that should be ignored for indexing. Only considered if `index_all` is set to `true`.
> * `include_chats` - An array/list of chat id's to index. Only considered if `index_all` is set to `false`.
2020-08-17 13:14:02 +05:30
* **Run app.**
2020-08-10 07:23:19 +00:00
2020-12-12 22:01:59 +05:30
``` bash
python3 -m app
2020-08-10 07:25:42 +00:00
```
2020-08-10 07:23:19 +00:00
## Contributions
Contributions are welcome.
## Contact
You can contact me [@odysseusmax ](https://tx.me/odysseusmax ).
## License
2020-12-12 22:01:59 +05:30
2020-08-10 07:23:19 +00:00
Code released under [The GNU General Public License ](LICENSE ).