- # regrettably, these (and anything else with special triggers)
- # must be special-cased, which is aesthetically unsatisfying.
-
- # karma: up
- if command.endswith("++"):
- self.karmaup(cmd)
- # karma: down
- if command.endswith("--"):
- self.karmadown(cmd)
-
- # and in the general case (this is slightly magical)
- if command.lower() in config.commands.keys():
- config.commands[command](*args)
- # else do nothing.
-
- # What this _means_ is: you write a
- # function(bot, cmd, nick, conn, public), where bot is the bot class
- # (ie self here), and drop it in commands.py; then add a trigger command
- # to config.py for it, in the dictionary "commands", and it will
- # just start working on bot restart or config reload.
-
- # This is, IMO, quite nifty. :)
-
- # And now the karma commands, as these pretty much have to be here :(
- # increment karma
- def karmaup(self, cmd):
- if self.karma.dict.has_key(cmd.split()[0][:-2]):
- self.karma.dict[cmd.split()[0][:-2]] += 1
- else:
- self.karma.dict[cmd.split()[0][:-2]] = 1
- #decrement karma
- def karmadown(self, cmd):
- if self.karma.dict.has_key(cmd.split()[0][:-2]):
- self.karma.dict[cmd.split()[0][:-2]] -= 1
- else:
- self.karma.dict[cmd.split()[0][:-2]] = -1
-
+ # Convenience function - reply to a public message publicly, or
+ # a private message privately
+ def automsg(self,public,nick,msg):
+ if public:
+ self.connection.privmsg(self.channel,msg)
+ else:
+ self.connection.notice(nick, msg)