Skip to main content

Discord bot for organizing Werewolf RP games ESPCI-style

Project description

lg-rez

PyPI PyPI - Python Version PyPI - Wheel Read the Docs

Discord bot for organizing boisterous Werewolf RP games ESPCI-style.

Please not that this project's source code (comments, docstrings) is written exclusively in French. The bot itself uses only French language; no internationalization is available at this time.

NOTE AUX GRIS / MJS

Tout ce qui suit est du blabla READMEsque peu intéressant.

Pour les trucs intéressants, c'est-à-dire les instructions pour lancer une nouvelle saison, voir Nouvelle saison.md.

What's New in LG-Rez

Only major features are reported here; see CHANGELOG.md or in the doc for details.

3.0

  • Changed all commands to Discord builtin slash commands, using Discordpy 2.0
  • Several major commands changes

2.4

  • New commands !mp, !setup, !cfini
  • New subcommand !boudoir find
  • Minor improvements and command changes.

2.3

  • New subcommand !boudoir ping
  • Command !roles partially splitted to !camps.

2.2

  • New command !modif.

2.1

  • New Actions System with actions / vote history and better action request;
  • New Boudoirs management system and new command !boudoir;
  • New command !lore.

2.0

  • Major refactoring of data management and internal structure;
  • New config namespace module for easier customization.

Installation

Use the package manager pip to install lg-rez:

pip install lg-rez

We strongly recommand to install this package in a dedicated virtualenv (python3 -m venv <yourfolder>).

Dependencies

Configuration

To run correctly, the bot needs to be connected to several external services, each needing more or less sensitive tokens, stocked as environments variables. We support and encourage the use of python-dotenv to read them from a .env file, but you may prefer exporting them as environment variables.

All necessary variables, prefixed by LGREZ_, are listed in model.env.

Configuration Assistant Tool

We provide a command-line assistant tool to help you set up every services and generate the .env file (which you can later source and delete if you wish).

Run it simply with:

python -m lgrez

This tool also creates a start_bot.py file containing the minimal code needed to run the bot (see Usage section below).

Manual configuration

You may prefer to manually write your environment variables, or just check instructions regarding a specific one: they can be found in CONFIGURE.md.

Warning: the Configuration Assistant Tool checks every variable by running specific tests, which is not the case for manual configuration, so be sure of what you do!

Usage

This package's external API consists essentially in a discord.ext.commands.Bot subclass, LGBot, which implements every features needed to play.

The minimal code needed to run the bot in a configured folder (generated by the configuration assistant tool) is:

from lgrez import LGBot

bot = LGBot()
bot.run()

Bot usage

Once the bot connected to your Discord server, send !help to see every available commands (note: some commands are only visible by specific roles; grant yourself the "MJ" AND "Joueur en vie" roles to see everything.)
Use !help command to get more information about a command.

For precisions relative to non-command features (such as "IA" reactions to messages), look at the corresponding documentation section.

Customization

Since LGBot is a subclass of discord.ext.commands.Bot, you can use every arguments and methods it supports or subclass it to override existing behavior.

We also provide a direct way to customize some parameters of the game and of the Discord server through config module: roles/channels/emoji names, date of season beginning, inscription customization... See the doc for full API usage information.

See additional attributes and overriden methods on the doc (mostly in French)

Some useful examples:

Change command prefix

from lgrez import LGBot

bot = LGBot(command_prefix="?")
bot.run()

Customize some config options

from lgrez import LGBot, config

config.debut_saison = "27 octobre"
config.Role.mj = "Game-Master"

bot = LGBot()
bot.run()

Delete a command or alias

from lgrez import LGBot

bot = LGBot()
bot.remove_command("command_name")
bot.run()

Add a command or change the behavior of a command

from discord.ext import commands
from lgrez import LGBot

@commands.command()
async def mycommand(ctx, ...):
    ...

bot = LGBot()
bot.remove_command("mycommand")     # If replacing an existing command
bot.add_command(mycommand)
bot.run()

Enhance or replace the reaction to a Discord event

from lgrez import LGBot

async def say_hello(bot, member):
    await member.send("Hey!")

class MyBot(LGBot):
    """Your customized bot class"""
    async def on_member_join(self, member):
        await say_hello(self, member)
        super().on_member_join(member)      # Invoke the original reaction

bot = MyBot()
bot.run()

See discord.py documentation for more ideas.

Contributing

Community contributions are not welcome for now. Get in touch with the authors (see below) for any question or suggestion about this project.

License

This work is shared under the MIT license.

© 2020 - 2022 Loïc Simon, Tom Lacoma et al. – Club BD-Jeux × GRIs – ESPCI Paris - PSL

Reach us on Discord: LaCarpe#1674, TaupeOrAfk#3218 or by mail: loic.simon@espci.org, tom.lacoma@espci.org

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lg_rez-4.0.18.tar.gz (133.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lg_rez-4.0.18-py3-none-any.whl (150.8 kB view details)

Uploaded Python 3

File details

Details for the file lg_rez-4.0.18.tar.gz.

File metadata

  • Download URL: lg_rez-4.0.18.tar.gz
  • Upload date:
  • Size: 133.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for lg_rez-4.0.18.tar.gz
Algorithm Hash digest
SHA256 d6c8160c886b34073e888dc0b0756edc62008c81ef95b72e04f78a70aa146aec
MD5 6af3061fcac80b1df931391ae923dfa9
BLAKE2b-256 bcd7db9923622b69d6e117d9057a7821f72ca6419de761b0a33a3ed1e8841e9f

See more details on using hashes here.

File details

Details for the file lg_rez-4.0.18-py3-none-any.whl.

File metadata

  • Download URL: lg_rez-4.0.18-py3-none-any.whl
  • Upload date:
  • Size: 150.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for lg_rez-4.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 32ff139640c9f751716533bb9e3f8fb8b22c6aab7e5c687c1c5c0f5819ead2cd
MD5 f3bcd60565e5c9485422e99e1f100ec6
BLAKE2b-256 0f57b9247eb359ddb06a71d95779480a72c34daef8ea4ce38f66298c144b4298

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page