Cameron Grant 6ce7117cc4
All checks were successful
continuous-integration/drone/push Build is passing
Correctly handles multiple messages.
2025-10-06 16:12:38 -07:00
2025-10-06 16:12:38 -07:00
2025-10-03 23:56:52 -04:00
2025-10-03 23:40:06 -04:00
2025-10-03 17:43:05 -07:00
2025-10-03 13:31:54 -07:00
2025-10-03 16:22:07 -07:00
2025-10-03 16:22:07 -07:00
2025-09-26 10:15:55 -07:00
2025-10-03 16:22:07 -07:00
2025-10-03 16:22:07 -07:00
2025-10-03 18:13:42 -07:00

telegram-scam-baiter

Telethon + OpenAI bot that engages unsolicited DMs with safe, time-wasting small talk. It uses a focused system prompt, keeps recent chat history, and replies with human-like delays to keep scammers busy while revealing nothing useful.

What it does

  • Listens for messages from a single target (by username or numeric user ID), or auto-targets the first inbound DM.
  • Maintains a rolling history and crafts short, question-ending replies to keep the other person typing.

Environment variables

Variable Required Default Description
TG_API_ID yes Telegram API ID from https://my.telegram.org
TG_API_HASH yes Telegram API hash from https://my.telegram.org
TG_SESSION no telethon_session Session file prefix used by Telethon
TARGET_USERNAME no Target's public username (without @). Leave empty if using TARGET_USER_ID
TARGET_USER_ID no 0 Target's numeric Telegram user ID (use if no username)
TARGET_DISPLAY_NAME no Persons display name (case-insensitive; exact or partial match across dialogs)
TARGET_CACHE_FILE no target_id.txt Path to store resolved numeric ID for future runs
OPENAI_API_KEY yes OpenAI API key
OPENAI_MODEL no gpt-4o-mini Chat-capable model used for replies
MIN_DELAY_SEC no 25 Minimum delay (seconds) before each reply
MAX_DELAY_SEC no 75 Maximum delay (seconds) before each reply
HISTORY_FILE no chat_history.jsonl Path to local JSONL file for conversation history
MAX_TOKENS_HISTORY no 2200 Rough token budget for messages passed to the model
MAX_MESSAGES_HISTORY no 30 Hard cap on number of messages kept in rolling history
AUTO_OPENER_ENABLED no false If true, send an initial opener only on fresh start when a target is resolved and no catch-up reply was needed
OPENER_TEXT no The opener text to send when AUTO_OPENER_ENABLED=true
TYPING_SIM_ENABLED no true Show a "typing…" indicator before sending the message
TYPING_WPM no 22 Approximate words per minute to estimate typing duration
TYPING_MIN_SEC no 2.0 Minimum typing duration (seconds)
TYPING_MAX_SEC no 18.0 Maximum typing duration (seconds)
PYTHONUNBUFFERED no 1 If set, forces unbuffered output in some environments

Notes:

  • Set one of TARGET_USERNAME, TARGET_USER_ID, or TARGET_DISPLAY_NAME. If none are set, the first inbound DM will become the target automatically.
  • The opener is disabled by default to avoid sending context-specific messages; enable explicitly with AUTO_OPENER_ENABLED and provide OPENER_TEXT.
  • Increase delays if you hit Telegram flood limits.

License

MIT License — see LICENSE file for details.

Description
No description provided
Readme MIT 162 KiB
Languages
Python 84.7%
Smarty 9.3%
Shell 3.1%
Dockerfile 2.9%