Logo van Tg Hub

Tg Hub

Organisatie
OpenMinis
tg-hub

A skill for reading and writing Telegram data with Python and UV. It depends only on Telethon and uses a local-first architecture: messages are synced to SQLite and then queried offline. On first use, you must log in from the terminal with a phone number verification code. After that, the session is persisted and you do not need to log in again. Supports syncing group and channel messages locally, keyword search, multi-keyword filtering, today's messages, recent messages, speaker rankings, timeline statistics, and more. This skill must be triggered whenever the user mentions "Telegram", "TG", "Telegram", "tg-hub", "sync Telegram messages", "search TG groups", "Telegram keywords", "get TG messages", or any scenario that requires programmatically reading or writing Telegram data.

Overzicht

UitgeverOpenMinis
RepositoryMinisSkills
Skillnaamtg-hub
Sterren
543
Forks
86
Meegeleverde bestanden
7
LicentieMIT
Links
  • Instructies in Markdown

    Het model laadt het bestand SKILL.md alleen als dat nodig is. Dat kost dus alleen tokens als een verzoek daadwerkelijk bij de skill past.

  • Werkt met elk LLM

    AI-skills bestaan uit instructies in gewone Markdown, niet uit aanbiederspecifieke code. Daardoor werken ze met GPT, Claude, Gemini, Grok of een lokaal model.

  • Meegeleverde bestanden: 7

    Scripts, sjablonen en referentiemateriaal die het model tijdens het werken kan lezen. De bestanden kunnen alleen worden gelezen en worden nooit uitgevoerd.

  • Open source

    Gepubliceerd door OpenMinis op GitHub. Bekijk de bronbestanden voordat je de skill installeert.

Installatie

Installeer de AI-skill Tg Hub in TypingMind om deze met elk LLM te gebruiken, of voeg de skill toe aan een andere agent die SKILL.md kan lezen.

1

Installeren in TypingMind

TypingMind installeert een skill rechtstreeks vanuit de GitHub-map. De app leest SKILL.md, bundelt de bijbehorende bestanden en slaat het resultaat lokaal op.

  1. Open de app en ga naar Plug-ins → Skills.
  2. Kies "Installeren via GitHub".
  3. Plak de onderstaande URL van de skillmap en bevestig.
    https://github.com/OpenMinis/MinisSkills/tree/main/tg-hub
  4. Schakel de skill in voor elke chat waarin je de skill wilt kunnen gebruiken.
Plug-ins → Skills → Skill toevoegen → Via GitHub-URL. Plak vervolgens de map-URL en druk op Doorgaan.
2

Installeren in een andere agent

Elke agent die het Agent Skills-formaat kan lezen, kan deze skill gebruiken — kopieer de map naar de skillmap van die agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/OpenMinis/MinisSkills.git /tmp/MinisSkills
mkdir -p .claude/skills
cp -r /tmp/MinisSkills/tg-hub .claude/skills/tg-hub
Start Claude Code na het kopiëren opnieuw op, zodat de nieuwe skill wordt herkend.

Gebruik deze skill in TypingMind

Schakel Tg Hub in voor een chat naar keuze in TypingMind en het model doet de rest. De naam en beschrijving staan in de systeemprompt. Zodra een verzoek bij de skill past, laadt het model zelf de volledige instructies. Je hoeft de skill nooit handmatig aan te roepen. Pas als het model de skill daadwerkelijk gebruikt, kost dat tokens.

Het model laadt Tg Hub automatisch zodra een verzoek erbij past.

Werkt met elk AI-model

AI-skills zijn gewone Markdown-instructies in plaats van aanbiederspecifieke code. Daardoor is Tg Hub niet gebonden aan het model waarvoor de skill is geschreven. Installeer de skill één keer in TypingMind en gebruik deze met GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama of een lokaal model dat je zelf draait — allemaal met je eigen API-sleutels.

  • Alleen geladen wanneer nodig

    De systeemprompt bevat alleen de naam en beschrijving. De instructies worden bij het eerste bijpassende verzoek opgehaald, dus een ongebruikte skill kost niets.

  • Wissel van model tijdens een chat

    Omdat de skill uit instructies bestaat en niet uit code, blijft deze werken als je van model wisselt — het volgende model leest hetzelfde SKILL.md-bestand.

Skillinstructies

Dit is de inhoud van SKILL.md die het model laadt. Lees deze vóór de installatie — een skill bestaat uit instructies die je model zal volgen.

tg-hub

Based on: jackwener/tg-cli (Apache-2.0)

This skill simplifies the original repository as follows:

  • Removed the click / rich / python-dotenv / pyyaml dependencies
  • Kept only telethon as a third-party dependency
  • Removed the CLI layer and encapsulated all functionality as a synchronous Python API
  • Changed the default session/db path to /var/minis/workspace/tg-hub/
  • Changed configuration to read environment variables directly, with no .env file required

Architecture: Local-First

Telegram MTProto (telethon)
    ↓  sync / refresh (incremental)
Local SQLite  ~/.tg-hub/messages.db
    ↓  search / today / recent / filter (offline)
Structured data
  • Read operations (search/today/recent): query the local SQLite database, with no network access, and respond in milliseconds
  • Write operations (sync/refresh): connect to Telegram to fetch new messages and write them incrementally to SQLite
  • Session file: ~/.tg-hub/tg_hub.session

File Structure

/var/minis/skills/tg-hub/
├── SKILL.md
├── pyproject.toml          # telethon only
└── scripts/
    ├── __init__.py
    ├── config.py           # Configuration (environment variables / default paths)
    ├── db.py               # SQLite message storage
    ├── exceptions.py       # Structured exceptions
    └── client.py           # TGClient core class (all APIs)

First-Time Login (Must Be Done in Terminal)

tg-hub uses the MTProto protocol (not the Bot API), so you need to log in with your Telegram account.

Recommendation: Use your own TG_API_ID / TG_API_HASH whenever possible. I have synced the upstream tg-cli anti-risk-control implementation: it uses a Telegram Desktop 5.x fingerprint and prints a warning if you continue using the default api_id=2040. The public app ID is only a fallback. Using your own credentials is still recommended for long-term use.

1. Open Terminal
2. (Recommended) Set your own TG_API_ID / TG_API_HASH first
3. cd /var/minis/skills/tg-hub
4. uv run python -c "
   import sys; sys.path.insert(0,'.')
   from scripts.client import TGClient
   me = TGClient().login()
   print('Login successful:', me)
   "
5. Enter your phone number when prompted (in +86XXXXXXXXXX format)
6. Enter the verification code received in the Telegram app
7. After login succeeds, the session is saved automatically and future logins are not required

If you do not have your own credentials for now, you can log in with the built-in public credentials first. If you encounter login or fetch errors, switch to your own APP ID first.

Open Terminal to log in


Quick Start

Environment Setup

bash
cd /var/minis/skills/tg-hub
uv sync

Python Usage

python
import sys
sys.path.insert(0, "/var/minis/skills/tg-hub")
from scripts.client import TGClient

client = TGClient()

# View the current account
me = client.whoami()
print(me["name"], me["phone"])

# List all conversations (fetched from TG in real time)
chats = client.list_chats()
for c in chats[:10]:
    print(f"  [{c['type']}] {c['name']}  Unread: {c['unread']}")

# Incrementally sync a single group
n = client.sync("Group name or username", limit=1000)
print(f"Added {n} messages")

# Quickly refresh all groups (up to 500 new messages per group)
# Slight throttling is enabled by default; you can also limit this round to only the first 30 chats
result = client.refresh(delay=1.0, max_chats=30)
for name, count in result.items():
    if count > 0:
        print(f"  {name}: +{count}")

# Search by keyword
msgs = client.search("Python", hours=48)
for m in msgs:
    print(f"[{m['chat_name']}] {m['sender_name']}: {m['content'][:80]}")

# Multi-keyword filtering (OR logic)
msgs = client.filter("hiring,remote,part-time", hours=24)

# Today's messages
msgs = client.today()

# Messages from the last 12 hours
msgs = client.recent(hours=12, limit=200)

# Speaker rankings
top = client.top_senders(hours=24)
for t in top[:5]:
    print(f"  {t['sender_name']}: {t['msg_count']} messages")

# Timeline statistics
tl = client.timeline(granularity="hour", hours=48)

# Local database statistics
stats = client.stats()
print(f"{stats['total']} local messages across {len(stats['chats'])} groups")

API Quick Reference

Authentication

MethodDescription
login()Interactive login (first time, requires terminal)
whoami()Get current account information

Sync (Online)

MethodDescription
list_chats(chat_type=None)List all conversations (real time)
sync(chat, limit=5000)Sync a single group to local SQLite
sync_all(limit_per_chat=5000, delay=1.0, max_chats=None)Sync all groups (with throttling/count limit)
refresh(limit_per_chat=500, delay=1.0, max_chats=None)Quick incremental refresh (recommended for daily use)

Query (Local, Offline)

MethodDescription
search(keyword, *, chat, sender, hours, regex, limit)Keyword/regex search
filter(keywords, *, chat, hours)Multi-keyword OR filtering
today(chat=None)Today's messages
recent(hours=24, *, chat, sender, limit)Messages from the last N hours
top_senders(chat, hours, limit)Speaker rankings
timeline(chat, hours, granularity)Timeline statistics
stats()Database statistics
local_chats()List of locally synced groups
delete_chat(chat)Delete local messages for a group

Environment Variables

VariableDefault ValueDescription
TG_API_ID2040 (fallback only)Recommended: replace with your own API ID
TG_API_HASHBuilt in (fallback only)Recommended: replace with your own API Hash
TG_SESSION_NAMEtg_hubSession filename
TG_DATA_DIR~/.tg-hubData directory
TG_DB_PATH{TG_DATA_DIR}/messages.dbSQLite path
TG_DEVICE_MODELDesktopTelethon client device model
TG_SYSTEM_VERSIONmacOS 15.3Telethon client system version
TG_APP_VERSION5.12.1Telethon client version
TG_LANG_CODEenClient language code
TG_SYSTEM_LANG_CODEen-USSystem language code

Account Security Recommendations

  1. Use your own API credentials whenever possible: Go to https://my.telegram.org, create an application, and then set TG_API_ID / TG_API_HASH.
  2. Control sync frequency: Avoid repeatedly running refresh() at high frequency.
  3. Use delay and max_chats: For daily incremental refreshes, we recommend limiting the number of chats synced per round and keeping an interval between chats.
  4. Do not be too aggressive with the first full sync: tg-hub automatically applies a lower fetch limit for the first sync of each chat.
  5. Prefer read operations: Local queries such as search and statistics do not use the network, so they are much lower risk than frequent syncs.

Notes

  • The first login must be completed in an interactive terminal (a verification code is required).
  • Using your own TG_API_ID / TG_API_HASH is strongly recommended to avoid risk-control issues caused by abuse of the public APP ID.
  • tg-hub is aligned with the upstream tg-cli Telegram Desktop 5.x client fingerprint and retains environment variable overrides to reduce the risk of abnormal fingerprints.
  • If you are still using the default api_id=2040, a warning is printed during connection to remind you to switch to your own TG_API_ID / TG_API_HASH.
  • The session file is stored at /var/minis/workspace/tg-hub/tg_hub.session. Keep it safe.
  • The first run of sync_all may take a long time, depending on the number of groups and the amount of historical messages.
  • We recommend using refresh() for daily incremental updates and sync(chat, limit=10000) for the initial full sync.
  • Telegram applies rate limits to API requests. During large syncs, Telethon automatically handles flood waits.

Meegeleverde bestanden

Zolang de skill geladen is, leest het model deze bestanden als dat nodig is. Het model kan ze alleen lezen; ze worden nooit uitgevoerd.

Veelgestelde vragen

Wat doet de AI-skill Tg Hub?

A skill for reading and writing Telegram data with Python and UV. It depends only on Telethon and uses a local-first architecture: messages are synced to SQLite and then queried offline. On first use, you must log in from the terminal with a phone number verification code. After that, the session is persisted and you do not need to log in again. Supports syncing group and channel messages locally, keyword search, multi-keyword filtering, today's messages, recent messages, speaker rankings, timeline statistics, and more. This skill must be triggered whenever the user mentions "Telegram", "TG...

Waarom Tg Hub gebruiken in TypingMind?

Omdat je deze skill één keer installeert en met elk model kunt gebruiken. Tg Hub bestaat uit gewone Markdown in plaats van aanbiederspecifieke code. Dezelfde skill werkt dus met GPT-5, Claude, Gemini, Grok of een lokaal model. Ook als je midden in een chat van model wisselt, blijft de skill werken. TypingMind werkt met je eigen API-sleutels, dus je betaalt aanbieders rechtstreeks in plaats van een abonnement per gebruikersplek af te sluiten. Je skills en chats blijven in je eigen opslag.

Hoe installeer ik Tg Hub in TypingMind?

Open Plug-ins → Skills → Installeren vanaf GitHub in TypingMind en plak https://github.com/OpenMinis/MinisSkills/tree/main/tg-hub. TypingMind leest het bestand SKILL.md, bundelt de bijbehorende bestanden en installeert het geheel als een skill die je per chat kunt inschakelen.

Welke AI-modellen kunnen Tg Hub gebruiken?

Elk model dat je in TypingMind koppelt. AI-skills bestaan uit gewone Markdown-instructies in plaats van aanbiederspecifieke code. GPT, Claude, Gemini, Grok en lokale modellen kunnen deze skill dus allemaal laden wanneer een verzoek erbij past.

Hoeveel AI-modellen kan ik met Tg Hub gebruiken?

Zoveel als je wilt. Je kunt Tg Hub gebruiken met elk model dat skills ondersteunt, zoals GPT, Claude, Gemini, Grok, DeepSeek, Mistral of Llama. Allemaal in TypingMind met je eigen API-sleutels.

Is de AI-skill Tg Hub gratis?

Ja. Deze skill is door OpenMinis op GitHub gepubliceerd onder de licentie MIT. Je betaalt alleen je eigen AI-aanbieder voor de tokens die je gebruikt.

Wat zijn AI-skills?

Een AI-skill is een herbruikbare bundel instructies die een AI-model leert hoe het één specifieke taak moet uitvoeren. De skill volgt het open Agent Skills-formaat: het bestand SKILL.md bevat de naam en beschrijving van de skill. Daarnaast kan de skill scripts, sjablonen of referentiebestanden bevatten die het model nodig heeft. Het model leest de instructies alleen als je verzoek bij de skill past. Een geïnstalleerde skill kost dus niets zolang deze niet wordt gebruikt.

Waarin verschillen AI-skills van plug-ins of MCP-servers?

Een plug-in of MCP-server geeft een model nieuwe tools om aan te roepen: code die ergens wordt uitgevoerd en een resultaat teruggeeft. Een AI-skill geeft het model juist kennis en een werkwijze: hoe het een taak moet aanpakken, welke stappen het moet volgen en hoe goede uitvoer eruitziet. Skills bestaan uit gewone Markdown en hebben dus geen server, API-sleutel of runtime nodig. Ze werken met elk model.

Bekijk alles

Maak nu je eigen AI-werkruimte

Schrijf je in voor onze nieuwsbrief en blijf op de hoogte van nieuwe functies en toekomstige weggeefacties 👇