Skip to content

Dockerized Python Telegram bot that sends scheduled daily motivational quotes to your chat and responds to on-demand quote requests.

License

Notifications You must be signed in to change notification settings

TriTacLe/DailyQuoteBot

Repository files navigation

DailyQuoteBot

A Telegram bot and scheduler that sends you daily quotes per x times and sends you a quote if you send any messages to the bot

Features

  • Fetches and sends a random quote daily at a scheduled time.
  • Supports multiple quote sources: Bible API, Kanye REST API, motivational quotes.
  • Users can request a quote on-demand via the Telegram command /w or any messages to the bot.
  • Deployable via Docker or runnable locally.

Prerequisites

  • Python 3.10+ installed locally.
  • pip for installing Python dependencies.
  • A Telegram account to create a bot.
  • Docker for containerized deployment.

Setup

1. Clone the Repository

git clone https://github.com/TriTacLe/DailyQuoteBot.git
cd DailyQuoteBot

2. Create and Configure the Telegram Bot

  1. Open Telegram and start a chat with BotFather.
  2. Send /newbot and follow the prompts to set a name and username for your bot.
  3. BotFather will provide you with a bot token. Copy this token.

3. Get Your Telegram Chat ID

In order to send messages to you, the bot needs your Chat ID:

  1. Open a chat with your newly created bot and send any message (e.g., Hello).
  2. Ensure the .env file has your TELEGRAM_BOT_TOKEN set (see next step).
  3. Run the helper script:
python get_telegram_chat_id.py

This script will print your Chat ID. Copy value.

4. Configure Environment Variables

  1. Copy the example file:
cp .env.example .env
  1. Open .env in IDE and fill in the required fields:
# Time the bot sends a daily quote (24-hour format HH:MM)
TIME=07:00

# Quote Sources Endpoints (defaults work out of the box)
BASE_URL_BIBLE=https://bible-api.com/
BASE_URL_KANYE=https://api.kanye.rest
BASE_URL_MOTIVATIONAL=https://stoic.tekloon.net/stoic-quote

# Enable/Disable Quote Sources (true/false)
ENABLE_BIBLE=true
ENABLE_KANYE=false
ENABLE_MOTIVATIONAL=true

# Telegram Credentials
TELEGRAM_BOT_TOKEN=<your_bot_token>
TELEGRAM_BOT_USERNAME=@YourBotUsername
TELEGRAM_CHAT_ID=<your_chat_id>

# docker
CONTINENT=Continent
CITY=City
  1. Save .env

5. Install Dependencies

pip install --no-cache-dir -r requirements.txt

6. Docker

Running the Application Locally

From the project root, run:

python src/main.py

This will:

  1. Start the scheduler, which sends a quote daily at the time specified by TIME.
  2. Launch the Telegram bot, which listens for messages. You can request a quote manually by sending /w in the bot chat.

Docker Setup manually

You can containerize the application for easier deployment.

  1. Build the Docker Image
docker build -t dailyquotebot:latest .
  1. Run the container manually
docker run -d --name dailyquotebot-container dailyquotebot:latest
  1. Stop and remove image and container
docker rmi dailyquotebot:latest
docker rm -f dailyquotebot-container

Docker compose

  1. Start service
docker compose down
docker compose up --build
docker compose up -d
#or
docker-compose up -d --build
  1. Stop service
docker compose down
  1. Logs and troubleshooting

docker images
docker ps -a
docker compose logs -f dailyquotebot
  1. Other commands
docker compose stop
docker compose start
pip freeze -> requirements.txt

About

Dockerized Python Telegram bot that sends scheduled daily motivational quotes to your chat and responds to on-demand quote requests.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •