ref: ebdda171d992ee83085c72b932bb69421c54e917
bin/growl-message.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
#!/usr/bin/env python import sys import subprocess def notify(message, title): cmd = "terminal-notifier -message '%s' -title '%s' -sender com.apple.Terminal >> /dev/null 2>&1" % (message, title) subprocess.call(cmd, shell=True) def main(message, title): if message.startswith('#'): return if 'honzakral' in message: return if 'honza has joined' in message: return if 'honza:' in message: # Someone talking to me in the room # e.g. # honza: in room who, where = title.split(' ') notify(message, '%s in %s' % (who, where)) return elif message.startswith('honza :'): # Someone talking to me in a private message # e.g. # honza :hey man who, _ = title.split(' ') notify(message, '%s said' % who) return elif 'honza' in message: notify(message, 'honza mentioned') return else: return if __name__ == '__main__': if len(sys.argv) == 3: main(sys.argv[1], sys.argv[2]) |