telegram-patterns
Skill2 starsChanged 4 months agoMITView on GitHub
Telegram-specific patterns and Telethon library usage
1 other project uses a version of this.
Adopted by
Most recently taken up by
- leshchenko1979/fast-mcp-telegramword for word, first seen Jul 28, 2026
Other versions1 project uses a version of this.
Word for word · 1
- leshchenko1979/fast-mcp-telegram★ 50100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository11 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- .cursor/rules/code-optimization.mdcCursor rule
- .cursor/rules/docs-plain-language.mdcCursor rule
- .cursor/rules/general.mdcCursor rule
- .cursor/rules/implementation-workflow.mdcCursor rule
- .cursor/rules/memory-bank.mdcCursor rule
- Clean Up Docs PushSkill
- feature-developmentSkill
- Release Notes GenerationSkill
- Remove Old LogsSkill
- sourcery-pr-cycleSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Always resolve chat/user entities using the utility functions:
- Distinctive: line 26
Use these special identifiers for common chats:
- Distinctive: line 44
Check for various types of message content:
- Distinctive: line 61
Use proper patterns for iterating through messages:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Telegram-Specific Patterns
Entity Resolution
Always resolve chat/user entities using the utility functions:
from src.utils.entity import get_entity_by_id
# ✅ Correct - handles all entity types (users, chats, channels)
entity = await get_entity_by_id(chat_id)
if not entity:
raise ValueError(f"Could not find chat with ID '{chat_id}'")
# ❌ Wrong - don't use client.get_entity directly
entity = await client.get_entity(chat_id) # Missing error handlingSpecial Chat Identifiers
Use these special identifiers for common chats:
# Saved Messages (your own messages)
chat_id = "me"
# Channel IDs (always start with -100)
channel_id = "-1001234567890"
# User IDs (numeric strings)
user_id = "123456789"
# Usernames (without @)
username = "telegram"Message Content Detection
Check for various types of message content:
# Check for text content
has_text = message.text and message.text.strip()
# Check for media content (photos, documents, etc.)
has_media = hasattr(message, "media") and message.media is not None
# Check for specific media types
is_photo = hasattr(message, "photo") and message.photo is not None
is_document = hasattr(message, "document") and message.document is not None
is_voice = hasattr(message, "voice") and message.voice is not NoneMessage Iteration
Use proper patterns for iterating through messages:
# ✅ Correct - limit results and handle empty messages
async for message in client.iter_messages(entity, limit=50):
if not message:
continue
# Process message
await process_message(message)
# ❌ Wrong - no limit can cause performance issues
async for message in client.iter_messages(entity): # No limit!
passForwarded Message Handling
Handle forwarded messages properly:
# Check if message is forwarded
if hasattr(message, "forward") and message.forward:
forward_info = await _extract_forward_info(message)
original_sender = forward_info.get("sender")
original_chat = forward_info.get("chat")
forward_date = forward_info.get("date")Peer ID Handling
Work with different peer ID types:
# User peer
user_peer = {"_": "inputPeerUser", "user_id": 123456, "access_hash": 123456789}
# Channel peer
channel_peer = {"_": "inputPeerChannel", "channel_id": 123456, "access_hash": 123456789}
# Chat peer
chat_peer = {"_": "inputPeerChat", "chat_id": 123456}
# Self peer (Saved Messages)
self_peer = {"_": "inputPeerSelf"}Session Management
Handle Telegram session files properly:
# Session files are managed automatically by the framework
# Don't manually create or delete session files
# Use setup_telegram.py for initial authentication
# Session file location is determined by environment:
# - Local development: project root
# - Production/ephemeral: ~/.config/fast-mcp-telegram/Rate Limiting Awareness
Be aware of Telegram API limits:
# Respect rate limits
import asyncio
await asyncio.sleep(1) # Rate limiting between requests
# Use reasonable limits for bulk operations
MAX_MESSAGES = 100 # Don't fetch thousands at once
BATCH_SIZE = 50 # Process in reasonable batchesError Pattern Recognition
Recognize common Telegram errors:
error_text = str(e).lower()
# Channel access errors
if "channel" in error_text and "access" in error_text:
return {"error": "Cannot access this channel"}
# Flood wait errors
if "flood" in error_text and "wait" in error_text:
return {"error": "Rate limited, please wait before retrying"}
# Authentication errors
if "auth" in error_text or "session" in error_text:
return {"error": "Authentication required, run setup_telegram.py"}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

