Skip to content

ahmed-n-abdeltwab/python-rocketchat-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Rocket.Chat Bot (rocketchat_API==1.35.1)

It just does simple stuff like greeting when login and logout.


📌 Project Purpose

This bot:

  • Greets users with a welcome message when they log in.
  • Sends farewell messages when they log out.

🏗️ Software Design

🔹 Design Pattern

  • Modular Design: Each module has a single responsibility and is easy to maintain.

  • Layered Architecture:

    • Configuration Layer: Environment variables and settings.
    • API Client Layer: Communicates with the rocketchat_API.
    • Business Logic Layer: Handles greeting messages and user events.
    • Entry Point: Starts the bot and orchestrates all components.

🔹 Key Principles

  • Separation of Concerns: Keeps configuration, API calls, and logic separate.
  • Single Responsibility Principle: Each module does one job, making it easy to debug and test.
  • Security: Uses environment variables to avoid exposing sensitive credentials.

📂 Project Structure

python-rocketchat-bot/
│
├── src/
│   ├── bot.py             # Main bot entry point
│   ├── config.py          # Loads environment variables
│   ├── handlers.py        # Logic for greeting messages
│   └── rocket_client.py   # Rocket.Chat API wrapper
├── requirements.txt       # Dependencies
├── .envrc                 # Direnv configuration
└── .env.example           # Example environment file (DO NOT COMMIT real credentials)

⚙️ Installation

  1. Clone the repository

    git clone https://github.com/ahmed-n-abdeltwab/python-rocketchat-bot
    cd python-rocketchat-bot
  2. Create and activate a virtual environment (optional but recommended)

    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Set up your environment variables

    • Create a .env file based on .env.example
    • Example:
    ROCKETCHAT_URL=https://your.rocket.chat
    ROCKETCHAT_USER=bot_username
    ROCKETCHAT_PASSWORD=bot_password
    CHANNEL=general

🚀 How to Run the Bot

python3 src/bot.py

The bot will start polling for user login/logout events and send greeting messages to the configured channel.


📝 Important Notes

  • Channel ID: Make sure the CHANNEL exists in Rocket.Chat. You can use either a #channel name or a direct room ID.

About

rocket.chat_API python basic bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published