> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cryptechtoday.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a Telegram Scam Bot

> Create an automated Telegram bot in Python to audit contract addresses posted in your trading group

# Build a Telegram Scam Alert Bot

In this guide, you will build a Python Telegram bot that automatically listens to messages in your crypto trading group, extracts Ethereum/EVM contract addresses, queries the CrypTech API, and replies with a clean security report.

***

## Step 1: Install Dependencies

Install `pyTelegramBotAPI` and `requests`:

```bash theme={null}
pip install pyTelegramBotAPI requests
```

***

## Step 2: Bot Script (`bot.py`)

Create a file named `bot.py` and replace `YOUR_TELEGRAM_BOT_TOKEN` and `YOUR_CRYPTECH_API_KEY`:

```python theme={null}
import re
import requests
from telebot import TeleBot

TELEGRAM_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN"
CRYPTECH_API_KEY = "YOUR_CRYPTECH_API_KEY"

bot = TeleBot(TELEGRAM_TOKEN)

# Regex pattern for Ethereum / EVM contract addresses
ETH_ADDRESS_REGEX = r"0x[a-fA-F0-9]{40}"

@bot.message_handler(func=lambda message: True)
def handle_group_message(message):
    text = message.text or ""
    match = re.search(ETH_ADDRESS_REGEX, text)
    
    if not match:
        return

    contract_address = match.group(0)
    bot.reply_to(message, f"🔍 Auditing contract `{contract_address}`...")

    try:
        response = requests.post(
            "https://api.cryptechtoday.com/api/v1/analyze",
            headers={
                "X-API-Key": CRYPTECH_API_KEY,
                "Content-Type": "application/json"
            },
            json={"address": contract_address, "chain": "ethereum"},
            timeout=10
        )

        if response.status_code != 200:
            bot.reply_to(message, f"⚠️ Audit failed with status {response.status_code}.")
            return

        data = response.json()
        raw = data.get("raw_summary", {})
        sellability = data.get("sellability", {})

        is_honeypot = "🚨 HONEYPOT" if raw.get("is_honeypot") else "✅ SAFE"
        score = data.get("total_score", 0)
        risk = data.get("risk_label", "UNKNOWN")
        max_exit = sellability.get("max_safe_exit_usd", 0)

        report = (
            f"🛡️ *CrypTech Token Audit: {data.get('symbol', 'UNKNOWN')}*\n"
            f"━━━━━━━━━━━━━━━━━━━\n"
            f"• *Verdict*: {is_honeypot}\n"
            f"• *Safety Score*: {score}/100 ({risk})\n"
            f"• *Buy Tax*: {raw.get('buy_tax_pct', 0)}% | *Sell Tax*: {raw.get('sell_tax_pct', 0)}%\n"
            f"• *Liquidity*: ${raw.get('liquidity_usd', 0):,.0f}\n"
            f"• *Max Safe Exit*: ${max_exit:,.0f}\n"
            f"• *LP Locked*: {'YES 🔒' if raw.get('lp_locked') else 'NO ⚠️'}\n"
            f"━━━━━━━━━━━━━━━━━━━\n"
            f"🔗 [View Live on CrypTech](https://app.cryptechtoday.com)"
        )

        bot.reply_to(message, report, parse_mode="Markdown", disable_web_page_preview=True)

    except Exception as e:
        bot.reply_to(message, f"⚠️ Error: {str(e)}")

if __name__ == "__main__":
    print("🤖 CrypTech Telegram Bot is running...")
    bot.infinity_polling()
```

***

## Step 3: Run the Bot

Run the script in your terminal:

```bash theme={null}
python bot.py
```

Now invite your bot into your Telegram group or send it a direct message containing any contract address (e.g., `0x514910771AF9Ca656af840dff83E8264EcF986CA`). The bot will reply with a risk card.


## Related topics

- [Authentication](https://docs.cryptechtoday.com/authentication.md)
- [Errors & Rate Limits](https://docs.cryptechtoday.com/errors-and-limits.md)
- [Alpha Radar](https://docs.cryptechtoday.com/api-reference/alpha-radar.md)
- [Introduction](https://docs.cryptechtoday.com/index.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.