tg-scraper is a trading bot which listens for messages from specific Telegram channels, parse them for Solana addresses, and forward the addresses to BonkBot.
Between November 2023 and March 2024, the Solana ecosystem was booming and at the core of it, there were callers (influencers) who shared token addresses (think of it like a stock ticker) within their Telegram channels, each of which had thousands of subscribers. These posts typically caused the value of the shared tokens to surge within seconds to minutes, as people quickly bought into the tokens.
The purpose of this bot was to purchase the token immediately after the caller posted it, before others could, hold it briefly, and then sell it for a profit. As other bots are now way faster than this one, I decided to open source this project for educational purposes.
Here is a demonstration of the bot in action: a token address is sent through a test channel, the bot detects it, quickly buys the token, and then sells it 10 seconds later for a potential profit.
202409291617.mp4
The bot is capable of executing a buy within 2 to 4 seconds. Initially, I ran it on my laptop, being careful not to close the VS Code tab. Later on, I deployed the bot on a small DigitalOcean droplet, running up to 3 instances at the same time, each with a different Telegram account and strategy. During peak market activity, this bot was making over 200 SOL a month.
- A Telegram account with access to BonkBot (McQueen)
- Telegram API credentials (API ID and API Hash)
- A Telegram private channel to use as a test channel
- A list of Telegram channels you want the bot to listen to
Create a virtual environment:
python3 -m venv myenv
Activate the virtual environment:
source myenv/bin/activate
Install the required dependencies from requirements.txt
:
pip install -r requirements.txt
This command will print out all the channels your account is subscribed to, along with their IDs:
python dialogs.py
You can then place those IDs in util.py
within the ids_to_names
dictionary.
API_ID= # Your Telegram API ID
API_HASH= # Your Telegram API Hash
PUBKEY= # Your BonkBot public key
TEST_CHANNEL= # ID of your test channel
HOLDING_TIME= # Holding time for trades in seconds
BAN_WORDS=potatotest,bananatest # List of banned words
- Make sure you have some SOL in your wallet.
- Configure the bot settings as needed.
- Make sure to enable the auto-buy feature.
Start the bot:
python lanaos.py
Once running, the bot will begin listening for messages and will log every trade both in the terminal and in the logs.csv
file.