diff --git a/core/main.py b/core/main.py index 7d0b42a..7af9934 100644 --- a/core/main.py +++ b/core/main.py @@ -19,41 +19,23 @@ class Input(object): self.chan = paraml[0] if self.chan == conn.nick: self.chan = nick - elif command =='JOIN': - self.chan = msg - -class FakeBot(object): - - def __init__(self, bot, conn, input, func): - self.bot = bot - self.conn = conn - self.persist_dir = bot.persist_dir - self.input = input - self.msg = conn.msg - self.cmd = conn.cmd - self.join = conn.join - self.func = func - self.doreply = True - self.chan = input.chan - def say(self, msg): self.conn.msg(self.chan, msg) def reply(self, msg): - self.say(self.input.nick + ': ' + msg) + self.say(self.nick + ': ' + msg) + + +def run(func, input): + ac = func.func_code.co_argcount + if ac == 2: + out = func(bot, input) + elif ac == 1: + out = func(input.inp) + if out is not None: + input.reply(unicode(out)) - def run(self): - ac = self.func.func_code.co_argcount - if ac == 2: - out = self.func(self, self.input) - elif ac == 1: - out = self.func(self.input.inp) - if out is not None: - if self.doreply: - self.reply(unicode(out)) - else: - self.say(unicode(out)) def main(conn, out): for csig, func, args in bot.plugs['tee']: @@ -72,4 +54,4 @@ def main(conn, out): break if input == None: continue - thread.start_new_thread(FakeBot(bot, conn, input, func).run, ()) + thread.start_new_thread(run, (func, input)) diff --git a/plugins/goonsay.py b/plugins/goonsay.py index 794feaa..7cd3623 100644 --- a/plugins/goonsay.py +++ b/plugins/goonsay.py @@ -3,6 +3,6 @@ from util import hook #Scaevolus: factormystic if you commit a re-enabled goonsay I'm going to revoke your commit access #@hook.command def goonsay(bot, input): - bot.say(' __________ /') - bot.say('(--[. ]-[ .] /') - bot.say('(_______o__)') + input.say(' __________ /') + input.say('(--[. ]-[ .] /') + input.say('(_______o__)') diff --git a/plugins/log.py b/plugins/log.py index 6bd69db..8629cc9 100644 --- a/plugins/log.py +++ b/plugins/log.py @@ -18,7 +18,7 @@ timestamp_format = '%H:%M:%S' formats = {'PRIVMSG': '<%(nick)s> %(msg)s', 'PART': '-!- %(nick)s [%(user)s@%(host)s] has left %(chan)s', - 'JOIN': '-!- %(nick)s [%(user)s@%(host)s] has joined %(chan)s', + 'JOIN': '-!- %(nick)s [%(user)s@%(host)s] has joined %(param0)s', 'MODE': '-!- mode/%(chan)s [%(param_tail)s] by %(nick)s', 'KICK': '-!- %(param1)s was kicked from %(chan)s by %(nick)s [%(msg)s]', 'TOPIC': '-!- %(nick)s changed the topic of %(chan)s to: %(msg)s', diff --git a/plugins/misc.py b/plugins/misc.py index 7b39ec9..9943d45 100644 --- a/plugins/misc.py +++ b/plugins/misc.py @@ -6,7 +6,7 @@ def rejoin(bot, input): if input.command == 'KICK': if input.paraml[1] == input.conn.nick: if input.paraml[0] in input.conn.channels: - bot.join(input.paraml[0]) + input.conn.join(input.paraml[0]) if input.command == 'INVITE': - bot.join(input.inp) + input.conn.join(input.inp) diff --git a/plugins/remember.py b/plugins/remember.py index 23fd1e3..4d2904e 100644 --- a/plugins/remember.py +++ b/plugins/remember.py @@ -49,9 +49,9 @@ def remember(bot, input): tail = tail.strip() low = head.lower() if low not in memory[filename]: - bot.reply("done.") + input.reply("done.") else: - bot.reply('forgetting that "%s", remembering this instead.' % + input.reply('forgetting that "%s", remembering this instead.' % memory[filename][low]) memory[filename][low] = input.inp.strip() save_memory(filename, memory[filename]) @@ -72,7 +72,7 @@ def forget(bot, input): return "I don't know about that." if not hasattr(input, 'chan'): return "I won't forget anything in private." - bot.say("Forgot that %s" % memory[filename][low]) + input.say("Forgot that %s" % memory[filename][low]) del memory[filename][low] save_memory(filename, memory[filename]) @@ -86,4 +86,4 @@ def question(bot, input): word = input.inp.split()[0].lower() if word in memory[filename]: - bot.say("%s" % memory[filename][word]) + input.say("%s" % memory[filename][word]) diff --git a/plugins/tell.py b/plugins/tell.py index ed8f28b..0d54bbc 100644 --- a/plugins/tell.py +++ b/plugins/tell.py @@ -39,7 +39,7 @@ def tellinput(bot, input): if more: reply += " (+%(more)d more, to view say .showtells)" % {"more": more} - bot.reply(reply) + input.reply(reply) command = "delete from tell where id = ?" cursor.execute(command, (tell[0], )) @@ -61,15 +61,15 @@ def showtells(bot, input): if(len(tells) > 0): for tell in tells: reltime = timesince.timesince(datetime.fromtimestamp(tell[3])) - bot.msg(input.nick, '%(teller)s said %(reltime)s ago: %(quote)s' % - {'teller': tell[1], 'quote': tell[2], 'reltime': reltime}) + input.msg(input.nick, '%(teller)s said %(time)s ago: %(quote)s' % + {'teller': tell[1], 'quote': tell[2], 'time': reltime}) command = "delete from tell where id = ?" cursor.execute(command, (tell[0], )) conn.commit() else: - bot.msg(input.nick, "You have no pending tells.") + input.msg(input.nick, "You have no pending tells.") conn.close() diff --git a/plugins/weather.py b/plugins/weather.py index da4b33a..98bb9a1 100644 --- a/plugins/weather.py +++ b/plugins/weather.py @@ -60,8 +60,8 @@ def weather(bot, input): info['high'] = w.find('forecast_conditions/high').get('data') info['low'] = w.find('forecast_conditions/low').get('data') - bot.reply('%(city)s: %(condition)s, %(temp_f)sF/%(temp_c)sC (H:%(high)sF'\ - ', L:%(low)sF), %(humidity)s, %(wind_condition)s.' % info) + input.reply('%(city)s: %(condition)s, %(temp_f)sF/%(temp_c)sC (H:%(high)s'\ + 'F, L:%(low)sF), %(humidity)s, %(wind_condition)s.' % info) if loc != stalk.get(nick, ''): with lock: