├── README.md └── Kris_Kingle.py /README.md: -------------------------------------------------------------------------------- 1 | # SECRET SANTA / KRIS KINGLE 2 | ![secret](https://user-images.githubusercontent.com/78873223/152636931-5d17014d-6390-4ab6-bbdc-73831ac73b59.jpg) 3 | 4 | ### Note: 5 | Before executing the script, make sure to turn on 'Less Secure App access' option from your gmail ID that will be used to send out the mails to all participants of the game. 6 | To do so, get going with the following steps: 7 | 8 | 1.Log into the Gmail account that will be used to send the emails. 9 | 10 | 2.Go to Gmail's [Less Secure App Access](https://myaccount.google.com/lesssecureapps?pli=1&rapt=AEjHL4NELkm6zvkeSQxzOL8a2UdhbIUASi6uvDQY573YvLX9rO1G5GHA4Um6YgEmGmZD6_Jc2tsqRDXuMf99mMud0Pslsov5MA) 11 | 12 | 3.Set the Allow less secure apps option to ON. 13 | 14 | ### OUTPUT 15 | Post execution of this script the following is performed automatically: 16 | 17 | > 1. The script automatically allots everyone a name for whom they have to buy a gift this christmas. 18 | > 2. Every participant receives the necessary details of the game on their respective Email IDs to maintain confidentiality. 19 | > 3. A CSV file containing the dataframe is created to store the records. 20 | 21 | ## Libraries to be installed: 22 | 23 | > 1. pandas 24 | > 2. numpy 25 | 26 | ### Installation can be done using the pip command. (Example: pip install pandas) 27 | 28 | 29 | ## Inbuilt libraries required: 30 | 31 | > 1. smtplib 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Kris_Kingle.py: -------------------------------------------------------------------------------- 1 | #Random allotment and secretly mailing the allotment details to each participant. 2 | 3 | import numpy as np 4 | import pandas as pd 5 | import smtplib 6 | 7 | participants = { 8 | 'Vikas' : 'Email ID of Vikas', #Example: 'abc@gmail.com' 9 | 'Dev' : 'Email ID of Dev', #Example: 'bbc@gmail.com' 10 | 'Mahek' : 'Emai ID of Mahek', #Example: 'cbc@gmail.com' 11 | 'Akash' : 'Email ID of Akash', #Example: 'dbc@gmail.com' 12 | 'Vishal' : 'Email ID of Vishal' #Example: 'lbc@gmail.com' 13 | } 14 | 15 | 16 | #set groups of people which must not gift each other, 0 means no constrains, every other number is a group 17 | 18 | constrains = { 19 | 'Vikas' : 0, 20 | 'Dev' : 0, 21 | 'Mahek' : 1, 22 | 'Akash' : 1, 23 | 'Vishal' : 0 24 | } 25 | 26 | 27 | def setRandom(): 28 | santa = list(np.random.choice(list(participants.keys()), len(list(participants.keys())), replace = False)) 29 | receiver = [] 30 | for i in range(-1, len(santa)-1): 31 | receiver.append(santa[i]) 32 | return santa, receiver 33 | 34 | def checkConstrains(): 35 | for i in range(len(santa)): 36 | print(i, santa[i], constrains[santa[i]], receiver[i], constrains[receiver[i]], sep = ' | ', end = '\n') 37 | if santa[i]==receiver[i]: 38 | return False 39 | if constrains[santa[i]] and constrains[santa[i]] == constrains[receiver[i]]: #se il vincolo è diverso da 0 oppure se sono uguali 40 | return False 41 | return True 42 | 43 | 44 | 45 | 46 | 47 | santa, receiver = setRandom() 48 | while not checkConstrains(): 49 | santa, receiver = setRandom() 50 | print(santa, receiver) 51 | 52 | 53 | #Keep less secured apps option turned on from your gmail account to avoid error while sending out the mail. 54 | 55 | smtpObj = smtplib.SMTP('smtp.gmail.com', 587) 56 | smtpObj.ehlo() 57 | smtpObj.starttls() 58 | email = input('Enter your email: ') 59 | password = input('Enter your password: ') 60 | smtpObj.login(email, password) 61 | 62 | for j in range(len(participants)): 63 | smtpObj.sendmail(email, participants[santa[j]], \ 64 | 'Subject: Secret Santa 2022 \ 65 | \nHo Ho Ho %s! \ 66 | \n\nChristmas is almost here, \ 67 | \n\nThis year you are gifting to....... %s!' % (santa[j], receiver[j])) 68 | 69 | smtpObj.quit() 70 | 71 | #df = pd.DataFrame({'santa':santa, 'receiver':receiver}) 72 | #df.to_csv('Kris Kingle list.csv') 73 | 74 | 75 | 76 | 77 | 78 | --------------------------------------------------------------------------------