The secret-santa
package is a Secret Santa 🎅🎄 game which randomly assigns and notifies people to whom they should give a gift using Twilio's messaging API.
My friends and I wanted to have a Secret Santa party in our group, but didn't have the time to meet and draw names, so we wrote this code to have it draw the names and send each participant the name of whom he should give a gift to.
I was bored. Truly bored!
And I know this could be written in one file - with a handful of code lines, but I wanted to try a few things out such as poetry
, mkdocs
, Google style docstrings
, etc.
=> This is the result.
To be able to install the project's dependencies, you need to have:
A few notes:
|
(for Union type hinting) without importing it from futures
.poetry
as its build system, but that could be changed to pip
by changing the [build-system]
section to requires = ["setuptools ~= 58.0", "cython ~= 0.29.0"]
and running the command below from the root of the project:
python -m pip install .
To run this package, you need to have:
.env
file to be passed to the program through the command line with the --env-path
arguments.
TWILIO_ACCOUNT_SID
, TWILIO_AUTH_TOKEN
, and TWILIO_NUMBER
which could be added to a .env
file like this:
TWILIO_ACCOUNT_SID="YOUR_TWILIO_ACCOUNT_SID_HERE"
TWILIO_AUTH_TOKEN="YOUR_TWILIO_AUTH_TOKEN_HERE"
TWILIO_NUMBER="YOUR_TWILIO_NUMBER_HERE"
--env-path
argument was not provided, the code will try to search for a .env
file at the project root. Please note: The code will not throw an error if no environment file has been passed / if the file does not exist, but it will validate the existence of the three environment variables mentioned above (i.e. the environment variables needed could be set from the commandline / on the system beforehand.)--participants-path
argument, with each player having a full_name
, phone_number
, and optionally a nickname
as such:
[
{
"full_name": "Name 1",
"phone_number": "+123456789",
"nickname": "N1"
},
{
"full_name": "Name 2",
"phone_number": "+987654321"
},
...
]
--participants-path
argument was not provided, the code will try to look for a participants.json
file at the project root.To install the dependencies with poetry installed, all you need to do is run:
poetry install
To run the Secret Santa package / module, all you need to do after setting it up is run:
poetry run secret_santa
with the appropriate commands / arguments.
To see all the supported command-line arguments, run poetry run secret_santa --help
.
I can think of some things to add, such as:
--check-participants
to validate no two participants are the same (by phone number)--custom-message
to allow for customizing the message to be sent to the user's liking.If ever comes a time in which I'll be in a similar state to the one I was in writing this code, I may add these, but I don't see myself doing a lot with this package in the near future, however, if you like it and would like to add something, feel free to contribute.
You could contribute code to the repository in many ways:
git checkout -b my-new-feature
.Google style docstrings
git commit -m "Added some feature"
.git push origin my-new-feature
.my-new-feature
to the main
branch with a descriptive description of the changes made.In the spirit of Christmas, I decided publish this code under the Unlicense License, to whomever may find it useful / want to use it (if someone ever will 😊.)
The secret-santa
project was originally developed by Fawzi Abo Shkara.