scrape_group
Extract and convert Telegram group posts into markdown format using an authenticated session. Specify the group URL and optionally limit the number of posts to retrieve.
Instructions
Scrape a Telegram group and return posts in markdown format. Uses authenticated session if logged in.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| max_posts | No | Maximum number of posts to scrape (default: 100) | |
| url | Yes | The Telegram group URL (e.g., https://t.me/groupname) |
Implementation Reference
- src/server.ts:417-420 (handler)The handler function for the 'scrape_group' tool. It delegates the scraping logic to the shared handleScrapeChannel method.private async handleScrapeGroup(args: any): Promise<any> { // Groups are handled the same way as channels return this.handleScrapeChannel(args); }
- src/server.ts:166-184 (registration)Registration of the 'scrape_group' tool in the getTools() method, including name, description, and input schema definition.{ name: 'scrape_group', description: 'Scrape a Telegram group and return posts in markdown format. Uses authenticated session if logged in.', inputSchema: { type: 'object', properties: { url: { type: 'string', description: 'The Telegram group URL (e.g., https://t.me/groupname)' }, max_posts: { type: 'number', description: 'Maximum number of posts to scrape (default: 100)', default: 100 } }, required: ['url'] } },
- src/server.ts:385-415 (helper)Shared helper function handleScrapeChannel that contains the core logic for scraping Telegram channels/groups, called by the scrape_group handler.private async handleScrapeChannel(args: any): Promise<any> { // Check if authenticated and use authenticated scraper by default const isAuthenticated = await this.auth.isAuthenticated(); const scraperToUse = isAuthenticated ? this.authScraper : this.scraper; if (isAuthenticated) { logger.info('Using authenticated scraper (logged in)'); } else { logger.info('Using unauthenticated scraper (not logged in)'); } const options: ScrapeOptions = { url: args.url, maxPosts: args.max_posts === undefined ? 0 : args.max_posts, // 0 means no limit includeReactions: args.include_reactions !== false }; const result = await scraperToUse.scrape(options); const markdown = this.formatter.format(result); return { content: [ { type: 'text', text: isAuthenticated ? `${markdown}\n\n✅ *Scraped using authenticated session*` : markdown } ] }; }
- src/server.ts:71-72 (registration)Dispatch case in the main tool handler switch statement that routes 'scrape_group' calls to its handler.case 'scrape_group': return await this.handleScrapeGroup(args);