import logging
import subprocess

from lala.util import command,msg

@command
def fortune(user, channel, text):
    """Show a random, hopefully interesting, adage"""
    try:
        p = subprocess.Popen(["fortune", "fortunes"],
                stdout=subprocess.PIPE)
        result = p.communicate()[0]
        msg(channel,"%s: %s" % (user, result.replace("\n","")))
    except OSError, e:
        logging.error("Error while calling fortune: %s" % e)

@@ -446,8 +446,398 @@
 s%22 %25 e)%0A
+%0A@command%0Adef ofortune(user, channel, text):%0A    %22%22%22Show a random, hopefully interesting, offensive adage%22%22%22%0A    try:%0A        p = subprocess.Popen(%5B%22fortune%22, %22-o%22%5D,%0A                stdout=subprocess.PIPE)%0A        result = p.communicate()%5B0%5D%0A        msg(channel,%22%25s: %25s%22 %25 (user, result.replace(%22%5Cn%22,%22%22)))%0A    except OSError, e:%0A        logging.error(%22Error while calling fortune: %25s%22 %25 e)%0A

add a command for fortune -o