making progress on mute
This commit is contained in:
parent
39147ef498
commit
0cbb886ae9
1 changed files with 39 additions and 9 deletions
|
@ -1,11 +1,35 @@
|
||||||
"""
|
'''
|
||||||
|
# mute plugin by lukeroge and neersighted
|
||||||
from util import hook
|
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
|
@hook.sieve
|
||||||
def mutesieve(bot, input, func, kind, args):
|
def mutesieve(bot, input, func, kind, args, db):
|
||||||
if kind == "event":
|
if kind == "event":
|
||||||
return input
|
return input
|
||||||
if input.chan <is_muted>:
|
if is_muted(input.chan,input.conn.db):
|
||||||
if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute":
|
if input.command == "PRIVMSG" and input.lastparam[1:] == "unmute":
|
||||||
return input
|
return input
|
||||||
else:
|
else:
|
||||||
|
@ -16,9 +40,12 @@ def mutesieve(bot, input, func, kind, args):
|
||||||
def mute(inp, input=None, db=None):
|
def mute(inp, input=None, db=None):
|
||||||
".mute <channel> -- Mutes the bot in <channel>. If no channel is specified, it is muted in the current channel."
|
".mute <channel> -- Mutes the bot in <channel>. If no channel is specified, it is muted in the current channel."
|
||||||
if inp:
|
if inp:
|
||||||
input.chan = inp
|
channel = inp
|
||||||
|
else:
|
||||||
|
channel = input.chan
|
||||||
|
|
||||||
if input.nick in input.bot.config["admins"]:
|
if input.nick in input.bot.config["admins"]:
|
||||||
<mute_bot>
|
mute(channel, db)
|
||||||
input.notice("Muted")
|
input.notice("Muted")
|
||||||
else:
|
else:
|
||||||
input.notice("Only bot admins can use this command!")
|
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):
|
def unmute(inp, input=None, db=None):
|
||||||
".unmute <channel> -- Unmutes the bot in <channel>. If no channel is specified, it is unmuted in the current channel."
|
".unmute <channel> -- Unmutes the bot in <channel>. If no channel is specified, it is unmuted in the current channel."
|
||||||
if inp:
|
if inp:
|
||||||
input.chan = inp
|
channel = inp
|
||||||
|
else:
|
||||||
|
channel = input.chan
|
||||||
|
|
||||||
if input.nick in input.bot.config["admins"]:
|
if input.nick in input.bot.config["admins"]:
|
||||||
if <ismuted>:
|
if is_muted(channel, db):
|
||||||
input.notice("Already muted!")
|
input.notice("Already muted!")
|
||||||
else:
|
else:
|
||||||
<mute_bot>
|
mute(channel, db)
|
||||||
input.notice("Muted")
|
input.notice("Muted")
|
||||||
else:
|
else:
|
||||||
input.notice("Only bot admins can use this command!")
|
input.notice("Only bot admins can use this command!")
|
||||||
"""
|
'''
|
Reference in a new issue