Jabber/XMPP conference bot & framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
brathuhn/modules/active/cowsay.py

24 lines
685 B

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)