Canary is a Python3 bot designed for the McGill University Community Discord Server. The bot provides helper functions to users, as well as fun functions, a quote database and custom greeting messages.
Master | |
---|---|
Dev |
- If you wish to use the
update
command to update to the latest version of the bot, configure your github account in your environment of choice and clone into the repository with:
$ git clone https://github.com/idoneam/Canary
- Dependencies are managed with poetry which can be installed via pip with:
$ python3 -m pip install poetry
- Dependencies may be installed using poetry with the following command:
$ poetry install --no-dev
-
Use of the LaTeX equation functionality requires a working LaTeX installation (at the very minimum,
latex
anddvipng
must be present). The easiest way to do this is to install TeX Live (usually possible through your distro's package manager, or through TeX Live's own facilities for the latest version). See the TeX Live site for more information. -
Development dependencies (YAPF and
pytest
) can be installed alongside all other dependencies with:
$ poetry install
-
You may enter the virtual environment generated by the pipenv installation with:
$ poetry shell
or simply run the bot with$ poetry run python3 Main.py
-
In order to run bots on Discord, you need to create a bot account.
You must set certain values in the config.ini
file, in particular your Discord bot token (which you get in the previous link) and the values in the [Server]
section.
Click here to see descriptions for a few of those values
(For values that use Discord IDs, see this to know how to find them)
[Discord]
Key
: Your Discord bot token.
[Server]
ServerID
: Your server ID.CommandPrefix
: What a message should begin with to be considered a command.BotName
: The name of your bot.UpvoteEmoji
: The name of your upvote emoji (for the score function).DownvoteEmoji
: The name of your downvote emoji.ModeratorRole
: The name of the role that your moderators have (for functions like DMing users).DeveloperRole
: The name of the role that your developers have (for functions like restarting the bot). This could be the same role than moderator.ReceptionChannelID
: The ID of a channel that will receive messages sent to the bot through theanswer
command (and where messages sent by mods to users with thedm
command will be logged)
[Meta]
Repository
: The HTTPS remote for this repository, used by theupdate
command as the remote when pulling.
[Logging]
LogLevel
: See this for a list of levels. Logs from exceptions and commands likemix
andbac
are at theinfo
level. Logging messages from the level selected and from more severe levels will be sent to your logging file. For example, setting the level toinfo
also sends logs fromwarning
,error
andcritical
, but not fromdebug
.LogFile
: The file where the logging output will be sent (will be created there by the bot if it doesn't exist).
[DB]
Schema
: Location of the Schema file that creates tables in the database (This file already exists so you shouldn't have to change this unless you rename it or change its location).Path
: Your database file path (will be created there by the bot if it doesn't exist).
[Helpers]
CourseTemplate
: McGill course schedule URL. Changes every school year.CourseSearchTemplate
: McGill course search URL. Changes every school year.GCWeatherURL
: Government of Canada weather URL. Region-specific.GCWeatherAlertURL
: Government of Canada weather alerts URL. Region-specific.WttrINTemplate
: http://wttr.in/ URL template. Region-specific.TepidURL
: TEPID screensaver endpoint for printer status.
[Subscribers]
FoodRecallChannel
: Channel where you want CFIA recall notices posted.FoodRecallLocationFilter
: Regions you want to receive CFIA recall notices for.FoodSpottingChannel
: Channel where you want foodspotting posts to be sent, ideally in a dedicated channel.NoFoodSpottingRole
: Name of role assigned to abusers of the foodspotting command that will prevent them from using it.MetroStatusChannel
: Channel where you want metro status alerts to be sent, ideally in a dedicated channel with opt-in read permissions for users.
[Currency]
Name
: The name of the bot currency.Symbol
: The currency's symbol (e.g.$
).Precision
: How many decimal digits after the decimal point are "official" for the currency.Initial
: How much currency is given out by theinitial_claim
command.SalaryBase
: Currently unused.Inflation
: Currently unused.
[IncomeTax]
: Currently unused.[AssetTax]
: Currently unused.[OtherTax]
: Currently unused.[Betting]
:RollCases
: Intervals forbet_roll
. For example, a value of66, 90, 99, 100
gives the intervals[1, 66]
,[67, 90]
,[91, 99]
, and[100]
.RollReturns
: The multiplier return for each interval. For example, a value of0, 2, 4, 10
with the intervals described above gives a 0x return forrandom <= 66
, a 2x return for66 < random <= 90
, a 4x return for90 < random <= 99
, and a 10x return forrandom == 100
.
[Roles]
:Pronouns
: Comma seperated list of pronoun roles in server.Fields
: Comma seperated list of field of study roles in server.Faculties
: Comma seperated list of faculty roles in server.Years
: Comma seperated list of year roles in server.Generics
: Comma seperated list of generic or meme roles in server.
If you installed all dev dependencies, you can run tests with poetry run pytest
.
Run poetry run python Main.py
in your shell. Ensure that your Discord token is set in the config.ini
file within the config
directory.
A Docker Container is provided for easier development.
Freeze requirements to a requirements.txt
$ poetry export -f requirements.txt > requirements.txt
From within the root of the repository:
$ docker build -t canary:latest .
From within the root of the repository:
$ docker run -v $(pwd):/mnt/canary canary:latest
Optionally provide the -d
flag to run the container in detached state.
Note that the current host directory is mounted into the container, any changes to log files, pickles, configuration are reflected across the host and the container.
We format our code using Google's YAPF. Our builds will reject code that do not conform to the standards defined in .style.yapf
. You may format your code using :
$ poetry run yapf --recursive --in-place .
and ensure your code conforms to our linting with :
$ poetry run yapf --diff --recursive .
Contributions are welcome, feel free to fork our repository and open a pull request or open an issue. Please review our contribution guidelines before contributing.