/Fale-Hafez

Hafez Bot is a Telegram bot that delivers random poems from the Persian poet Hafez. Users can interact with the bot via simple commands to receive a poem and its meaning.

Primary LanguagePythonMIT LicenseMIT

Hafez Poetry Telegram Bot

This Telegram bot provides random Hafez poems along with their meanings when prompted with the /fal command. The bot is built using Python and the python-telegram-bot library, and it reads the poems from an XLSX file.

Structure

hafez_bot/
├── __init__.py
├── hafez_bot.py
├── Faal.xlsx
├── .gitignore
├── LICENSE
├── README.md
└── requirements.txt

Features

  • Start the bot with /start to get a welcome message.
  • Use /fal to receive a random Hafez poem and its meaning.

Prerequisites

  • Python 3.7+
  • Telegram Bot API token
  • An XLSX file containing Hafez poems and their meanings

Setup

  1. Clone the repository:
   git clone https://github.com/Mohammadk202/test_bot
   cd hafez-poetry-bot
  1. Install the required packages:
   pip install -r requirements.txt
  1. Place your Faal.xlsx file in the root directory of the project. Ensure the XLSX file has the following columns:

    • Column A: Poem
    • Column B: Meaning
  2. Add your Telegram bot token to a .env file:

echo BOT_TOKEN=your_bot_token_here > .env

Running the Bot

  1. Run the bot using the following command:
   python hafez_bot.py
  1. Open your Telegram app and start a chat with your bot. Use the /start command to initiate the conversation and then use /fal to receive a random Hafez poem.

Deployment

To deploy the bot to a platform like Railway, follow these steps:

  1. Create a new project on Railway and link it to your GitHub repository.
  2. Set the environment variable BOT_TOKEN with your Telegram Bot API token in the Railway project settings.
  3. Deploy the project, and Railway will automatically build and run the bot.

Contributing

Feel free to submit issues or pull requests if you have suggestions or improvements.

License

This project is licensed under the MIT License. See the LICENSE file for details