How rainrisa/telegraf-file-sharing works
Project Type and Purpose
• The project is a Telegram bot built with Telegraf.js. Its purpose is to allow file sharing with additional features such as broadcast messaging, admin controls, and support for both in-memory and MongoDB storage.
File Structure
• Top-Level Files/Folders: Notice files like Dockerfile, package.json, tsconfig.json, and .dockerignore which indicate deployment and build configurations.
• The main application code lives in the “src” directory.
• Key sub-directories in “src”:
• databases: Contains two database modules (mongoDB.ts and inMemory.ts) that illustrate the support for two storage options.
• extra: Common helper utilities (filterAsync, sleep, etc.) which support asynchronous operations and data transformations.
• handlers/commands: Contains command handler files (broadcast, share, start, uptime, users), which interact with Telegram commands.
• scenes: Implements scene-based interactions for share processes, managing different stages (callback, enter, message) of a conversation.
• services: Implements core services like authentication (auth.ts), broadcast (broadcast.ts), database (database.ts), environment variable management (env.ts), global state management (globalState.ts), and a Telegram service (telegram.ts).
• The entry point is “src/main.ts” which likely initiates the Telegraf bot and wires together these components.
• The file structure reinforces a modular and separated design; different folders represent different concerns (command handling, scene management, database abstraction, and utility services).
README
• The README clarifies that the bot is intended to share files and broadcast messages, using Telegraf.js for Telegram API interactions.
• It also states the support for environmental configuration (variables for bot token, admin IDs, DB URL, etc.) and provides usage instructions, which indicate that the bot should be easily deployable on platforms like Replit or Cyclic.
• There is a reference to an earlier project (File Sharing Bot with Pyrogram) but emphasizes that this is adapted for Telegraf, meaning that the core bot engine differs while the functionality is similar.