2018-01-28 18:29:58 -05:00
|
|
|
# Telegram Group Chat Logger
|
|
|
|
|
2018-01-29 00:29:50 -05:00
|
|
|
This is a bot that logs public Group Chats to a Postgres Database.
|
2018-01-28 18:29:58 -05:00
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2018-01-29 00:29:50 -05:00
|
|
|
- Required: Python 3.x, pip, PostgreSQL
|
2018-01-28 18:29:58 -05:00
|
|
|
- Clone this repo
|
2018-01-29 00:29:50 -05:00
|
|
|
- `pip install --upgrade -r requirements.txt`
|
2018-01-28 18:29:58 -05:00
|
|
|
|
2018-01-29 00:29:50 -05:00
|
|
|
## Telegram Bot Setup
|
|
|
|
|
|
|
|
- Create a bot by talking to BotFather: https://core.telegram.org/bots#creating-a-new-bot
|
|
|
|
- Store your Telegram Bot Token in environment variable `BOT_TOKEN`. It will look similar to this:
|
|
|
|
```
|
|
|
|
export TELEGRAM_BOT_TOKEN="4813829027:ADJFKAf0plousH2EZ2jBfxxRWFld3oK34ya"
|
|
|
|
```
|
|
|
|
- Create a Telegram group.
|
2018-01-28 18:29:58 -05:00
|
|
|
- Add your bot to the group like so: https://stackoverflow.com/questions/37338101/how-to-add-a-bot-to-a-telegram-group
|
2018-01-29 01:22:37 -05:00
|
|
|
- Use `/setprivacy` with `@BotFather` in order to allow it to see all messages in a group.
|
2018-01-29 00:29:50 -05:00
|
|
|
|
2018-01-30 18:28:00 -05:00
|
|
|
## Database setup
|
|
|
|
- Store database URL in environment variable.
|
2018-01-29 00:29:50 -05:00
|
|
|
```
|
2018-01-30 18:28:00 -05:00
|
|
|
export TELEGRAM_BOT_POSTGRES_URL="postgresql://<user>:<password>@localhost:5432/<databasename>"
|
2018-01-29 00:29:50 -05:00
|
|
|
```
|
|
|
|
- Run: `python model.py` to setup the DB tables.
|
2018-01-30 18:28:00 -05:00
|
|
|
|
|
|
|
## Running the bot
|
2018-01-29 00:29:50 -05:00
|
|
|
- Run: `python bot.py` to start logger
|
2018-01-30 18:28:00 -05:00
|
|
|
- Messages will be displayed on `stdout` as they are logged.
|