pytmbot

📦 pyTMBot Installation Script

This script provides an easy way to install, manage, and uninstall the pyTMBot either inside a Docker container or locally on your system. It also includes support for setting up a Python virtual environment for local installations.

✅ Requirements

📋 Pre-Installation Information

Before running the script, gather the following information:

🔑 Essential Information

  1. Telegram Bot Token: Obtain from BotFather when creating your bot
  2. Allowed Telegram User IDs: Valid Telegram user IDs (can be adjusted later via logs)
  3. Global Chat ID: Send a message to your bot, then visit:
    https://api.telegram.org/bot<YourBotToken>/getUpdates
    

    Look for the chat_id in the JSON response.

🐳 Docker Configuration

  1. Docker Socket Path: Default is unix:///var/run/docker.sock

🌐 Webhook Configuration (if applicable)

  1. Domain URL or Public IP: For webhook mode
  2. SSL Certificate Path: Path to SSL certificate file
  3. SSL Private Key Path: Path to SSL private key file

📊 Monitor Plugin (InfluxDB)

  1. InfluxDB URL: Address of your InfluxDB server
  2. Organization Name: Your InfluxDB organization name
  3. Bucket Name: The name of your InfluxDB bucket
  4. InfluxDB Token: Your authorization token for InfluxDB

⚙️ Usage

🚀 Running the Script

To get the latest version of the script and run it:

sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/orenlab/pytmbot/refs/heads/master/tools/install.sh)"

🛠️ Installation Options

When running the script, you will be prompted to choose one of the following options:

1. Docker Installation

Runs pyTMBot inside a Docker container for easy management and isolation.

2. Local Installation

Installs pyTMBot directly on your system.

3. Update Local Installation

Updates pyTMBot to the latest version.

4. Uninstall pyTMBot

Completely removes the bot and its files from your system.

🔧 Configuration Details

📝 Systemd Service

For local installations, the script creates a systemd service with:

🐳 Docker Compose

For Docker installations, creates a docker-compose.yml with:

📜 Logs and Monitoring

📊 Log Files

🔍 Service Management

For local installations:

# Check service status
sudo systemctl status pytmbot

# Start/stop/restart service
sudo systemctl start pytmbot
sudo systemctl stop pytmbot
sudo systemctl restart pytmbot

# View logs
sudo journalctl -u pytmbot -f

For Docker installations:

# Check container status
docker ps -f name=pytmbot

# View logs
docker logs pytmbot -f

# Restart container
docker restart pytmbot

❗ Troubleshooting

🔧 Common Issues

🛠️ Manual Fixes

🚫 Uninstallation

🏠 Local Uninstallation

Run the script and choose option 4:

sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/orenlab/pytmbot/refs/heads/master/tools/install.sh)"

🐳 Docker Uninstallation

Remove the Docker container and images:

# Stop and remove container
sudo docker compose down

# Remove images (optional)
sudo docker rmi orenlab/pytmbot

# Clean up files
sudo rm -rf /opt/pytmbot

🔄 Updates

📦 Local Updates

🐳 Docker Updates

cd /opt/pytmbot
sudo docker compose pull
sudo docker compose up -d