telegram bot usage - panuozzo77/StreamingCommunity GitHub Wiki

Telegram Bot Usage

This document explains how to set up and use the Telegram bot integration with StreamingCommunity, allowing you to control and monitor downloads remotely from your Telegram app.

Overview

The StreamingCommunity Telegram bot provides a convenient way to search for and download content without needing direct access to the terminal. Each download runs within a screen session, enabling multiple downloads to run simultaneously.

Setup

Prerequisites

Before using the Telegram bot, ensure you have:

  1. A Telegram account
  2. The StreamingCommunity application installed
  3. Screen utility installed on your system (for Linux/macOS)

Configuration

1. Create a Telegram Bot

First, you need to create a Telegram bot:

  1. Open Telegram and search for "BotFather"
  2. Start a chat with BotFather and send the command /newbot
  3. Follow the prompts to create your bot
  4. Once created, BotFather will provide a token (keep this secure)

2. Get Your Telegram User ID

To restrict bot access to only yourself:

  1. Search for "userinfobot" on Telegram
  2. Start a chat with this bot
  3. It will reply with your user ID

3. Create an Environment File

Create a .env file in the StreamingCommunity directory with the following content:

TOKEN_TELEGRAM=YourTelegramBotToken
AUTHORIZED_USER_ID=YourTelegramUserID
DEBUG=False

Replace YourTelegramBotToken with the token provided by BotFather and YourTelegramUserID with your Telegram user ID.

4. Enable Telegram Bot in Configuration

Edit your config.json file to enable the Telegram bot:

{
    "DEFAULT": {
        "telegram_bot": true
    }
}

Starting the Bot

On Linux/macOS

Navigate to the StreamingCommunity/TelegramHelp directory and run:

python3 telegram_bot.py

For persistent operation, it's recommended to run the bot inside a screen session:

screen -S streamingbot
python3 telegram_bot.py

Press Ctrl + A, followed by D to detach from the screen session without stopping the bot.

On Windows

Navigate to the StreamingCommunity\TelegramHelp directory and run:

python telegram_bot.py

For persistent operation on Windows, you might want to create a service or use a tool like NSSM (Non-Sucking Service Manager).

Using the Bot

Available Commands

The bot supports the following commands:

  • /start – Initiates a new search for content to download
  • /list – Displays the status of active downloads
  • /stop <ID> – Stops a download with the specified ID
  • /screen <ID> – Views the real-time output of a download with the specified ID

Workflow

Starting a New Download

  1. Send /start to the bot
  2. The bot will present a list of available streaming sites
  3. Select a site by sending its corresponding number
  4. Enter your search terms
  5. The bot will display search results
  6. Select content by sending its corresponding number
  7. Follow the prompts to select season, episode, and download options
  8. The download will start in a separate screen session

Monitoring Downloads

  1. Send /list to the bot
  2. The bot will display all active downloads with their IDs
  3. To view the output of a specific download, send /screen <ID>
  4. To stop a download, send /stop <ID>

Example Interaction

You: /start
Bot: Categorie: 
     anime | film_serie | film | serie | other

     Inserisci il sito:
     0: Altadefinizione
     1: Animeunity
     2: Animeworld
     3: Streamingcommunity

You: 3
Bot: Inserisci i termini di ricerca:

You: stranger things
Bot: Risultati per "stranger things":
     1. Stranger Things (2016)
     2. Stranger Things: Stagione 4 (2022)

You: 1
Bot: Seleziona la stagione:
     1. Stagione 1
     2. Stagione 2
     3. Stagione 3
     4. Stagione 4

You: 1
Bot: Seleziona gli episodi (1-8) o "all" per tutti:

You: all
Bot: Download avviato con ID: 12345
     Usa /screen 12345 per vedere l'output
     Usa /stop 12345 per interrompere il download

You: /list
Bot: Download attivi:
     ID: 12345 - Stranger Things S01 - In corso

You: /screen 12345
Bot: [Output del download in tempo reale]

You: /stop 12345
Bot: Download 12345 interrotto

Advanced Usage

Running Multiple Downloads

The bot allows running multiple downloads simultaneously, each in its own screen session. Simply start a new download with /start while others are running.

Checking Screen Sessions

On Linux/macOS, you can manually check screen sessions:

screen -ls

To reattach to a screen session:

screen -r session_id

Handling Interrupted Downloads

If a download is interrupted, incomplete files may remain in the folder specified in config.json. These files must be deleted manually to avoid storage or management issues.

Troubleshooting

Common Issues

  1. Bot Not Responding

    • Verify the bot is running
    • Check the TOKEN_TELEGRAM value in your .env file
    • Ensure you're using the correct bot in Telegram
  2. Unauthorized Access

    • Verify your AUTHORIZED_USER_ID in the .env file
    • Only the authorized user can interact with the bot
  3. Download Failures

    • Check the screen output with /screen <ID>
    • Verify your internet connection
    • Check if the source site is accessible

Debugging

If you encounter issues, you can enable debug mode by setting DEBUG=True in your .env file. This will provide more detailed logs.

Related Documentation

⚠️ **GitHub.com Fallback** ⚠️