The crawler component ofDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/backtest-kit/backtest-ollama-crontab/llms.txt
Use this file to discover all available pages before exploring further.
backtest-ollama-crontab connects to Telegram using GramJS (the telegram npm package) over the MTProto protocol. Unlike a Telegram Bot, this is a user-account connection — it authenticates as a real Telegram user, which is required to read messages from public channels without needing to be a member or administrator. Once authentication succeeds, GramJS serializes the session to a session.txt file. Every subsequent run loads that file and reconnects without prompting again.
Get Telegram API Credentials
Before you can authenticate, you need a Telegram application registered under your account:- Open my.telegram.org in a browser and log in with your phone number.
- Navigate to API Development Tools.
- Fill in the form (App title and short name can be anything) and click Create Application.
- Copy the App api_id (an integer) and App api_hash (a 32-character hex string).
- Add both values to your
.envfile:
.env
The bundled default credentials (
CC_TELEGRAM_API_ID=31861455) are demo values included for development convenience. They have strict rate limits imposed by Telegram and may not work for all public channels. Always replace them with your own application credentials before running the crawler against real channels.Run the Auth Command
Thepackages/main package exposes an auth script that launches a QR-code authentication flow using qrcode-terminal. The script is triggered by passing --session to the main entry point, which npm run auth handles automatically.
Run the auth command
.env are injected before the process starts, so your CC_TELEGRAM_API_ID and CC_TELEGRAM_API_HASH values are available at runtime.Scan the QR code on your phone
On your mobile device:
- Open Telegram.
- Go to Settings → Devices (or Settings → Privacy and Security → Active Sessions on some versions).
- Tap Link Desktop Device.
- Point your camera at the QR code displayed in the terminal.
Enter your 2FA password if prompted
If your Telegram account has two-step verification enabled, the terminal will prompt:Type your cloud password and press Enter.
Session file is written
On successful authentication the terminal prints:The file
packages/main/session.txt now contains your serialized GramJS StringSession.Session File
session.txt contains a single serialized string produced by the GramJS StringSession class. The getTelegram() function in packages/core/src/config/telegram.ts wraps session loading in a singleshot singleton so the client is initialized only once per process lifetime:
packages/core/src/config/telegram.ts
session.txt is missing, readFile throws and the error handler logs:
session.txt file must be present in the working directory from which the crawler process is launched — not necessarily at the repository root. When running a specific strategy, place the file inside that strategy’s content folder and start the process from there.
Security Considerations
session.txtis already listed in.gitignoreat the repository root. Verify this before your first commit if you have modified.gitignore.- Never copy
session.txtinto a Docker image or include it in build artifacts. - The crawler targets public Telegram channels; no channel membership or administrative rights are required — a valid authenticated Telegram account is sufficient.
- If you need to rotate a session (e.g. after a password change or a suspected leak), delete
session.txt, re-runnpm run auth, and replace the file in all strategy folders.