Skip to main content

Discord bot for organizing Werewolf RP games ESPCI-style

Project description

lg-rez

(Français) lg-rez est un bot Discord pour encadrer des parties endiablées de Loup-Garou à la PCéenne.

(English) lg-rez is a Discord bot for organizing boisterous Werewolf RP games ESPCI-style.

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 usual environment variables.

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

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:

cd <your/code/folder>
<your/venv>/bin/python -m lgrez

This tool also creates a 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 the CONFIGURE.md file.

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

Usage

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, use !help to see every available commands (remember to grant yourself the "MJ" role before!)
Use !help command to an advanced documentation about each command.

For precisions relative to other features (such as "IA" reactions to messages), look at the corresponding (commented and documented) file in features.

Customization

Since LGBot is a subclass of discord.ext.commands.Bot, every arguments and methods described in the documentation can be used, and you can subclass it to override existing behaviour.

Some useful examples:

Change command prefix

from lgrez import LGBot

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

Disable a command or alias

from lgrez import LGBot

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

Add a command or change a command behaviour

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 change an event reaction

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)      # Call 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 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

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-1.0.2.tar.gz (72.4 kB view hashes)

Uploaded Source

Built Distribution

lg_rez-1.0.2-py3-none-any.whl (84.3 kB view hashes)

Uploaded Python 3

Supported by

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