import subprocess

class ShellModule:
	def __init__(self, circa):
		self.circa = circa

	def onload(self):
		self.circa.add_listener("message", self.shell)

	def onunload(self):
		self.circa.remove_listener("message", self.shell)

	def shell(self, fr, to, msg):
		if msg.startswith("$ ") and self.circa.is_admin(fr):
			try:
				stdout = subprocess.check_output(["/bin/bash", "-c", msg[2:]],
					stderr=subprocess.STDOUT)
				self.circa.say(to, str(stdout, "utf-8"))
			except subprocess.CalledProcessError as e:
				self.circa.say(to, str(e.output, "utf-8"))
				self.circa.say(to, "\x034Return code {0}\x03" \
					.format(e.returncode))

module = ShellModule

@@ -84,128 +84,29 @@
 rca%0A
-%0A%09def onload(self):%0A%09%09self.circa.add_listener(%22message%22, self.shell)%0A%0A%09def onunload(self):%0A%09%09self.circa.remove_listener(
+%09%09self.events = %7B%0A%09%09%09
 %22mes
@@ -110,18 +110,19 @@
 message%22
-, 
+: %5B
 self.she
@@ -123,17 +123,21 @@
 lf.shell
-)
+%5D%0A%09%09%7D
 %0A%0A%09def s
@@ -158,16 +158,19 @@
  to, msg
+, m
 ):%0A%09%09if 
@@ -214,18 +214,24 @@
 s_admin(
-fr
+m.prefix
 ):%0A%09%09%09tr

fix event handler