Telegram
Telegram Importer Plugin for Memri
This plugin imports Telegram contacts and messages to your Memri Pod after QR-based authorization.
Install
To install as a Python package, run:
pip install -e .
Obtaining Telegram API Keys
- Follow the instructions here
Run
Local, Non-docker
You need to have a pod running with Telegram credentials exported to environment beforehand. Then, you can run the plugin locally with the run_plugin CLI:
NOTE: Make sure that the plugin instance also has access to Telegram credentials.
export TELEGRAM_APP_KEY=12345678
export TELEGRAM_APP_SECRET="1234567890123456"
run_plugin --metadata "metadata.json"
Authorization
If valid credentials exist in Pod, then they will be used.
Otherwise, go to /qr
endpoint of the server started in the process,
which is displayed in the output, and complete QR authorization.
If you have 2 factor authentication enabled,
you will need to provide the code in the terminal.
It is done by sending a POST request to /v1/2fa
endpoint with the code in the json body.
Example:
# using curl
curl -X POST -H "Content-Type: application/json" -d '{"code": "123456"}' http://localhost:8080/v1/2fa
# using httpie
http POST http://localhost:8080/v1/2fa code=123456
Docker
docker buildx build . -t telegram --platform linux/amd64 --build-arg TELEGRAM_APP_KEY=$TELEGRAM_APP_KEY --build-arg TELEGRAM_APP_SECRET=$TELEGRAM_APP_SECRET
To run the plugin:
simulate_run_plugin_from_frontend --metadata "metadata.json"
Authorization
If valid credentials exist in Pod, then they will be used.
Otherwise, go to /qr
endpoint of the server started in the process,
which is displayed within Pod logs, and complete QR authorization.
Data imported
- Account
- handle
- displayName
- photo
- MessageChannel
- name
- photo
- Message
- sender
- content
- receiver
- messageChannel
Contributing
You are welcome to create issues and send merge requests. See contributing
Legal
This code is in no way affiliated with, authorized, maintained, sponsored or endorsed by Telegram or any of its affiliates or subsidiaries. This is an independent and unofficial software. Use at your own risk.