import brathuhn, subprocess def cowsay(msg,args): cowfile="default" text="" if( len(args)==2 ): text=args[1] elif( len(args)==4 and args[1]=="-f"): cowfile=args[2] text = args[3] else: brathuhn.sendMsg(brathuhn.ROOM,"Usage: "+args[0]+" [-l] [-f cowfile] text",'groupchat') return try: p=subprocess.Popen(["/usr/games/cowsay","-f",cowfile,text],stdout=subprocess.PIPE) p.wait() txt=p.stdout.read() for line in txt.split('\n'): #brathuhn.sendStyledMsg(brathuhn.ROOM,line,'groupchat',) brathuhn.sendMonoMsg(brathuhn.ROOM,line,'groupchat') except subprocess.CalledProcessError: pass brathuhn.addCommand("cowsay","Usage: !cowsay [cowfile] text",cowsay)