├── .gitignore ├── README.md ├── intro.py └── settings.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.csv 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | introbot 2 | ======== 3 | 4 | Introbot is a quick python script to write an introductory e-mail between n parties. 5 | 6 | To use, edit `settings.py` and swap in your info. 7 | 8 | add a person 9 | ------------ 10 | 11 | Add a person with the `-a` switch. A person has a nickname, a firstname, and a description. 12 | 13 | For example: 14 | 15 | python intro.py -a hilary "Hilary thinks you should write scripts to do things instead of just doing them." 16 | 17 | If the nickname that you want to use is the same as their first name, that's it. If you want to use a different nickname, just specify all three in order (nickname, name, and description): 18 | 19 | python intro.py -a mason Hilary "Hilary thinks..." 20 | 21 | voila! 22 | 23 | write an intro 24 | -------------- 25 | 26 | To create an intro, just give the nicknames of the people you would like to introduce. 27 | 28 | python intro.py hilary pete 29 | 30 | The script will generate the intro, print it to STDOUT, and, on a Mac, copy it to your clipboard. Paste it into your favorite e-mail client and take a dramatic sip of coffee. 31 | 32 | You can also create an intro with a custom message: 33 | 34 | python intro.py hilary pete -m "You both love sculpture, you should definitely find a time to talk." 35 | 36 | disclaimers 37 | ----------- 38 | 39 | This is how my brain organizes people and introductions, I have no idea if it'll work for you. I'd love ideas to make this better! 40 | -------------------------------------------------------------------------------- /intro.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import subprocess 3 | import csv 4 | from optparse import OptionParser 5 | 6 | import settings 7 | 8 | 9 | def load_people(filename="people.csv"): 10 | parsed_people = {} 11 | with open(filename) as r: 12 | people = csv.reader(r) 13 | for person in people: 14 | parsed_people[person[0]] = [person[1], person[2]] 15 | if not person[1]: 16 | parsed_people[person[0]][0] = person[0].title() 17 | return parsed_people 18 | 19 | 20 | def save_person(nick, desc, name=None, filename="people.csv"): 21 | with open(filename, 'a') as csvfile: 22 | w = csv.writer(csvfile) 23 | w.writerow([nick, name, desc]) 24 | 25 | 26 | def write_introduction(people, message): 27 | i = " & ".join([v[0] for n, v in people.items()]) + ", please meet.\n\n" 28 | i += "\n\n".join([v[1] for n, v in people.items()]) 29 | if message: 30 | i += "\n\n" + message 31 | else: 32 | i += "\n\n" + settings.closing 33 | i += "\n\n" + settings.valediction + ",\n\n" + settings.name 34 | return i 35 | 36 | 37 | if __name__ == '__main__': 38 | parser = OptionParser() 39 | parser.add_option("-a", "--add", dest="add", action="store_true") 40 | parser.add_option("-m", "--message", dest="message", default=False, action="store") 41 | (options, args) = parser.parse_args() 42 | 43 | if options.add: # we're adding a new person 44 | if len(args) == 2: 45 | save_person(args[0], args[1]) 46 | else: 47 | save_person(args[0], args[2], args[1]) 48 | 49 | else: # write the intro 50 | try: 51 | people = load_people() 52 | except(FileNotFoundError): 53 | print("No people!") 54 | sys.exit() 55 | 56 | introducing = {} # get the people data from the set 57 | for person in args: 58 | try: 59 | introducing[person] = people[person] 60 | except KeyError as e: 61 | print("Missing person %s in your data!" % e) 62 | sys.exit() 63 | 64 | msg = write_introduction(introducing, options.message) 65 | print(msg) 66 | p = subprocess.Popen(["pbcopy"], stdin=subprocess.PIPE) 67 | p.communicate(msg.encode('utf-8')) 68 | -------------------------------------------------------------------------------- /settings.py: -------------------------------------------------------------------------------- 1 | name = "Hilary" 2 | valediction = "Cheers" 3 | closing = "I think you'll find quite a bit to talk about." 4 | --------------------------------------------------------------------------------