เครื่องกำเนิดรายการชื่อซานต้าลับที่ปรับแต่งได้
จุดประสงค์ของสคริปต์นี้คือ:
มอบหมายรายชื่อผู้ซื้อแต่ละรายให้กับรายการรับของขวัญสำหรับกิจกรรมลับซานต้า ผู้ใช้สามารถระบุจำนวนของขวัญที่ผู้ซื้อแต่ละคนควรซื้อและโปรแกรมจะทำให้มั่นใจได้ว่าผู้ซื้อจะไม่มีชื่อเดียวกันสองครั้ง
ส่งอีเมลไปยังผู้เข้าร่วม Secret Santa ทุกคนที่บอกพวกเขาว่าใครจะซื้อของขวัญ
วาดต้นคริสต์มาสและรวมไว้ในอีเมลเพื่อเทศกาล ต้นคริสต์มาสเป็นสตริงของอักขระต่อไปนี้: [,], =, ~
ตัวอย่างของอีเมลจะเป็นอย่างไร:
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
บันทึก:
มันง่ายกว่ามากในการแก้ไขอาร์กิวเมนต์เริ่มต้นใน run_draw.py
มากกว่าที่จะใช้บรรทัดคำสั่งโดยตรง
ผู้ใช้ส่วนใหญ่จะต้องปรับเปลี่ยนอาร์กิวเมนต์ส่วนใหญ่เป็นกรณีการใช้งานเฉพาะของพวกเขา
ตรวจสอบให้แน่ใจว่า name_to_nickname_dict
และ name_to_email_dict
มีคีย์เดียวกัน
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')