33 lines
726 B
Python
33 lines
726 B
Python
|
import subprocess
|
||
|
|
||
|
class TestBot:
|
||
|
def __init__(self):
|
||
|
pass
|
||
|
def say(self,chan,message):
|
||
|
print(message)
|
||
|
|
||
|
class NFile:
|
||
|
def __init__(self,bot,chan):
|
||
|
self.bot = bot
|
||
|
self.chan = chan
|
||
|
def write(self,c):
|
||
|
self.bot.say(self.chan,c)
|
||
|
|
||
|
class UrnPlugin:
|
||
|
def __init__(self,bot):
|
||
|
self.bot = bot
|
||
|
|
||
|
def onMessage(self,chan,nick,message):
|
||
|
parts = message.strip().split()
|
||
|
if parts[0]!="!urn":
|
||
|
return
|
||
|
with open("te.urn","w") as f:
|
||
|
f.write(" ".join(parts[1:]))
|
||
|
subprocess.call("urn te.urn",shell=True)
|
||
|
t = subprocess.Popen("lua out.lua",shell=True,stdout=subprocess.PIPE)
|
||
|
out = t.communicate()[0]
|
||
|
lines = [l.strip() for l in out.strip().split("\n")]
|
||
|
for line in lines:
|
||
|
if line:
|
||
|
self.bot.say(chan,line)
|