- Config ✅
- Authorization ✅
- Getting available gifts ✅
- Database-related functions ✅
- Connecting to user account via Telegram Business ✅
- Transferring stars from user ✅
- Buying gifts ✅
- Auto-buy task ✅
- Filling bot balance with required amount of stars ✅
- Limiting auto-buy to config settings ✅
- Auto-buy ✅ (needs testing)
- Checking user's gifts ⏳
- Upgrading gifts ❌
- Auto-upgrade task ❌
- Limiting auto-upgrade to config settings ❌
- Auto-upgrade ❌
- Rewrite in Rust using grammers ❌
- Host public bot with some limitations and extra optimizations ❓
bot_token: Telegram bot token. To get this, you need to create bot in @BotFather.api_id: API ID from my.telegram.org.api_hash: API Hash from my.telegram.org.owner_id: Your User ID in Telegram. You can get it by enabling "Show Peer IDs in Profile" in Telegram Desktop settings, or by sending any message to @userinfobot.gift_price: Array, containing two elements: min price and max price in stars. Bot will buy new gift only if it's price in stars will be between this two numbers.gift_supply: Likegift_price, this is also array with min and max, but for min and max supply. Bot will buy gift only ifmax_stars_per_gift: Maximum stars amount that can be spent on one gift. Used only for auto-buy, not for auto-upgrade.auto_upgrade: Can betrue("yes") orfalse("no"). Iftrue, bot will auto upgrade gifts on an account.max_upgrade_price: Bot will upgrade gift only if upgrade price for this gift is not more than this number. Used only ifauto_upgradeistrue.sort: Array, containing two elements: sort by and order. "Sort by" can beprice,supply, orrandom. "Order" can beasc(ascending) ordesc(descending). Applied only for auto-buy. For auto-upgrade always["price", "desc"]is applied. Forrandomsort, order will be ignored.message: Message to be attached to gift. Can be empty string. HTML is used as parse mode, so you need to escape<and>, if it's not a part of HTML tag.anti_floodwait_check: Telegram can block bot for few seconds with FloodWaitError if bot sends requests too fast. This value is delay between requests in seconds while checking if new gifts available. The shorter delay, the faster bot will be, but it's not recommended to set anti-FloodWait values to less than 0.01.anti_floodwait_buy: Anti-FloodWait delay, but this one is between buying new gifts.anti_floodwait_upgrade: Anti-FloodWait delay, but this one is between upgrading gifts when upgrade for gifts is available for needed price.anti_floodwait_base: Anti-FloodWait delay, but this one is between basic system requests like refreshing business connection data. In most cases, this value is added to the other delays.log_level: Logging level. In most cases,INFOis perfect.
To improve performance, this script uses directly Telegram MTProto protocol, instead of HTTP Bot API. By using this, script is not limited to 30 RPS, but you need to create app in my.telegram.org ("API development" tab) and get api_id and api_hash.
- Install Python >=3.12, if not installed.
- Download repository to your PC or server.
- Install dependecies from
pyproject.tomlorrequirements.txt. You can useuvorpip. If you usepip, it's recommended to also usevenv. - Create app and obtain
api_idandapi_hashon my.telegram.org. - Create bot in @BotFather and enable Business Mode in Bot Settings.
- Copy config-example.toml to config.toml and fill config fields.
- Run
python3 -m telegram_gifts_sniperin this repo folder. - (OPTIONAL) If you want to use this command in any folder and you don't use virtal environment, you can use
python3 -m pip install ..
For any regular questions like "how to run script with Python", use Google or DeepSeek, please.
Script uses some optimizations by default:
asynciofor optimizing parallel tasks, especially network requests.aiosqliteinstead ofsqlite3for better compatibility withasyncio.telethonfor interacting with MTProto directly instead of HTTP Bot API.
You can try PyPy, but it's strongly not recommended.
Also, maybe I will add option to use uvloop event loop instead of the default.
You need to self-host this bot. If someone offers to host bot and connect to your account - it can be a scam. Also, one bot - one user. It's very important to use your bot and your hosting, so you can be safe.
If you found bugs or have suggestions - please, open Issue about it. You can use Russian, but it will be better if you will write in English. Also, if you think this script violates Telegram's Terms of Service (ToS) - you can open Issue about it with a quote from ToS and link to that page. Thanks!
If you like this script, you can send me some TON for a coffee:
UQBITU-03tqNOXT24oV-QwC_pnfW7AuS3aAYectWP9UfAbrP (ton-lapismyt.ton)