MinoMino / minqlbot

An administration tool for the Quake Live client, extensible with plugins.
GNU General Public License v3.0
26 stars 10 forks source link

Auto Mute #6

Closed BarelyMiSSeD closed 9 years ago

BarelyMiSSeD commented 9 years ago

I added a plugin called mute.py and put it in the config.cfg plugin list. I can get most of the stuff to work but I can't get the bot to execute the auto mute on player connect. Here is the contents of the mute.py file:


import minqlbot import time

class mute(minqlbot.Plugin): def init(self): super().init() self.add_hook("player_connect", self.handle_player_connect, minqlbot.PRI_NORMAL) self.add_command("mute", self.cmd_mute, 1, usage="") self.add_command("unmute", self.cmd_unmute, 1, usage="") self.add_command("addmute", self.cmd_addmute, 2) self.add_command("delmute", self.cmd_delmute, 2)

    #self.mute_timer = None

def handle_player_connect(self, player):
    self.delay(5, self.check_mute(player))

def cmd_mute(self, player, msg, channel):
    if len(msg) < 2:
        return minqlbot.RET_USAGE

    n = self.find_player(msg[1])
    if n:
        self.mute(n)
    else:
        channel.reply("^7I do not know '{}'.".format(msg[1]))

def cmd_unmute(self, player, msg, channel):
    if len(msg) < 2:
        return minqlbot.RET_USAGE

    n = self.find_player(msg[1])
    if n:
        self.unmute(n)
    else:
        channel.reply("^7I do not know '{}'.".format(msg[1]))

def cmd_addmute(self, player, msg, channel):
    if len(msg) < 1:
        return
    name = msg[1].lower()
    #Permission level 5 players not auto mutable
    if self.has_permission(name, 5):
        channel.reply("^6{}^7 has permission level 5 and cannot be auto muted.".format(name))
        return
    else:
        c = self.db_query("SELECT * FROM Mutes WHERE name=?", name)
        if not c.fetchone():
            self.db_query("INSERT INTO Mutes VALUES(?, 0, 0, 0, 0)", name)
            self.db_commit()
        self.db_query("UPDATE Mutes SET active=1 WHERE name=?", name)
        self.db_commit()
        channel.reply("^6{} ^7has been added to the Auto Mute list.".format(name))
        n = self.find_player(msg[1])
        if n:
            self.mute(n)

def cmd_delmute(self, player, msg, channel):
    if len(msg) < 1:
        return
    else:
        name = msg[1].lower()
        c = self.db_query("SELECT * FROM Mutes WHERE name=?", name)
        delmute = False
        for row in c:
            if row[1]: # if active Mute
                self.db_query("UPDATE Mutes SET active=0 WHERE name=? AND issued=?", row[0], row[2])
                self.db_commit()
                delmute = True
        if delmute:
            channel.reply("^6{}^7 has been removed form the auto mute list.".format(name))
            n = self.find_player(msg[1])
            if n:
                self.unmute(n)
        else:
            channel.reply("^7No active auto mutes on ^6{}^7 found.".format(name))

def check_mute(self, player, channel):
    channel.reply("Start")
    config = minqlbot.get_config()
    channel.reply("0")
    if "Mute" in config and "AutoMute" in config["Mute"]:
        auto_pass = config["Mute"].getboolean("AutoMute")
        channel.reply("1")
        if auto_pass:
            channel.reply("2")
            name = self.clean_name(player).lower()
            c = self.db_query("SELECT * FROM Mutes WHERE name=?", name)
            for row in c:
                if name == row["name"] and row["active"]:
                    channel.reply("3")
                    self.mute(name)
                    channel.reply("^6{}^7 has been muted. Msg BarelyMiSSeD or xXThatDudeXx if this is in error.".format(player))      

The addmute and delmute seem to be working but when a player connects nothing happens. I put the commands "channel.reply("1")" and the ones like it in to see where it was getting in the code, but I am not seeing any messages at all when a player in the mutes database is added, not even the "Start" message. Any ideas?