Coder Social home page Coder Social logo

wheelercj / parhelion Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 2.88 MB

A general-purpose Discord bot that can send reminders, help answer FAQs, translate between many different languages, solve math questions, run code in almost any language, and more.

License: MIT License

Python 99.96% Dockerfile 0.04%
assistant bot discord discord-bot discord-py docker python

parhelion's Introduction

Parhelion

A general-purpose Discord bot that can send reminders, help with answering FAQs, translate between many different languages, solve math questions, run code in just about any language, and more.

demo gif

You can try the bot in the support server, or invite the bot into your own server, or run your own instance of the bot by following the instructions below.

setup instructions

These instructions require Docker to be installed and maybe Git. You don't need to know how to use them.

  1. Create a Discord API app. Enable the server members intent and the message content intent. You can see which permissions the bot needs in the get_bot_invite_link function near the top of cogs/utils/common.py.
  2. Download the bot's files in one of two ways:
    • If you just want to run the bot, download docker-compose.yml from this repo into a folder for the bot.
    • If you want to be able to edit the bot's code, use git clone https://github.com/wheelercj/Parhelion.git && cd Parhelion.
  3. Create a file named .env in the bot's folder. See the sample .env below for what to put in the file.
  4. Use docker compose up -d to download image(s) from Docker Hub if needed, create containers, and run the bot and database.

Here are other docker commands that may be helpful:

  • docker compose logs -ft to see the live Docker logs. Note that the bot's logs can be found in a "logs" folder created by the bot.
  • docker compose up -d --build to rebuild the bot's image from source code, create containers, and run the bot and database.
  • docker compose up -d --pull=always to redownload the bot's image from Docker Hub, create containers, and run the bot and database.
  • docker compose ps to list all containers and see their statuses.
  • docker image ls to list all images.
  • docker volume ls to list all volumes (including the volume holding the database's data).
  • docker compose pause to pause the containers.
  • docker compose unpause to unpause paused containers.
  • docker compose stop to stop the containers (this clears their memory).
  • docker compose start to start stopped containers.
  • docker compose down to stop and delete the containers. The bot's logs and the database's data will persist.
  • docker compose rm to delete stopped containers. The bot's logs and the database's data will persist.
  • docker volume rm <volume name> to delete a volume such as the database's data.
  • See the official docs for more.

sample .env

Here's an example of a .env file for this bot based on the real one Parhelion uses (all the secrets in this example have been replaced with fakes).

# The only variables required for the bot to run are DISCORD_BOT_TOKEN,
# POSTGRES_PASSWORD, and PRIVACY_POLICY_LINK. Some variables are required for certain
# features and/or have default values defined elsewhere you may want to change as
# described below. Most of the remaining variables you will probably want to
# comment-out, delete, or change the value of.

# Get the token from the Discord API app page: https://discord.com/developers/applications
DISCORD_BOT_TOKEN="BfnYJ4XscOQOIkC5bxUbr3QH.D9yps5.cfURLTidT_zCPRZ-DxcaUMk634E"

PRIVACY_POLICY_LINK="https://gist.github.com/wheelercj/033bbaf78b08ff0335943d5119347853"

# The Postgres variables, if removed, default to the Postgres defaults (except password;
# there is no default password).
POSTGRES_DB="bot"
POSTGRES_USER="dev"
POSTGRES_PASSWORD="dkByXjCEQJ7UPYgyZu1W167LhldOVcSgEV7EXmhs7iYbzf4yv73tmIzYlmqvSQHYZrLo7se8lbOR3FYIFBzJv6NgDwg5GBj4FZI"

# These two variables are used by the bot, but not by the `parhelion_db` service in
# docker-compose.yml which always uses localhost and port 5432. If the database is
# running in Docker (the default), the `parhelion` service requires POSTGRES_HOST to be
# the name of the database's container ("parhelion_db" by default).
POSTGRES_HOST="parhelion_db"
POSTGRES_PORT="5432"

# This is a string of a comma-separated list of command prefixes. If you want a comma as
# part of a command prefix, use `COMMA` to say where. The command prefixes `/` and `@`
# are hardcoded.
DEFAULT_BOT_PREFIXES=";,par ,Par "

# Required if you want to use the owner-only `gist` command for making gists.
MAIN_GITHUB_GISTS_TOKEN="ghp_gHc6Zhhprk43ZGM1VNNvQmgnDxydvKxmDVfb"

# These are used to automatically create gists of any leaked bot tokens Parhelion
# detects to invalidate the tokens and protect Discord bots (including itself). If you
# think many tokens might be spammed, you could create a separate GitHub account for
# this so you don't clutter your main account (if you have one).
ALTERNATE_GITHUB_GISTS_TOKEN="ghp_aPyJbZJYCXN9wS0ZGsnHPMvc40A63DUnIScH"
ALTERNATE_GITHUB_ACCOUNT_NAME="beep-boop-82197842"

# The support server variables are for a support server for your bot, if you have one.
SUPPORT_SERVER_LINK="https://discord.gg/mCqGhPJVcN"
SUPPORT_SERVER_ID="845465081582977044"

MEMBERSHIP_LINK="https://ko-fi.com/parhelion99369"
MEMBERSHIP_REMOVES_NOTE_LIMIT="true"
MEMBERSHIP_REMOVES_REMINDER_LIMIT="true"
MEMBERSHIP_REMOVES_TAG_LIMIT="true"
MEMBERSHIP_ROLE_IDS="884564744722333697,884565844221382668,884565211632267285"
# By default, all membership roles remove the note, reminder, and tag limits.

parhelion's People

Contributors

wheelercj avatar

Stargazers

Holy avatar

Watchers

Kostas Georgiou avatar  avatar

Forkers

nexuslove

parhelion's Issues

Duplicate log messages

Sometimes, messages are logged multiple times.

Example:

2023-12-16 07:38:31[INFO]Loading . . .
2023-12-16 07:39:00[INFO][author chris__________][guild None][command remind]
2023-12-16 07:55:01[INFO][author chris__________][guild None][command /remind list]
2023-12-16 07:55:10[INFO][author chris__________][guild None][command /remind delete]
2023-12-17 20:38:51[INFO]Loading . . .
2023-12-17 20:38:51[INFO]Loading . . .
2023-12-18 05:03:03[INFO][author chris__________][guild None][command /timestamp]
2023-12-18 05:03:03[INFO][author chris__________][guild None][command /timestamp]
2023-12-18 05:03:56[INFO][author chris__________][guild None][command /timestamp]
2023-12-18 05:03:56[INFO][author chris__________][guild None][command /timestamp]
2023-12-20 06:43:21[INFO][author chris__________][guild None][command /translate to]
2023-12-20 06:43:21[INFO][author chris__________][guild None][command /translate to]
2023-12-20 10:09:59[INFO]Loading . . .
2023-12-20 10:09:59[INFO]Loading . . .
2023-12-20 10:09:59[INFO]Loading . . .
2023-12-21 06:49:51[INFO][author chris__________][guild None][command /timestamp]
2023-12-21 06:49:51[INFO][author chris__________][guild None][command /timestamp]
2023-12-21 06:49:51[INFO][author chris__________][guild None][command /timestamp]
2023-12-21 06:50:14[INFO][author chris__________][guild None][command /timestamp]
2023-12-21 06:50:14[INFO][author chris__________][guild None][command /timestamp]
2023-12-21 06:50:14[INFO][author chris__________][guild None][command /timestamp]

Notice the time of each line. Some lines have the same time as other lines, which doesn't make sense since all commands here were from one person, unless individual events are being logged multiple times.

The patterns in the log files suggest that when the bot reconnects, the logger is sometimes recreated but doesn't actually replace the existing logger even though the variable is overwritten.

It appears the discord.py documentation has changed slightly since I last read about on_connect. It now says that the warnings from on_ready also apply; that is, the on_connect function may be called multiple times during a single run of the bot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.