secret santa
1.0.0
给出了电子邮件收件人的文件,这将随机对匹配项进行随机进行,并将每个匹配项发送给每个匹配项。该应用程序保证没有人获得自己,但是所有其他组合都被认为有效。请注意,除非明确告知要这样做,否则该程序不会向操作员表示匹配。
任务反复改组,直到没有人自己。虽然这可能会永远持续,但是除非您只提供一个参与者,否则它不会。虽然这意味着您将在圣诞节期间很孤单,但您的电脑旋转会为您的房屋温暖,试图将一张卡的两张甲板放在不同的订单中。
一旦建立了分配的电子邮件,我们的工作就完成了。返回练习颂歌,再一次测试蛋酒食谱,以确保。
除了我们正在用古老而废弃的图书馆格式化电子邮件的事实外,这个应用程序非常过分建立。它能够在8个散装和大约2秒后在100k记录上生成有效的匹配设置。不过,发送100k电子邮件显然需要一段时间!
go get
安装依赖项(Logrus,Urfave.cli,Gophermail)go build
以编译secret-santa
可执行./secret-santa
运行它secret-santa
从包含JSON文件的参与者列表中获取其参与者列表。每个参与者都会成为带有name
和address
参数的数组中的成员。这默认为data/people.json
,但是您可以使用--source-file
参数使用所喜欢的任何路径。请参阅示例以获取详细信息。
您还必须通过创建模板文件来自定义电子邮件主体。该文件支持{{.From}}
和{{.To}}
这是从参与者JSON文件中删除的名称。这默认为data/email.template
,但是您可以使用--template-file
参数使用您喜欢的任何路径。请参阅示例以获取详细信息。
NAME:
secret-santa - Secret Santa Emailer!
USAGE:
secret-santa [global options] command [command options] [arguments...]
VERSION:
0.0.1
COMMANDS:
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--from-name value Display name for sender (default: "Secret Santa Robotic Elf")
--from-address value Email address to send from (required unless dry run)
--from-password value Password for the from-address (e.g. gmail password)
--smtp-host value Host to send to (default: "smtp.gmail.com")
--smtp-port value Port to send to (default: 587)
--source-file value JSON file containing an array of name/address objects (default: "data/people.json")
--template-file value Text file containing a template used for the email body (default: "data/email.template")
--subject value Email subject (default: "Shhhh! It's your Secret Santa assignment")
--show-matches Print the pairings out when sending
--dry-run Do not send. Implies --show-matches
--help, -h show help
--version, -v print the version
$ ./secret-santa --dry-run --source-file data/example.json
INFO[0000] Shuffling...
INFO[0000] Shuffling...
INFO[0000] Shuffling...
INFO[0000] Shuffling...
INFO[0000] Shuffling...
INFO[0000] match from="Dee Dee" to=Tommy
INFO[0000] match from=Ringo to="Dee Dee"
INFO[0000] match from=George to=Paul
INFO[0000] match from=Joey to=George
INFO[0000] match from=Marky to=Ringo
INFO[0000] match from=Paul to=Marky
INFO[0000] match from=John to=Joey
INFO[0000] match from=Tommy to=John
$ ./secret-santa --from-address "[email protected]" --from-password "your_pass" --source-file data/people.json
INFO[0000] Shuffling...
INFO[0000] Shuffling...
INFO[0001] sent
INFO[0002] sent
INFO[0002] sent
INFO[0003] sent
INFO[0004] sent
INFO[0005] sent
INFO[0006] sent
INFO[0007] sent
INFO[0008] sent
INFO[0009] sent