c6ca7fc68367338527538572aef1caaa19715588
Bluesky DM to Telegram
This script sends the last message from a specifiec Bluesky conversation with a Bluesky account to a Telegram bot.
Variables
The script expects the following variables:
Variables | Description |
---|---|
WORKING_DIR | Can be changed to whatever directory |
PDSHOST | If your not hosting your own PDS it's probably https://bsky.social |
BLUESKY_HANDLE | The handle of your Blueksy bot account, e. g. my-bluesky-bot.bsky.social |
BLUESKY_PASSWORD | Either your Bluesky bot account's password or it's app password (https://bsky.app/settings/app-passwords) |
CONVO_ID | Conversation-ID of the Bluesky bot account, can be retriefed by using get_messages |
CHAT_ID | Chat-ID of the Telegram bot |
TOKEN | Token for the Telegram bot |
Setup
1. Create Bluesky bot account
- Create a new Bluesky account
- It's recommended to create an app password for your Bluesky account and allow access to DMs
- Paste your PDS host's URL (PDSHOST), your account's handle (BLUESKY_HANDLE) and (app) password (BLUESKY_PASSWORD) into the script's respective variables
- Follow your main Bluesky account, so that it can send the bot account DMs
2. Create a Telegram bot
- Create a new bot using the @BotFather
- Paste the bot's token in the script as the TOKEN variable
- Send any message to the bot
- Visit https://api.telegram.org/bot<$TOKEN>/getUpdates and retrieve the CHAT_ID
- The URL should look something like this:
https://api.telegram.org/bot123456789:ABCdefGHI123_abcDEF/getUpdates
- The CHAT_ID can be found in the following key
.results.0.message.chat.id
- The URL should look something like this:
3. Retrieve your CONVO_ID
- Login to your main Bluesky account and send any message to your Bluesky bot account
- Start the script using the argument
create_session
so retrieve the Bluesky token (token.json) - Start the script again using the argument
get_message
to get the CONVO_ID - Paste the output in the script as the CONVO_ID
Usage
- Start the script without any argument
- The script should create the
bluesky.json
andlast_id.txt
files and send a message to your Telegram bot - Now you can deploy the script e. g. using `rontab to run continously
Files
The script createts and uses several files to store persistent variables.
bluesk.json
stores the latest Bluesky message ID, URI and poster's account handlelast_id.txt
stores the Bluesky message ID of the last message that was succesfully sent to Telegramtoken.json
stores the Bluesky ACCESS_JWT and REFRESH_JWT token
Description
Script that sends the last direct message from a Bluesky bot account to a Telegram bot.
Languages
Shell
100%