The Movie Cast Telegram Bot allows users to search and watch movies directly within Telegram. It provides a seamless experience by listing videos, supporting search functionality, and enabling video streaming through the Telegram platform. The bot also supports inline keyboard navigation for browsing movies and interacting with users.
- Movie Search: Search for movies based on keywords.
- Video Streaming: Users can watch movies by selecting them from the inline buttons.
- Pagination: Navigate through the list of movies with next/previous buttons.
- MongoDB Integration: The bot stores video data (caption, size, file ID) in a MongoDB database.
- Automatic Message Deletion: Messages are deleted after 2 minutes to keep the chat clean.
- Video Upload: Admins can upload videos, which are checked for duplicates before being added to the database.
Before running the bot, ensure you have the following tools and accounts:
- Node.js (version 14.x or higher)
- MongoDB account with a URI for connecting to your database
- Telegram Bot Token - Get yours from @BotFather
- npm or yarn for package management
Follow these steps to set up the bot locally:
-
Clone the repository:
git clone https://github.com/deepak748030/TelegramFileStoreBot.git cd TelegramFileStoreBot -
Install dependencies:
npm install # or yarn install -
Set up environment variables:
- Create a
.envfile in the root of the project. - Add the following variables:
TELEGRAM_BOT_TOKEN=your-telegram-bot-token MONGODB_URI=your-mongodb-connection-uri
- Create a
-
Run the bot:
node index.js
Once the bot is up and running, you can interact with it by sending commands or searching for movies.
/start: Greets the user and provides a welcome message with a navigation menu./moviecounts: Returns the total number of movies in the database.- Search for Movies: Type a movie name to search for matching videos.
- Inline Buttons: Navigate through video search results with "Next" and "Previous" buttons.
- Watch Movies: Select a movie from the results to watch it.
- Type the movie name you want to search for.
- The bot will respond with a list of movies matching your search.
- Use the "Next" or "Previous" buttons to browse through multiple pages of results.
- Click on a movie to watch it.
- Admins (identified by specific usernames) can upload videos to the bot. The bot ensures that no duplicate videos are stored.
- Videos will be stored with a cleaned-up caption and their metadata (file ID, caption, and size).
The bot stores video information in a MongoDB database with the following schema:
const videoSchema = new mongoose.Schema({
fileId: { type: String, required: true },
caption: { type: String, required: true },
size: { type: Number, required: true }
});- Start Command: When a user starts the bot, they are greeted with a welcome message and given the option to view movies or visit the website.
- Search Functionality: Users can search for movies by name, and the bot will return matching results from the database. The results are displayed with the option to select and watch the video.
- Pagination: The results are displayed in pages, with a maximum of 8 movies per page. Users can navigate through the pages using inline buttons.
- Video Upload: Admins can upload videos to the bot. The bot checks for duplicates and saves the video data to the database.
Contributions are welcome! To contribute to this project, follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature-branch) - Make your changes
- Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature-branch) - Create a pull request
For any questions, you can reach out to:
- Telegram: @yourusername
- Email: deepakkushwah748930@gmail.com