Skip to content

ruopsdev/tibo-telegram-bot

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

162 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Tibo.app - Theory of inventive based offers @meteoritt

tibo-telegram-bot

visitors

Telegram bot @albert_ai_bot (https://t.me/albert_ai_bot)

Open Source Code (БПО): https://github.com/ruopsdev/tibo-telegram-bot

Quick Start

New to this project? Check out the Quick Start Guide (QUICKSTART.md) to get running in 5 minutes!

πŸ‡¨πŸ‡³ Chinese Language Support: See CHINESE_SUPPORT.md for δΈ­ζ–‡ε‘½δ»€ε’ŒεŠŸθƒ½

Table of Contents

Features

  • Multi-language Support: Chinese (δΈ­ζ–‡), English
  • Weather information via OpenWeatherMap API
  • Random meme generation
  • Sentiment analysis with NLTK
  • Bar notification system
  • Random number generator
  • Language Detection: Auto-detect text language (100+ languages)
  • Translation: Translate between languages using Google Translate
  • Webhook and polling modes
  • Flask web server with health check endpoints

Prerequisites

  • Python 3.13 or higher (3.13-3.14)
  • Telegram Bot Token (get from @BotFather)
  • pip or Poetry for dependency management
  • (Optional) Render.com account for deployment

Installation

Option 1: Using pip

# Clone the repository
git clone https://github.com/ruopsdev/tibo-telegram-bot.git
cd tibo-telegram-bot

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Option 2: Using Poetry

# Clone the repository
git clone https://github.com/ruopsdev/tibo-telegram-bot.git
cd tibo-telegram-bot

# Install dependencies with Poetry
poetry install
poetry shell

Configuration

Required Environment Variables

Create a .env file in the project root or set these environment variables:

# Required - Get this from @BotFather on Telegram
export TIBO_TELEGRAM_BOT_TOKEN="your_telegram_bot_token_here"

# Optional - For Render.com deployment only
export RENDER_SERVICE_ID="your_render_service_id"
export RENDER_API_KEY="your_render_api_key"

# Optional - For TeleAds middleware (if using)
export TELEADS_API_KEY="your_teleads_api_key"

# Optional - Server port (default: 8443)
export PORT=8443

Getting a Telegram Bot Token

  1. Open Telegram and search for @BotFather
  2. Send /newbot command
  3. Follow the instructions to create your bot
  4. Copy the token provided by BotFather
  5. Set it as TIBO_TELEGRAM_BOT_TOKEN environment variable

Running the Bot

Local Development (Polling Mode)

Polling mode is recommended for local development and testing:

# Set the IDE environment variable to enable polling mode
export IDE=1
export TIBO_TELEGRAM_BOT_TOKEN="your_token_here"

# Run the bot
python telegram.py

The bot will start in polling mode and listen for messages directly from Telegram.

Production (Webhook Mode)

Webhook mode is used for production deployment on platforms like Render.com:

# Set environment variables
export TIBO_TELEGRAM_BOT_TOKEN="your_token_here"
export PORT=8443

# Run with Flask development server
python telegram.py

# OR run with Gunicorn (recommended for production)
gunicorn telegram:app --bind 0.0.0.0:8443

Using Flask-Script (Alternative)

python manage.py runserver

Available Commands

πŸ“– For complete command reference with examples, see COMMANDS.md

Once the bot is running, you can use these commands in Telegram:

Basic Commands

  • /start - Initialize the bot, register user, and show help
  • /check - Same as /start - register and show welcome
  • /help - Display list of available commands

Weather Information

  • /weather [city] - Get current weather (default city: Perm)
    • Example: /weather Moscow
  • /ΠΏΠΎΠ³ΠΎΠ΄Π° [Π³ΠΎΡ€ΠΎΠ΄] - Weather command in Russian

Entertainment & Fun

  • /mem - Get a random meme from imgflip
  • /meme - Get a random meme (same as /mem)
  • /getimage or /image - Get a random image from imgflip
  • /8, /eight, /восСмь, /Ρ€Π°Π½Π΄ΠΎΠΌ - Generate random number between 1-100
  • /3.14, /3, /three, /Ρ‚Ρ€ΠΈ, /pi, /ΠΏΠΈ - Display the value of Pi (3.141592...)

Social Features

  • /bar - Notify bar members with:
    • Mention all configured bar members
    • Create a poll "DRINK BEER SAVE WATER"
    • Send random beer photo

Sentiment Analysis (AI-powered)

All these commands trigger sentiment analysis - the bot will ask you to send text, then analyze its emotional tone and respond with an emoji and sentiment scores:

Main command:

  • /emotion - Analyze sentiment of your text

Alternative commands (all do the same): /themes, /idea, /more, /mind, /context, /echo, /bet, /produce, /think, /note, /tibo, /agenda, /graph, /map, /push, /fact, /top, /stat, /game, /quiz, /test, /chat, /bio, /date, /rpg, /lol, /notify, /quote, /advice, /contact, /donate, /share, /random, /schedule, /settings, /new

Sentiment responses:

  • 😁 Very positive (>0.75)
  • πŸ˜€ Positive (>0.5)
  • 😊 Slightly positive (>0.25)
  • 🀨 Neutral positive (>0)
  • πŸ˜₯ Neutral negative (>-0.25)
  • 😈 Negative (>-0.5)
  • πŸ‘Ή Very negative (>-0.75)
  • 🀬 Extremely negative (>-1)

Other Commands

  • /promo - Display advertisement (requires TeleAds configuration)
  • /help_auth - Show inline bot capabilities with contact button

Deployment

Deploy to Render.com

  1. Create account on Render.com

  2. Create a new Web Service

  3. Connect your GitHub repository

  4. Configure the service:

    • Build Command: pip install -r requirements.txt
    • Start Command: gunicorn telegram:app
    • Environment: Python 3.13
  5. Add Environment Variables:

    • TIBO_TELEGRAM_BOT_TOKEN
    • RENDER_SERVICE_ID (found in Render dashboard)
    • RENDER_API_KEY (create in Render account settings)
  6. Deploy the service

  7. After deployment, visit https://your-service-url.onrender.com/ to set the webhook

Webhook Endpoints

Once deployed, these endpoints are available:

  • GET / - Set webhook to current URL
  • POST /<TIBO_TELEGRAM_BOT_TOKEN> - Telegram webhook endpoint
  • GET /health - Health check (returns "OK")
  • GET /debug - Debug information
  • GET|POST /restart - Restart Render service
  • GET /status - Check Render service status

Troubleshooting

Bot doesn't respond

  1. Check if TIBO_TELEGRAM_BOT_TOKEN is set correctly
  2. Verify webhook is set (visit /debug endpoint)
  3. Check logs for error messages
  4. Ensure all required dependencies are installed

ImportError or ModuleNotFoundError

# Reinstall all dependencies
pip install -r requirements.txt --upgrade

NLTK Data Missing

The bot will automatically download NLTK data on first run. If you encounter errors:

python -c "import nltk; nltk.download('vader_lexicon')"

Webhook Issues

If webhook isn't working:

# Remove existing webhook
curl https://api.telegram.org/bot<YOUR_TOKEN>/deleteWebhook

# Set new webhook
curl https://api.telegram.org/bot<YOUR_TOKEN>/setWebhook?url=https://your-domain.com/<YOUR_TOKEN>

Port Already in Use

# Change the port
export PORT=8000
python telegram.py

Project Structure

tibo-telegram-bot/
β”œβ”€β”€ telegram.py          # Main bot application
β”œβ”€β”€ manage.py            # Flask-Script management
β”œβ”€β”€ tiz.py              # NLTK sentiment analysis examples
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ pyproject.toml      # Poetry configuration
β”œβ”€β”€ Procfile            # Render/Heroku deployment config
β”œβ”€β”€ README.md           # This file
└── .gitignore          # Git ignore rules

Security Notes

  • Never commit your .env file or expose TIBO_TELEGRAM_BOT_TOKEN
  • Keep your dependencies up to date
  • Review the security audit in project issues before deploying

Git-Flow мСтодология ΠΌΠ΅Ρ‚Ρ€ΠΎΠ»ΠΎΠ³ΠΈΠΈ запуска Ρ„ΠΈΡ‡Π΅Π²Π΅Ρ‚ΠΎΠΊ Π² кластСрС Kubernetes: https://medium.com/ruopsdev/git-flow-presentation-b80643390888?source=collection_home_page----925f883655a3-----0-----------------------------------

Для Windows (win):

  • Ctrl+C – ΠΊΠΎΠΏΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ (copy)

  • Win+V – ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ Π±ΡƒΡ„Π΅Ρ€Π° ΠΎΠ±ΠΌΠ΅Π½Π°

  • Win+L – Π±Π»ΠΎΠΊΠΈΡ€ΠΎΠ²ΠΊΠ° экрана (lock)

  • Ctrl+Shift+Esc – диспСтчСр Π·Π°Π΄Π°Ρ‡ (process explorer)

  • PrtScr – снимок экрана Π² Π±ΡƒΡ„Π΅Ρ€ ΠΎΠ±ΠΌΠ΅Π½Π° (Print Screen)

  • Alt+Shift+S – снимок экрана Π½ΠΎΠΆΠ½ΠΈΡ†Π°ΠΌΠΈ (save screen)

  • Alt+PrtScr – снимок экрана ΠΈΠ»ΠΈ ΠΎΠΊΠ½Π° Π² OneDrive

  • Alt+Tab – ΠΏΠ΅Ρ€Π΅ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ ΠΎΠΊΠΎΠ½ (Tabula)

  • Win+Tab – ΠΏΠ΅Ρ€Π΅ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΠ΅ Ρ€Π°Π±ΠΎΡ‡ΠΈΡ… столов

  • Win+Arrow (стрСлка) – Ρ‚Π°ΠΉΠ»ΠΎΠ²Ρ‹ΠΉ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ ΠΎΠΊΠΎΠ½, прилСпляСт ΠΎΠΊΠ½ΠΎ Π² Π³Ρ€Π°Π½ΠΈΡ†Π°ΠΌ экрана

  • Win+R – ΠΎΠΊΠ½ΠΎ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ (Run)

ScrLk клавиша рядом с PrtScr Π²ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ ΠΈ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π°Π΅Ρ‚ Π½Π°Π²ΠΈΠ³Π°Ρ†ΠΈΡŽ Π² Microsoft Excel ΠΏΠΎ ячСйкам Π² Ρ‚Π°Π±Π»ΠΈΡ†Π΅ стрСлками, ΠΌΠΎΠΆΠ½ΠΎ Π»ΠΈΡΡ‚Π°Ρ‚ΡŒ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚ ΠΈΠ»ΠΈ ΠΏΠ΅Ρ€Π΅Ρ…ΠΎΠ΄ΠΈΡ‚ΡŒ ΠΏΠΎ ячСйкам, Π² зависимости ΠΎΡ‚ Ρ‚ΠΎΠ³ΠΎ Π±Ρ‹Π» Π²ΠΊΠ»ΡŽΡ‡Π΅Π½ ScrLk ΠΈΠ»ΠΈ Π½Π΅Ρ‚. Scroll Lock.

Для Linux:

Π’ Linux ΠΏΠΎΠ»Π΅Π·Π½Π° ΡƒΡ‚ΠΈΠ»ΠΈΡ‚Π° screen, tmux ΠΈΠ»ΠΈ byobu для выполнСния Π΄ΠΎΠ»Π³ΠΈΡ… запросов, ΠΊΠΎΠΌΠ°Π½Π΄ ΠΈΠ»ΠΈ бэкапов. Установка sudo apt install screen -y # (C) CSRedRat Β© 2026 β€” символ ΠΊΠΎΠΏΠΈΡ€Π°ΠΉΡ‚Π°, Π·Π½Π°ΠΊ авторского ΠΏΡ€Π°Π²Π°, прСдставляСт собой Π»Π°Ρ‚ΠΈΠ½ΡΠΊΡƒΡŽ Π±ΡƒΠΊΠ²Ρƒ C (пСрвая Π±ΡƒΠΊΠ²Π° слова Β«copyrightΒ») Π² окруТности. Site: https://yandex.ru/search/?text=copyright+symbol&lr=2&clid=1836588, may be later && may be before: https://web.archive.org/web/20200105175935/http://metin2wiki.ru/wiki/FAQ_Linux#expand

  • Ctrl+C – ΠΎΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹

  • Ctrl+X – ΠΎΡΡ‚Π°Π½ΠΎΠ²ΠΈΡ‚ΡŒ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹

  • Ctrl+Z – ΡƒΠ±Ρ€Π°Ρ‚ΡŒ ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡƒ Π² Ρ„ΠΎΠ½ΠΎΠ²Ρ‹ΠΉ Ρ€Π΅ΠΆΠΌ

  • Ctrl+R – рСкурсивный поиск ΠΏΠΎ истории ΠΊΠΎΠΌΠ°Π½Π΄

  • Ctrl+F – forward, ΠΎΠ±Ρ€Π°Ρ‚Π½Ρ‹ΠΉ поиск ΠΏΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π°ΠΌ

Команда htop ΠΏΠΎΠΊΠ°Π·Ρ‹Π²Π°Π΅Ρ‚ Π½Π°Π³Ρ€ΡƒΠ·ΠΊΡƒ ΠΏΠΎ ΠΊΠΎΠΌΠΏΡŒΡŽΡ‚Π΅Ρ€Ρƒ, установка sudo apt install htop -y

Команда sudo locate <тСкст> ΠΈΡ‰Π΅Ρ‚ ΠΏΠΎ всСму сСрвСру, ΠΏΠ΅Ρ€Π΅Π΄ этим Π½Π°Π΄ΠΎ Π²Ρ‹ΠΏΠΎΠ»Π½ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠ°Π½Π΄Ρƒ sudo apt install mlocate -y && sudo updatedb

Мой Ρ‚Π΅Π»Π΅Π³Ρ€Π°ΠΌ: https://t.me/ChudakovSergey ΠΈΠ»ΠΈ @ChudakovSergey ΠΈΠ»ΠΈ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΠΉΡ‚ΠΈ ΠΏΠΎ Π½ΠΎΠΌΠ΅Ρ€Ρƒ Ρ‚Π΅Π»Π΅Ρ„ΠΎΠ½Π° +79638610401

Личная ΠΏΠΎΡ‡Ρ‚Π°: csredrat@gmail.com

Sign (Подпись): стСрхов δ½ ζœƒθͺͺδΈ­ζ–‡ε—ŽοΌŸ- Π½ΠΈ Ρ…ΡƒΡƒ ΡˆΡƒΠ° шонгвин ΠΌΠ° https://burui.t.me (sj588 εΈƒη‘ž)

ALERT: Π˜Ρ‰Ρƒ ΠΊΠΎΠ»Π»Π΅Π³ для стартапа ΠΏΠΎ написанию ΠΊΠΎΠ΄Π° ΠΏΠ»Π°Ρ‚Ρ„ΠΎΡ€ΠΌΡ‹ Joker (codename RED.L), основанной Π½Π° Topalias: https://github.com/ruopsdev/topalias

Π― Π°Π²Ρ‚ΠΎΡ€ ΠΊΠ½ΠΈΠ³ΠΈ ΠΏΡ€ΠΎ Linux: https://github.com/meteoritt/gentleman (Ссли Π½Π°Π΄ΠΎ Π½Π°ΡΡ‚Ρ€ΠΎΠΈΡ‚ΡŒ домашний ΠΊΠΎΠΌΠΏΡŒΡŽΡ‚Π΅Ρ€ Π½Π° Windows с WSL – Windows Subsystem Linux ΠΏΠΎΠ΄ Π²Ρ‹ΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΠΏΠ΅Ρ‚-ΠΏΡ€ΠΎΠ΄ΠΆΠ΅ΠΊΡ‚ΠΎΠ², Ρ…ΠΎΠ±Π±ΠΈ, ΠΏΡ€ΠΎΠ΅ΠΊΡ‚ΠΎΠ²)

StratUp

curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
python3 -m ensurepip --upgrade
python3 -m pip --upgrade pip
pip3 install poetry
python3 -m pip install poetry
python3 -m poetry install

License

NoBSD: https://github.com/ruopsdev/tibo-telegram-bot/wiki/NoBSD-License

NoBSD License: https://github.com/ruopsdev/tibo-telegram-bot/wiki/NoBSD-License