diff --git a/plugins/mute.py b/plugins/mute.py index 15dc80b..0693e9c 100644 --- a/plugins/mute.py +++ b/plugins/mute.py @@ -1,11 +1,35 @@ -""" +''' +# mute plugin by lukeroge and neersighted from util import hook +def mute(chan, db): + db.execute("create table if not exists mute(channel, activated)") + db.execute("insert or replace into mute(channel, activated) values(?, ?)", (chan, 1)) + db.commit() + +def unmute(chan, db): + db.execute("create table if not exists mute(channel, activated)") + db.execute("insert or replace into mute(channel, activated) values(?, ?)", (chan, 0)) + db.commit() + + +def is_muted(chan, db): + indb = db.execute("select activated from mute where channel=lower(?)", [chan]).fetchone(); + if indb == 0: + if activated == 1: + return True + else: + return False + else: + db.execute("insert or replace into mute(channel, activated) values(?, ?)", (chan, "0")) + db.commit() + return False + @hook.sieve -def mutesieve(bot, input, func, kind, args): +def mutesieve(bot, input, func, kind, args, db): if kind == "event": return input - if input.chan : + if is_muted(input.chan,input.conn.db): if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute": return input else: @@ -16,9 +40,12 @@ def mutesieve(bot, input, func, kind, args): def mute(inp, input=None, db=None): ".mute -- Mutes the bot in . If no channel is specified, it is muted in the current channel." if inp: - input.chan = inp + channel = inp + else: + channel = input.chan + if input.nick in input.bot.config["admins"]: - + mute(channel, db) input.notice("Muted") else: input.notice("Only bot admins can use this command!") @@ -27,13 +54,16 @@ def mute(inp, input=None, db=None): def unmute(inp, input=None, db=None): ".unmute -- Unmutes the bot in . If no channel is specified, it is unmuted in the current channel." if inp: - input.chan = inp + channel = inp + else: + channel = input.chan + if input.nick in input.bot.config["admins"]: - if : + if is_muted(channel, db): input.notice("Already muted!") else: - + mute(channel, db) input.notice("Muted") else: input.notice("Only bot admins can use this command!") -""" +''' \ No newline at end of file