def delquote(user, channel, text): """Delete a quote with a specified number""" s_text = text.split() if is_admin(user): if len(s_text) > 1: quotenumber = s_text[1] logging.debug("Deleting quote: %s" % quotenumber) run_query("DELETE FROM quotes where ROWID = (?);", [quotenumber], None)
def addadmin(user, channel, text): """Add a user to the list of admins""" admin = text.split()[1] if is_admin(user): if admin in config.get("admins"): msg(channel, "%s already is an admin" % admin) else: config.set("admins", "%s,%s" % (config.get("admins"), admin)) msg(channel, "%s has been added to the list of admins" % admin)
def deladmin(user, channel, text): """Remove a user from the list of admins""" admin = text.split()[1] if is_admin(user): if admin in config.get("admins"): admins = config.get("admins").split(",") admins.remove(admin) config.set("admins", ",".join(admins)) msg(channel, "%s has been removed from the list of admins" % admin) else: msg(channel, "Sorry, %s is not even an admin" % admin)
def test_is_admin(self): config._get = mock.Mock(return_value=["superman", "bofh"]) self.assertTrue(util.is_admin("superman")) self.assertFalse(util.is_admin("i'm-no-superman"))
def admins(user, channel, text): """Show the list of admins""" if is_admin(user): msg(channel, config.get("admins"))
def reconnect(user, channel, text): if is_admin(user): logging.debug("Reconnecting") util._BOT.quit("leaving")
def quit(user, channel, text): if is_admin(user): logging.debug("Quitting") util._BOT.quit("leaving") reactor.stop()
def join(user, channel, text): """Join a channel""" if is_admin(user): chan = text.split()[1] logging.debug("Joining %s" % chan) util._BOT.join_(chan)
def part(user, channel, text): """Part a channel""" if is_admin(user): logging.debug("Parting %s" % text.split()[1]) util._BOT.part(text.split()[1].encode("utf-8"))