Skip to content

lapismyt/telegram_gifts_sniper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buy new limited Telegram gifts instantly using Telegram Business bot

⚠️ WARNING: This script is not completed, some features are not implemented yet. Also, it's not well-tested and can work unstable or even result in loss of funds. Please, use it very carefully.

TODO:

  • 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 ❓

Config explanation

  • 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: Like gift_price, this is also array with min and max, but for min and max supply. Bot will buy gift only if
  • max_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 be true ("yes") or false ("no"). If true, 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 if auto_upgrade is true.
  • sort: Array, containing two elements: sort by and order. "Sort by" can be price, supply, or random. "Order" can be asc (ascending) or desc (descending). Applied only for auto-buy. For auto-upgrade always ["price", "desc"] is applied. For random sort, 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, INFO is perfect.

About api_id and api_hash

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.

How to use

  1. Install Python >=3.12, if not installed.
  2. Download repository to your PC or server.
  3. Install dependecies from pyproject.toml or requirements.txt. You can use uv or pip. If you use pip, it's recommended to also use venv.
  4. Create app and obtain api_id and api_hash on my.telegram.org.
  5. Create bot in @BotFather and enable Business Mode in Bot Settings.
  6. Copy config-example.toml to config.toml and fill config fields.
  7. Run python3 -m telegram_gifts_sniper in this repo folder.
  8. (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.

Optimizations

Script uses some optimizations by default:

  • asyncio for optimizing parallel tasks, especially network requests.
  • aiosqlite instead of sqlite3 for better compatibility with asyncio.
  • telethon for 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.

How to be safe

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.

Feedback

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!

Donation

If you like this script, you can send me some TON for a coffee:

UQBITU-03tqNOXT24oV-QwC_pnfW7AuS3aAYectWP9UfAbrP (ton-lapismyt.ton)

About

Script for auto-buy & auto-upgrade limited gifts in Telegram using Telegram Business

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages