Created
December 12, 2012 20:40
-
-
Save derveloper/4271419 to your computer and use it in GitHub Desktop.
wichtelscript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
WICHTEL = [] | |
mailtpl = `cat mailtpl.txt` | |
File.open('wichtel.txt', 'r').each do |f| | |
WICHTEL << f.strip | |
end | |
WICHTEL = WICHTEL.shuffle.shuffle | |
WICHTEL.each_with_index do |w,i| | |
pair = [w, i == WICHTEL.size-1 ? WICHTEL[0] : WICHTEL[i+1] ] | |
sender_mail = pair[0].split(',')[0] | |
sender_name = pair[0].split(',')[1] | |
recipient_mail = pair[1].split(',')[0] | |
recipient_name = pair[1].split(',')[1] | |
mail = mailtpl.gsub(/USER/, recipient_name) | |
mail = mail.gsub(/To: .*/,"To: #{sender_mail}") | |
`echo "#{mail}" > tickets/#{sender_name}.txt` | |
`ssmtp #{sender_mail} < tickets/#{sender_name}.txt` | |
`rm tickets/#{sender_name}.txt` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment