Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - import xchat, re, urllib, time, subprocess, sys, signal
 - from subprocess import check_output
 - __module_name__="guileInterface"
 - __module_version__="0.1"
 - __module_description__ = "An interface to the guile program"
 - class TimeoutException(Exception):
 - pass
 - def guileCall(word, word_eol, userdata):
 - def thandler(signum, frame):
 - raise TimeoutException()
 - text = word[1].split()
 - if text[0] == "'s":
 - t = " ".join(text[1:])
 - old_handler = signal.signal(signal.SIGALRM, thandler)
 - signal.alarm(5)
 - try:
 - output = check_output(
 - ["guile","-l","/home/jsvlrt/.xchat2/std.scm","-c",t],
 - stderr=subprocess.STDOUT
 - )
 - except subprocess.CalledProcessError as e:
 - output = e.output
 - finally:
 - signal.signal(signal.SIGALRM, old_handler)
 - signal.alarm(0)
 - for line in output.split("\n"):
 - if(line[:3] != ";;;"):
 - xchat.command("say " + line)
 - hook3 = xchat.hook_print("Your Message",guileCall)
 - def cleanupGuile(word, word_eol, userdata):
 - xchat.unhook(hook3)
 - xchat.hook_command("cguile",cleanupGuile)
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment