Generator Daftar Nama Santa Rahasia yang Dapat Disesuaikan
Tujuan dari skrip ini adalah untuk:
Tetapkan setiap pembeli daftar penerima hadiah untuk acara Secret Santa. Pengguna dapat menentukan jumlah hadiah yang harus dibeli oleh setiap pembeli, dan program akan memastikan bahwa tidak ada pembeli yang menggambar nama yang sama dua kali.
Kirim email ke semua peserta Secret Santa yang memberi tahu mereka siapa untuk membeli hadiah.
Gambarlah pohon Natal dan sertakan dalam email untuk perayaan. Pohon Natal adalah serangkaian karakter berikut: [,], =, ~.
Contoh seperti apa emailnya:
git clone https://github.com/tylerlum/DrawNames.git
cd DrawNames
pip install -e .
python run_draw.py --help
usage: run_draw.py [--name_to_email_dict NAME_TO_EMAIL_DICT]
[--name_to_nickname_dict NAME_TO_NICKNAME_DICT]
[--n_recipients_per_buyer N_RECIPIENTS_PER_BUYER]
[--email_subject_line EMAIL_SUBJECT_LINE]
[--email_used_to_send EMAIL_USED_TO_SEND] [-h]
optional arguments:
--name_to_email_dict NAME_TO_EMAIL_DICT
(Dict[str, str], default={'Tyler':
'[email protected]', 'OtherTyler':
'[email protected]'}) Tyler
--name_to_nickname_dict NAME_TO_NICKNAME_DICT
(Dict[str, str], default={'Tyler': 'Tygertron',
'OtherTyler': 'SwoleDude'}) Tyler
--n_recipients_per_buyer N_RECIPIENTS_PER_BUYER
(int, default=1)
--email_subject_line EMAIL_SUBJECT_LINE
(str, default=Sibling Secret Santa Draw 2023)
--email_used_to_send EMAIL_USED_TO_SEND
(Union[str, NoneType],
[email protected])
-h, --help show this help message and exit
Catatan:
Jauh lebih mudah untuk memodifikasi argumen default di run_draw.py
daripada menggunakan baris perintah secara langsung.
Sebagian besar pengguna perlu memodifikasi sebagian besar argumen ke kasus penggunaan spesifik mereka
Pastikan name_to_nickname_dict
dan name_to_email_dict
memiliki kunci yang sama
python run_draw.py
================================================================================
args = {'email_subject_line': 'Sibling Secret Santa Draw 2023',
'email_used_to_send': '[email protected]',
'n_recipients_per_buyer': 1,
'name_to_email_dict': {'OtherTyler': '[email protected]',
'Tyler': '[email protected]'},
'name_to_nickname_dict': {'OtherTyler': 'SwoleDude', 'Tyler': 'Tygertron'}}
================================================================================
--------------------------------------------------------------------------------
Reminder: to send emails, [email protected] must have app password set up.
If not set up, refer to https://support.google.com/mail/answer/185833?hl=en-GB or search for 'Sign in using app passwords'
--------------------------------------------------------------------------------
Enter the app password for [email protected]:
Thank you. Password was correct.
Names have been drawn!
Is this a valid assignment? True
Hi Tygertron! You will be buying a lovely present for: SwoleDude. :)
-Tyler Bot
NICKNAMES:
Tyler: Tygertron
OtherTyler: SwoleDude
[]
[~]
[~~]
[~~~]
[~~~~]
[~~~~~]
[~~~~~~]
[~~~~~~~]
[~~~~~~~~]
[~~~~~~~~~]
[~~~~~~~~~~]
[]
[]
[]
Email sent
Hi SwoleDude! You will be buying a lovely present for: Tygertron. :)
-Tyler Bot
NICKNAMES:
Tyler: Tygertron
OtherTyler: SwoleDude
[]
[~]
[~~]
[~~~]
[~~~~]
[~~~~~]
[~~~~~~]
[~~~~~~~]
[~~~~~~~~]
[~~~~~~~~~]
[~~~~~~~~~~]
[]
[]
[]
Email sent
Email sent
python run_draw.py
================================================================================
args = {'email_subject_line': 'Sibling Secret Santa Draw 2023',
'email_used_to_send': '[email protected]',
'n_recipients_per_buyer': 1,
'name_to_email_dict': {'OtherTyler': '[email protected]',
'Tyler': '[email protected]'},
'name_to_nickname_dict': {'OtherTyler': 'SwoleDude', 'Tyler': 'Tygertron'}}
================================================================================
--------------------------------------------------------------------------------
Reminder: to send emails, [email protected] must have app password set up.
If not set up, refer to https://support.google.com/mail/answer/185833?hl=en-GB or search for 'Sign in using app passwords'
--------------------------------------------------------------------------------
Enter the app password for [email protected]:
Traceback (most recent call last):
File "run_draw.py", line 115, in <module>
main()
File "run_draw.py", line 69, in main
email_sender = EmailSender(user=email_used_to_send, password=app_password)
File "<string>", line 5, in __init__
File "/home/tylerlum/github_repos/DrawNames/DrawNames/email_utils.py", line 38, in __post_init__
self.passwordcheck()
File "/home/tylerlum/github_repos/DrawNames/DrawNames/email_utils.py", line 33, in passwordcheck
server.login(self.user, self.password)
File "/home/tylerlum/miniconda3/envs/rlgpu/lib/python3.7/smtplib.py", line 735, in login
raise last_exception
File "/home/tylerlum/miniconda3/envs/rlgpu/lib/python3.7/smtplib.py", line 726, in login
initial_response_ok=initial_response_ok)
File "/home/tylerlum/miniconda3/envs/rlgpu/lib/python3.7/smtplib.py", line 647, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. Learn more atn5.7.8 https://support.google.com/mail/?p=BadCredentials ju17-20020a170903429100b001c0a4146961sm4804704plb.19 - gsmtp')