Skip to content

leoraclet/ptibot

Repository files navigation


πŸͺ« Ptibot πŸ”‹

My friendly little Python Discord Bot

license language lastcommit
Language Libraries Size OpenSource

Important

This project is currently a work in progress !

Table of Contents

πŸ“– About

Ptibot is a lightweight and extensible Discord bot built with Python, designed to help manage simple tasks, send reminders, and moreβ€”all within your Discord server.

Whether you're running a small community or developing a personal assistant, Ptibot provides a clean and developer-friendly starting point.

✨ Features

Project

  • πŸ”„ Reproducibility: The project is built using uv, enabling seamless setup replication across different machines for consistent environments.

  • πŸ“– Well-Documented: Source files include thorough comments and, where applicable, links and explanations to clarify key settings.

Bot

  • ⌚ Reminders: Develop reminder handling (create, delete, etc.) with synchronization support for Google Calendar or other calendar services.

  • πŸ€– ChatBot: Implement a Chat Bot functionality by using the Mistral API under the hood.

  • πŸ› οΈ Tools: Develop functionality to manage tasks (create, delete, edit) and group them by category.

  • πŸ“° News: Implement a News feed that follows popular RSS feeds, and notify of new posts.

  • βœ… Task Management: Implement functionality to manage tasks (create, delete, mark as completed).

Warning

Following is a list of features I wish to implement, and therefore, are not yet features:

  • πŸ“Ή Youtube Tracker: Implement a tracker to alert of new videos choosed youtube channels.

  • πŸ‘£ Github Tracker: Develop a tracker to alert of events on repositories of connected account.

πŸ—‚οΈ Structure

Note

The project's structure is designed to be self-explanatory, but here are the key components in case you're curious.

Directories

  • assets - Contains static image resources used in the project.
  • cogs - Python modules categorized by functionality.
    • admin.py - Admin-related commands and logic.
    • common.py - Shared utility functions or commands.
  • db - Contains the application's local database file.
  • ui - Contains custom UI components

Files

  • .dockerignore - Specifies files and directories to exclude from Docker builds.
  • .env - Environment variables for local development (not for production).
  • .env.template - Template for required environment variables.
  • .gitignore - Specifies files and directories to be ignored by Git.
  • .python-version - Python version specification for tools like pyenv.
  • Dockerfile - Defines the Docker image build instructions.
  • docker-compose.yml - Docker Compose configuration file.
  • LICENSE - Project license.
  • Makefile - Automation commands for building, testing, and running the app.
  • README.md - Project documentation and overview.
  • main.py - Entry point of the application.
  • pyproject.toml - Python environment and dependency configuration.
  • requirements.txt - List of Python dependencies.
  • uv.lock - Lockfile used by uv for reproducible environments.

πŸ“¦ Dependencies

Note

Here are the main libraries / dependencies of this project, but you can find all of them in the pyproject.toml file.

  • Loguru - Python logging made(stupidly) simple
  • discord.py - An API wrapper for Discord written in Python.
  • better-exceptions - Pretty and useful exceptions in Python, automatically.

πŸ› οΈ Setup

To use this app with your Discord bot, ensure the following prerequisites are met:

  1. You have a Discord account.
  2. You’ve created an application (and bot) through the Discord Developer Portal.
  3. You have access to your bot’s TOKEN.

After completing these steps, fill in the .env.template file with the necessary configuration details (such as the TOKEN) required by the app.

Caution

Make sure to rename the file to .env so it is properly recognized by the application.

πŸ“† Google Calendar

To enable synchronization with one of your Google Calendars, please follow this guide and configure the environment variables as specified.

πŸš€ Run

If you'd like to run this bot on your machine, here are two versions of how to do so by either doing on your system or using docker.

🏠 System

First, make sure the uv Python package manager is installed on your system.

Once that's done, clone the repository

git clone https://github.com/leoraclet/ptibot
cd ptibot

Then, install the project dependencies:

uv sync

Tip

You may need to create a virtual environment beforehand:

uv venv

Finally, if you have Make installed, you can launch the development server accordingly.

make run

or you can just run simple commands using

uv run {YOUR_COMMAND}

🐳 Using Docker

Ensure that Docker is installed on your system and that the docker command is available in your terminal.

To start the Docker setup, run:

docker compose up -d

Tip

To rebuild the image from scratch (without using the cache), use the following command:

docker compose build --no-cache

As with local development, you can use the Makefile to manage Docker-related tasks easily with the following commands:

make up      # Build (if needed) and start the containers
make down    # Stop and remove containers and associated networks
make build   # Build or rebuild the Docker services
make logs    # View the output logs from running containers

πŸ”₯ Inspirations

These projects served as both inspiration and valuable references during the development of this one. Be sure to check them out if you're interested in learning more:

πŸ’‘ Tips & Tricks

SSL Certificates error

If you encounter an error similar to the following:

...

ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1010)

You can resolve this by installing pip-system-certs in your virtual environment. To do so, run:

uv add pip-system-certs

Caution

If this solution doesn't work for any reason, you can find alternative solutions here on Stack Overflow.

πŸ“œ License

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

About

πŸ’¬ My little friendly Discord bot, in Python

Topics

Resources

License

Stars

Watchers

Forks

Languages