Skip to content

Configurable true random lottery ticket generator with the help of the random.org API. Emails you true random numbers for the configured lottery ticket packs.

Notifications You must be signed in to change notification settings

luczsoma/lottery-random

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lottery-random

lottery-random is a true random lottery ticket generator with the help of the random.org API. It emails you true random numbers for the configured lottery ticket packs via Azure Communication Services in the following format:


Lottery numbers for John Smith

Lottery numbers for John Smith

Lottery 5: [2, 5, 26, 43, 87], [3, 27, 42, 54, 87]
Lottery 6: [4, 7, 18, 32, 38, 39], [1, 2, 13, 27, 37, 40], [9, 17, 23, 30, 41, 43], [4, 8, 9, 12, 28, 37]
EuroJackpot: [15, 20, 23, 28, 44 | 1, 8], [2, 3, 24, 39, 41 | 2, 8], [3, 4, 8, 9, 11 | 5, 9]

Timestamp: 2019/05/09 03:25:32 (UTC)

This email was sent you by Jane Smith ([email protected]) using https://github.com/luczsoma/lottery-random.


Requirements

*Please note that you are not allowed to use an API key with neither Developer nor Non-Profit API key licenses: visit https://api.random.org/pricing for details.

Usage

Clone the repository:

git clone https://github.com/luczsoma/lottery-random.git

Create a virtual environment and activate it:

python -m venv venv
. ./venv/bin/activate

Install all dependencies:

pip install -r requirements.txt

Clone the example configuration file into your config file:

cp config.example.json config.json

Fill the config file with your desired configuration, and you are ready to go. Run the following command to send randomly filled lottery tickets to the given email addresses:

python src/lottery-random.py

Running lottery-random periodically

There are quite a few methods to run lottery-random periodically. E.g., if you have an always-on server anywhere on the internet you can add an entry to your user's crontab file. Enter:

crontab -e

Then enter the following:

0 0 * * 0 python lottery-random.py

This will run lottery-random every Sunday at midnight (according to your server's time zone).

Configuration options

You can see the JSON schema of the config.json file defined in config.schema.json. Your config.json file must comply with the provided schema.

API key for the random.org API

Provide your random.org API key in the random_org_api_key field:

{
  // …
  "random_org_api_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  // …
}

Please note that you are not allowed to use an API key with neither Developer nor Non-Profit API key licenses: visit https://api.random.org/pricing for details.

Azure Communication Services

Provide your Azure Communication Services endpoint and API key in the azure_email_endpoint and azure_email_key fields, respectively:

{
  // …
  "azure_email_endpoint": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "azure_email_key": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  // …
}

Email sender name and address

Provide the email address and name configured in Azure Communicationn Services in the sender_email and sender_name fields, respectively. Please note that these values will be visible in the email in the following form: "This email was sent you by {sender_name} ({sender_email}) using https://github.com/luczsoma/lottery-random.".

{
  // …
  "sender_email": "[email protected]",
  "sender_name": "Your Name"
  // …
}

Lottery game definitions

A lottery game definition is the description of a particular lottery game: it defines how a valid ticket looks like.

E.g., a EuroJackpot ticket consists of two sets of numbers:

  • 5 numbers from the [1–50] interval,
  • 2 numbers from the [1–12] interval.

This can be configured as follows:

{
  // …
  "games": [
    {
      "name": "EuroJackpot",
      "fields": [
        {
          "n": 5,
          "min": 1,
          "max": 50
        },
        {
          "n": 2,
          "min": 1,
          "max": 12
        }
      ]
    }
  ]
  // …
}

Lottery ticket packs

A lottery ticket pack is a set of played lottery tickets sent to one or more email addresses. E.g., if you play one ticket of EuroJackpot and one ticket of Lottery 5, and your friend plays one ticket of Lottery 5 and two tickets of Lottery 6 each week, you define two separate lottery ticket packs, which will be sent to you and your friend separately. You can also configure permanent tickets to be played regularly. Permanent tickets must conform to the game definition, and cannot contain duplicate numbers.

Lottery ticket packs can be configured as follows:

{
  // …
  "lottery_ticket_packs": [
    {
      "recipients": [
        {
          "email": "[email protected]",
          "name": "Your Name"
        }
      ],
      "elements": [
        {
          "game": "Lottery 5",
          "number_of_random_tickets": 1,
          "permanent_tickets": [[[3, 27, 42, 54, 87]]]
        },
        {
          "game": "Lottery 6",
          "number_of_random_tickets": 2,
          "permanent_tickets": [
            [[9, 17, 23, 30, 41, 43]],
            [[4, 8, 9, 12, 28, 37]]
          ]
        },
        {
          "game": "EuroJackpot",
          "number_of_random_tickets": 1,
          "permanent_tickets": [
            [
              [2, 5, 24, 39, 41],
              [2, 8]
            ],
            [
              [3, 4, 8, 9, 11],
              [5, 9]
            ]
          ]
        }
      ]
    },
    {
      "recipients": [
        {
          "email": "[email protected]",
          "name": "Your Friend’s Name"
        }
      ],
      "elements": [
        {
          "game": "Lottery 5",
          "number_of_random_tickets": 2,
          "permanent_tickets": []
        },
        {
          "game": "Lottery 6",
          "number_of_random_tickets": 1,
          "permanent_tickets": []
        }
      ]
    }
  ]
  // …
}

You can send the same lottery ticket pack to multiple recipients with setting the configuration as follows. Please note that the recipients.name attribute will be visible in the email in the following form: "True random lottery numbers for {recipients.name}".

{
  // …
  "lottery_ticket_packs": [
    {
      "recipients": [
        {
          "email": "[email protected]",
          "name": "Your Name"
        },
        {
          "email": "[email protected]",
          "name": "Your Friend’s Name"
        }
      ],
      "elements": [
        {
          "game": "Lottery 5",
          "number_of_random_tickets": 1,
          "permanent_tickets": [[[3, 27, 42, 54, 87]]]
        },
        {
          "game": "Lottery 6",
          "number_of_random_tickets": 2,
          "permanent_tickets": [
            [[9, 17, 23, 30, 41, 43]],
            [[4, 8, 9, 12, 28, 37]]
          ]
        },
        {
          "game": "EuroJackpot",
          "number_of_random_tickets": 1,
          "permanent_tickets": [
            [
              [2, 5, 24, 39, 41],
              [2, 8]
            ],
            [
              [3, 4, 8, 9, 11],
              [5, 9]
            ]
          ]
        }
      ]
    }
  ]
  // …
}

About

Configurable true random lottery ticket generator with the help of the random.org API. Emails you true random numbers for the configured lottery ticket packs.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages