scrape_group
Extract posts from Telegram groups and convert them to markdown format for analysis or archiving. Use authenticated sessions to access content with configurable post limits.
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 |
|---|---|---|---|
| url | Yes | The Telegram group URL (e.g., https://t.me/groupname) | |
| max_posts | No | Maximum number of posts to scrape (default: 100) |
Implementation Reference
- src/server.ts:417-420 (handler)The handler function that executes the 'scrape_group' tool. It delegates to handleScrapeChannel since groups are handled identically to channels.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.{ 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)Core helper function called by scrape_group handler, performing the actual scraping logic using TelegramScraper instance and formatting the result as markdown.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 } ] }; }