Skip to content
Back to skills

Telethon Session

ASecurity

Generate Telethon .session files for user-account login to Telegram. Use when: (1) user wants to test a Telegram bot as a real user, (2) user needs to interact with Telegram via user identity, (3) creating a Telegram session for Telethon-based automation, (4) mentions telethon, telegram session, or user-account login. NOT for: bot-token-based bots (no session needed).

  • 33 stars
  • 0 votes
  • 0 copies
  • 14 views
  • Added September 5, 2026
toolspythonbashapi

Works with

  • cli
  • api

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro scans all 2 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add dvcrn/openclaw-skills-marketplace --skill telethon-session --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Telethon Session?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Telethon Session
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/dvcrn-telethon-session/badge)](https://www.skillsdirectory.com/skills/dvcrn-telethon-session)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: telethon-session
description: "Generate Telethon .session files for user-account login to Telegram. Use when: (1) user wants to test a Telegram bot as a real user, (2) user needs to interact with Telegram via user identity, (3) creating a Telegram session for Telethon-based automation, (4) mentions telethon, telegram session, or user-account login. NOT for: bot-token-based bots (no session needed)."
---

# Telethon Session Generator

Generate a `.session` file to authenticate a Telegram user account via Telethon.

## Prerequisites

- `telethon` — install with `pip install telethon` (use venv if needed)
- API credentials from <https://my.telegram.org> (api_id + api_hash)

## Quick Start

Run the bundled script in interactive (PTY) mode — Telegram will send a login code and optionally ask for 2FA:

```bash
python3 scripts/login.py --api-id YOUR_ID --api-hash YOUR_HASH --phone "+86..."
```

The script prompts for:
1. **Login code** — from Telegram app or SMS
2. **2FA password** — only if enabled on the account

On success, `<session_name>.session` is created in the working directory.

## Key Notes

- **Session file is reusable** — no need to re-login unless Telegram invalidates it
- **Do NOT commit `.session` files** to version control (treat as secrets)
- **Bot token ≠ session** — bots use `bot_token=` in Telethon, no session file needed
- If `pip install telethon` fails on externally-managed Python, use a venv:
  ```bash
  python3 -m venv venv
  source venv/bin/activate
  pip install telethon
  ```

## Using the Session File

```python
from telethon import TelegramClient

client = TelegramClient('telegram_session', api_id, api_hash)
await client.start()  # auto-loads session, no prompt needed
```

Files in this skill

  • SKILL.md1.7 KB
  • scripts/login.py1.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.