2022-10-21 22:09:55 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
client = None
|
|
|
|
|
|
|
|
def mod_init(cl):
|
|
|
|
global client
|
|
|
|
client = cl
|
|
|
|
|
|
|
|
def action(msg):
|
|
|
|
return '%cACTION %s%c' % (1, msg, 1)
|
|
|
|
|
|
|
|
|
|
|
|
def execbuf(nick):
|
|
|
|
if 'edit' not in sys.modules:
|
|
|
|
return
|
|
|
|
b = sys.modules['edit'].bufs
|
|
|
|
if nick not in b:
|
|
|
|
return
|
|
|
|
try:
|
|
|
|
exec('\n'.join(b[nick].buf))
|
|
|
|
except Exception, e:
|
|
|
|
client.sendto(nick, 'ERROR: %s' % str(e))
|
|
|
|
|
|
|
|
|
|
|
|
def on_pubchat(who, chan, msg):
|
|
|
|
if msg[:len(client.nick)] == client.nick:
|
|
|
|
nmsg = msg.split(':')[1:]
|
|
|
|
nargs = nmsg[0].split()
|
|
|
|
if len(nargs) < 1: return
|
|
|
|
if len(nmsg) > 1:
|
|
|
|
nargs = nargs + [':' + ':'.join(nmsg[1:])]
|
|
|
|
ncmd = nargs[0]
|
|
|
|
|
|
|
|
if ncmd == "raw":
|
|
|
|
client.send(' '.join(nargs[1:]))
|
|
|
|
|
|
|
|
if ncmd == "execbuf":
|
|
|
|
execbuf(who.split('!')[0])
|
|
|
|
|
|
|
|
if ncmd == "exec":
|
|
|
|
try:
|
|
|
|
exec(' '.join(nargs[1:]))
|
|
|
|
except Exception, e:
|
|
|
|
client.sendto(chan, 'ERROR: %s' % str(e))
|
|
|
|
|
|
|
|
|
|
|
|
def on_privchat(who, msg):
|
|
|
|
on_pubchat(who, who, client.nick + ': ' + msg)
|
|
|
|
|