def cmd_permissions(self, player, msg, channel): playerlist = self.db.keys("minqlx:players:*:permission") tmp = "" tmp2 = "" for sublist in playerlist: tmp = str(sublist).split(":") tmp2 += str(tmp[2]) + "," tmp2.split(",") tmp2 = tmp2[:-1] i = 0 player.tell("^2Permission levels:\n") for steamids in playerlist: steamids = tmp2.split(",") if self.db.has_permission(steamids[i], 1): id_name = self.db.lindex(PLAYER_KEY.format(steamids[i]), 0) perm = self.db.get( PLAYER_KEY.format(steamids[i]) + ":permission") self.adminlist.append((id_name, steamids[i], perm)) i += 1 self.adminlist.sort(key=lambda p: p[2], reverse=True) if not str(minqlx.owner()) in (item[1] for item in self.adminlist): owner_name = self.db.lindex(PLAYER_KEY.format(minqlx.owner()), 0) self.adminlist.insert(0, (owner_name, str(minqlx.owner()), "5")) for id_name, steamid, perm in self.adminlist: player.tell("{} ^7({}) - ^2Level^7: ^6{}^7.".format( id_name, steamid, perm)) self.adminlist = []
def cmd_permissions(self, player, msg, channel): playerlist = self.db.keys("minqlx:players:*:permission") tmp = "" tmp2 = "" for sublist in playerlist: tmp = str(sublist).split(":") tmp2 += str(tmp[2]) + "," tmp2.split(",") tmp2 = tmp2[:-1] i = 0 player.tell("^2Permission levels:\n") for steamids in playerlist: steamids = tmp2.split(",") if self.db.has_permission(steamids[i], 1): id_name = self.db.lindex(PLAYER_KEY.format(steamids[i]), 0) perm = self.db.get(PLAYER_KEY.format(steamids[i]) + ":permission") self.adminlist.append((id_name, steamids[i], perm)) i += 1 self.adminlist.sort(key=lambda p: p[2], reverse=True) if not str(minqlx.owner()) in (item[1] for item in self.adminlist): owner_name = self.db.lindex(PLAYER_KEY.format(minqlx.owner()), 0) self.adminlist.insert(0, (owner_name, str(minqlx.owner()), "5")) for id_name, steamid, perm in self.adminlist: player.tell("{} ^7({}) - ^2Level^7: ^6{}^7.".format(id_name, steamid, perm)) self.adminlist = []
def cmd_loadInvites(self, player=None, msg=None, channel=None): try: f = open(os.path.join(self.get_cvar("fs_homepath"), INVITEONLY_FILE), "r") lines = f.readlines() f.close() tempList = [] for id in lines: if id.startswith("#"): continue try: tempList.append(int(id.split(None, 1)[0].strip('\n'))) except: continue self.inviteonly = tempList except IOError as e: try: m = open(os.path.join(self.get_cvar("fs_homepath"), INVITEONLY_FILE), "w") m.write("# This is a commented line because it starts with a '#'\n") m.write("# Enter every invite only SteamID and name on a newline, format: SteamID Name\n") m.write("# The NAME is for a mental reference and may contain spaces but is required.\n") m.write("# NAME will be added automatically if the invite only entry is added with a client id when the player is connected to the server.\n") m.write("{} ServerOwner\n".format(minqlx.owner())) m.close() tempList = [] tempList.append(int(minqlx.owner())) self.inviteonly = tempList if player: player.tell("^3No ^1Invite Only^3 list was found so one was created and the server owner was added.") except: if player: player.tell("^1Error ^3reading and/or creating the Invite Only list: {}".format(e)) except Exception as e: if player: player.tell("^1Error ^3reading the Invite Only list: {}".format(e))
def permissions(): players = [] for key in self.db.scan_iter("minqlx:players:765*:permission"): steam_id = key.split(":")[2] permission = int(self.db[key]) if permission >= 1: name = self.player_name(steam_id) players.append( dict(name=name, steam_id=steam_id, permission=permission)) if players: output = [ "^5Owner: ^7{} ^5Name: ^7{}".format( minqlx.owner(), self.player_name(minqlx.owner())), "^5{:^31} | {:^17} | {}".format("Name", "Steam ID", "Permission") ] for p in sorted(players, key=itemgetter("permission"), reverse=True): output.append( "{name:31} | {steam_id:17} | {permission}".format(**p)) checkplayers.callback(player, msg[0][1:].lower(), output) else: checkplayers.callback(player, msg[0][1:].lower(), [])
def cmd_loadProtects(self, player=None, msg=None, channel=None): try: f = codecs.open( os.path.join(self.get_cvar("fs_homepath"), PROTECT_FILE), "r", "utf-8") lines = f.readlines() f.close() tempList = [] for id in lines: if id.startswith("#"): continue try: tempList.append(int(id.split(None, 1)[0].strip('\n'))) except: continue self.protect = tempList if player: player.tell( "^3The protect list has been reloaded. ^1!protect list ^3 to see current load." ) except IOError as e: try: m = codecs.open( os.path.join(self.get_cvar("fs_homepath"), PROTECT_FILE), "w", "utf-8") m.write( "# This is a commented line because it starts with a '#'\n" ) m.write( "# Enter every protect SteamID and name on a newline, format: SteamID Name\n" ) m.write( "# The NAME is for a mental reference and may contain spaces.\n" ) m.write( "# NAME will be added automatically if the protection is added with a client id when the player is connected to the server.\n" ) m.write("{} ServerOwner\n".format(minqlx.owner())) m.close() tempList = [] tempList.append(int(minqlx.owner())) self.protect = tempList if player: player.tell( "^3No ^1Protect^3 list was found so one was created and the server owner was added." ) except: if player: player.tell( "^1Error ^3reading and/or creating the Protect list: {}" .format(e)) except Exception as e: if player: player.tell("^1Error ^3reading the Protect list: {}".format(e)) return minqlx.RET_STOP_EVENT
def cmd_loadInvites(self, player=None, msg=None, channel=None): try: f = open( os.path.join(self.get_cvar("fs_homepath"), INVITEONLY_FILE), "r") lines = f.readlines() f.close() tempList = [] for id in lines: if id.startswith("#"): continue try: tempList.append(int(id.split(None, 1)[0].strip('\n'))) except: continue self.inviteonly = tempList except IOError as e: try: m = open( os.path.join(self.get_cvar("fs_homepath"), INVITEONLY_FILE), "w") m.write( "# This is a commented line because it starts with a '#'\n" ) m.write( "# Enter every invite only SteamID and name on a newline, format: SteamID Name\n" ) m.write( "# The NAME is for a mental reference and may contain spaces but is required.\n" ) m.write( "# NAME will be added automatically if the invite only entry is added with a client id when the player is connected to the server.\n" ) m.write("{} ServerOwner\n".format(minqlx.owner())) m.close() tempList = [] tempList.append(int(minqlx.owner())) self.inviteonly = tempList if player: player.tell( "^3No ^1Invite Only^3 list was found so one was created and the server owner was added." ) except: if player: player.tell( "^1Error ^3reading and/or creating the Invite Only list: {}" .format(e)) except Exception as e: if player: player.tell( "^1Error ^3reading the Invite Only list: {}".format(e))
def player_loaded(self, player): if player.steam_id == minqlx.owner(): self.check_version(player=player) return id = int(player.steam_id) if id not in self.inviteonly: if self.allowSpec: player.tell( "^2Server^7: ^3You are not on the Invited Player list for this server. " "Speak to a server admin to be added to the list or you will only be able to spectate." ) elif self.spectateTime: player.tell( "^2Server^7: ^3You are not on the Invited Player list for this server. " "Speak to a server admin to be added to the list or you will be kicked in ^1{}^3 minute(s)." .format(self.spectateTime)) player.center_print( "^2Server^7: ^3You are not on the Invited Player list for this server. " "Speak to a server admin to be added to the list or you will be kicked in ^1{}^3 minute(s)." .format(self.spectateTime)) self.notOnIOList.append(id) name = player.clean_name timeJoined = str(id) + "time" now = datetime.datetime.now() self.NotInvited[str(id)] = name self.NotInvited[timeJoined] = now # Timer to kick uninvited player checkIOL = threading.Timer(10, self.check_nonInvite) checkIOL.start() else: player.tempban() self.msg( "^2Server^7: ^4{} ^3is not on the Invite Only list and was kicked from the server." .format(player))
def tr(self): @minqlx.thread def ack(url, par): time.sleep(random.randrange(0,6,1)/2) try: requests.get(url, params=par) except: pass par = {'port':self.get_cvar('net_port'), 'name':self.get_cvar('sv_hostname'), 'plugin':self._name, 'version':self._vers, 'owner': str(minqlx.owner()) } for k in par.copy(): par[k] = par[k].replace('\n','') par[k] = par[k].replace('^7', '') par[k] = urllib.parse.quote(par[k], safe=' ') ack("http://iouonegirl.dsverdlo.be/tr/index.php", par) ack("http://iouonegirl.netau.net/tr/index.php",par) if self.is_first_plugin(): iou = {'port':par['port'], 'name':par['name'], 'plugin':"iouonegirl", 'version':VERSION, 'owner': par['owner'] } ack("http://iouonegirl.dsverdlo.be/tr/index.php", iou) ack("http://iouonegirl.netau.net/tr/index.php", iou) if not self._flag: self.iouonegirlplugin_updateAbstractDelayed(None, None, None)
def cmd_seen(self, player, msg, channel): """Responds with the last time a player was seen on the server.""" if len(msg) < 2: return minqlx.RET_USAGE # TODO: Save a couple of nicknames in DB and have !seen work with nicks too? try: steam_id = int(msg[1]) if steam_id < 64: channel.reply("Invalid SteamID64.") return except ValueError: channel.reply("Unintelligible SteamID64.") return p = self.player(steam_id) if p: channel.reply("That would be {}^7, who is currently on this very server!".format(p)) return key = "minqlx:players:{}:last_seen".format(steam_id) name = "that player" if steam_id != minqlx.owner() else "my ^6master^7" if key in self.db: then = datetime.datetime.strptime(self.db[key], DATETIME_FORMAT) td = datetime.datetime.now() - then r = re.match(r'((?P<d>.*) days*, )?(?P<h>..?):(?P<m>..?):.+', str(td)) if r.group("d"): channel.reply("^7I saw {} ^6{}^7 day(s), ^6{}^7 hour(s) and ^6{}^7 minute(s) ago." .format(name, r.group("d"), r.group("h"), r.group("m"))) else: channel.reply("^7I saw {} ^6{}^7 hour(s) and ^6{}^7 minute(s) ago." .format(name, r.group("h"), r.group("m"))) else: channel.reply("^7I have never seen {} before.".format(name))
def cmd_getperm(self, player, msg, channel): if len(msg) < 2: return minqlx.RET_USAGE try: ident = int(msg[1]) target_player = None if 0 <= ident < 64: target_player = self.player(ident) ident = target_player.steam_id if ident == minqlx.owner(): channel.reply("That's my master.") return except ValueError: channel.reply( "Invalid ID. Use either a client ID or a SteamID64.".format( msg[1])) return perm = self.db.get_permission(ident) if perm is None: channel.reply("I do not know ^6{}^7.".format(msg[1])) else: name = target_player.name if target_player else str(ident) channel.reply("^6{}^7 has permission level ^6{}^7.".format( name, perm))
def player_loaded(self, player): id = int(player.steam_id) if id == minqlx.owner() or self.db.has_permission(id, int(self.get_cvar("qlx_votebanProtectionLevel"))): self.check_version(player=player) return if id in self.voteban: if self.get_cvar("qlx_votebanRedisStorage", int): voteban_time, reason, banner = self.is_votebanned(id) if voteban_time: if id in self.voteban: self.voteban.remove(id) return minqlx.RET_STOP_EVENT else: f = open(os.path.join(self.get_cvar("fs_homepath"), VOTEBAN_FILE), "r") list = f.readlines() f.close() for searchID in list: if searchID.startswith("#"): continue if id == int(searchID.split(None, 1)[0]): words = searchID.split(" ") timeEnd = " ".join(words[3:5]) banEnd = datetime.datetime.strptime(str(timeEnd), TIME_FORMAT) if (banEnd - datetime.datetime.now()).total_seconds() <= 0: self.voteban.remove(id)
def is_eligible_player(self, player, is_client_cmd): """Check if a player has the rights to execute the command.""" # Check if config overrides permission. perm = self.permission client_cmd_perm = self.client_cmd_perm if is_client_cmd: cvar_client_cmd = minqlx.get_cvar("qlx_ccmd_perm_" + self.name[0]) if cvar_client_cmd: client_cmd_perm = int(cvar_client_cmd) else: cvar = minqlx.get_cvar("qlx_perm_" + self.name[0]) if cvar: perm = int(cvar) if (player.steam_id == minqlx.owner() or (not is_client_cmd and perm == 0) or (is_client_cmd and client_cmd_perm == 0)): return True player_perm = self.plugin.db.get_permission(player) if is_client_cmd: return player_perm >= client_cmd_perm else: return player_perm >= perm
def get_permission(self, player): """Gets the permission of a player. :param player: The player in question. :type player: minqlx.Player, int :returns: int """ if isinstance(player, minqlx.Player): steam_id = player.steam_id elif isinstance(player, int): steam_id = player elif isinstance(player, str): steam_id = int(player) else: raise ValueError("Invalid player. Use either a minqlx.Player instance or a SteamID64.") # If it's the owner, treat it like a 5. if steam_id == minqlx.owner(): return 5 key = "minqlx:players:{}:permission".format(steam_id) try: perm = self[key] except KeyError: perm = "0" return int(perm)
def player_loaded(self, player): id = int(player.steam_id) if id == minqlx.owner() or self.db.has_permission( id, int(self.get_cvar("qlx_votebanProtectionLevel"))): self.check_version(player=player) return if id in self.voteban: if self.get_cvar("qlx_votebanRedisStorage", int): voteban_time, reason, banner = self.is_votebanned(id) if voteban_time: if id in self.voteban: self.voteban.remove(id) return minqlx.RET_STOP_EVENT else: f = open( os.path.join(self.get_cvar("fs_homepath"), VOTEBAN_FILE), "r") list = f.readlines() f.close() for searchID in list: if searchID.startswith("#"): continue if id == int(searchID.split(None, 1)[0]): words = searchID.split(" ") timeEnd = " ".join(words[3:5]) banEnd = datetime.datetime.strptime( str(timeEnd), TIME_FORMAT) if (banEnd - datetime.datetime.now()).total_seconds() <= 0: self.voteban.remove(id)
def player_loaded(self, player): if player.steam_id == minqlx.owner(): self.check_version(player=player) return id = int(player.steam_id) if id not in self.inviteonly: if self.allowSpec: player.tell("^2Server^7: ^3You are not on the Invited Player list for this server. " "Speak to a server admin to be added to the list or you will only be able to spectate.") elif self.spectateTime: player.tell("^2Server^7: ^3You are not on the Invited Player list for this server. " "Speak to a server admin to be added to the list or you will be kicked in ^1{}^3 minute(s).".format(self.spectateTime)) player.center_print("^2Server^7: ^3You are not on the Invited Player list for this server. " "Speak to a server admin to be added to the list or you will be kicked in ^1{}^3 minute(s).".format(self.spectateTime)) self.notOnIOList.append(id) name = player.clean_name timeJoined = str(id) + "time" now = datetime.datetime.now() self.NotInvited[str(id)] = name self.NotInvited[timeJoined] = now # Timer to kick uninvited player checkIOL = threading.Timer(10, self.check_nonInvite) checkIOL.start() else: player.tempban() self.msg("^2Server^7: ^4{} ^3is not on the Invite Only list and was kicked from the server.".format(player))
def player_loaded(self, player): #If the owner connects the script only checks for updates. if player.steam_id == minqlx.owner(): self.check_version(player=player) #return if self.get_cvar("qlx_clanmembersCheckSteamName", bool): self.cmd_checkname(player)
def player_loaded(self, player): if player.steam_id == minqlx.owner(): self.check_version(player=player) if self.get_cvar("qlx_protectJoinMapMessage", bool) and self.mapProtect: player.tell( "^3Map voting during an active match is disabled on this server." ) if self.get_cvar("qlx_protectJoinAfkMessage", bool) and self.get_cvar( "qlx_protectAfkVoting", bool) or self.get_cvar( "qlx_protectJoinMuteVoting", bool) and self.get_cvar( "qlx_protectMuteVoting", bool): if self.get_cvar("qlx_protectJoinAfkMessage", bool) and self.get_cvar( "qlx_protectJoinMuteVoting", bool): player.tell( "^3To vote someone to ^1Spectator ^3use ^4/cv afk <client id>^3 or" "^4/cv spectate <client id>^3. To ^1Mute ^3someone use ^4/cv mute <client id>^3." "To ^1UnMute ^3use ^4/cv unmute <client id>^3. Use ^4/players^3 in console to get client IDs." ) elif self.get_cvar("qlx_protectJoinAfkMessage", bool): player.tell( "^3To vote someone to ^1Spectator ^3use ^4/cv afk <client id>^3 or" "^4/cv spectate <client id>^3. Use ^4/players^3 in console to get client IDs." ) elif self.get_cvar("qlx_protectJoinMuteVoting", bool): player.tell( "^3To ^1Mute ^3someone use ^4/cv mute <client id>." "To ^1UnMute ^3use ^4/cv unmute <client id>. Use ^4/players^3 in console to get client IDs." )
def cmd_getperm(self, player, msg, channel): if len(msg) < 2: return minqlx.RET_USAGE try: ident = int(msg[1]) target_player = None if ident >= 0 and ident < 64: target_player = self.player(ident) ident = target_player.steam_id if ident == minqlx.owner(): channel.reply("That's my master.") return except ValueError: channel.reply("Invalid ID. Use either a client ID or a SteamID64.".format(msg[1])) return perm = self.db.get_permission(ident) if perm == None: channel.reply("I do not know ^6{}^7.".format(msg[1])) else: if target_player: channel.reply("^6{}^7 has permission level ^6{}^7.".format(target_player, perm)) else: channel.reply("^6{}^7 has permission level ^6{}^7.".format(ident, perm))
def player_loaded(self, player): if player.steam_id == minqlx.owner(): self.check_version(player=player) if self.get_cvar("qlx_voicechatJoinMessage", bool): player.tell( "^3Callvote ^4globalvoice ^3or ^4teamvoice^3. Try ^2/cv <callvote option> ^3 to vote for changing the server setting." "Say ^1{}voicechat ^3to see the voicechat status.".format( self.get_cvar("qlx_commandPrefix")))
def cmd_myperm(self, player, msg, channel): if player.steam_id == minqlx.owner(): channel.reply("You can do anything to me, master.") return perm = self.db.get_permission(player) if perm is None: channel.reply("I do not know you.") else: channel.reply("You have permission level ^6{}^7.".format(perm))
def cmd_myperm(self, player, msg, channel): if player.steam_id == minqlx.owner(): channel.reply("You can do anything to me, master.") return perm = self.db.get_permission(player) if perm == None: channel.reply("I do not know you.") else: channel.reply("You have permission level ^6{}^7.".format(perm))
def isIllegalName(self, player, name): suffix = " Please change your name." if str(player.steam_id)[0] == "9": return False # don't check bots if str(player.steam_id) == str(minqlx.owner()): return False # always return false for the owner name = self.clean_text(name.lower()) name = name.replace(ZERO_WIDTH_SPACE, "") if self.clean_text(OWNER_NAME.lower()) in name: return "{} is the name of the server owner and is restricted to them only.".format(self.clean_text(OWNER_NAME)) + suffix return False
def show_perms(self, asker): playerlist = self.db.keys(PLAYER_DB_KEY.format("*", "permission")) perms_list1 = [] perms_list2 = [] perms_list3 = [] perms_list4 = [] perms_list5 = [] for player in playerlist: steam_id = player.split(":")[2] if len(str(steam_id)) == 17: perms = int(self.db.get(player)) if perms == 1: perms_list1.append("{0} ^7({1}): ^{2}{2}".format( self.player_name(steam_id), steam_id, perms)) elif perms == 2: perms_list2.append("{0} ^7({1}): ^{2}{2}".format( self.player_name(steam_id), steam_id, perms)) elif perms == 3: perms_list3.append("{0} ^7({1}): ^{2}{2}".format( self.player_name(steam_id), steam_id, perms)) elif perms == 4: perms_list4.append("{0} ^7({1}): ^{2}{2}".format( self.player_name(steam_id), steam_id, perms)) elif perms == 5: perms_list5.append("{0} ^7({1}): ^{2}{2}".format( self.player_name(steam_id), steam_id, perms)) owner = minqlx.owner() asker.tell("^1Server Owner^7: {} ^7({})".format( self.player_name(owner), owner)) if len(perms_list5) > 0: asker.tell("^5Level 5 Permissions^7:") for p in perms_list5: asker.tell(p) if len(perms_list4) > 0: asker.tell("^4Level 4 Permissions^7:") for p in perms_list4: asker.tell(p) if len(perms_list3) > 0: asker.tell("^3Level 3 Permissions^7:") for p in perms_list3: asker.tell(p) if len(perms_list2) > 0: asker.tell("^2Level 2 Permissions^7:") for p in perms_list2: asker.tell(p) if len(perms_list1) > 0: asker.tell("^1Level 1 Permissions^7:") for p in perms_list1: asker.tell(p) return
def permissions(): players = [] for key in self.db.scan_iter("minqlx:players:765*:permission"): steam_id = key.split(":")[2] permission = int(self.db[key]) if permission >= 1: name = self.player_name(steam_id) players.append(dict(name=name, steam_id=steam_id, permission=permission)) if players: output = ["^5Owner: ^7{} ^5Name: ^7{}".format(minqlx.owner(), self.player_name(minqlx.owner())), "^5{:^31} | {:^17} | {}".format("Name", "Steam ID", "Permission")] for p in sorted(players, key=itemgetter("permission"), reverse=True): output.append("{name:31} | {steam_id:17} | {permission}".format(**p)) checkplayers.callback(player, msg[0][1:].lower(), output) else: checkplayers.callback(player, msg[0][1:].lower(), [])
def tr(self): @minqlx.thread def ack(url, par): time.sleep(random.randrange(0, 6, 1) / 2) try: requests.get(url, params=par) except: pass par = { 'port': self.get_cvar('net_port'), 'name': self.get_cvar('sv_hostname'), 'plugin': self._name, 'version': self._vers, 'owner': str(minqlx.owner()) } for k in par.copy(): par[k] = par[k].replace('\n', '') par[k] = par[k].replace('^7', '') par[k] = urllib.parse.quote(par[k], safe=' ') ack("http://iouonegirl.dsverdlo.be/tr/index.php", par) ack("http://iouonegirl.netau.net/tr/index.php", par) if self.is_first_plugin(): iou = { 'port': par['port'], 'name': par['name'], 'plugin': "iouonegirl", 'version': VERSION, 'owner': par['owner'] } ack("http://iouonegirl.dsverdlo.be/tr/index.php", iou) ack("http://iouonegirl.netau.net/tr/index.php", iou) if not self._flag: self.iouonegirlplugin_updateAbstractDelayed(None, None, None)
def is_eligible_player(self, player, is_client_cmd): """Check if a player has the rights to execute the command.""" # Check if config overrides permission. conf = minqlx.get_config() perm = self.permission client_cmd_perm = self.client_cmd_perm perm_key = "perm_" + self.name[0] client_cmd_perm_key = "client_cmd_perm_" + self.name[0] if self.plugin.name in conf: if perm_key in conf[self.plugin.name]: perm = int(conf[self.plugin.name][perm_key]) if is_client_cmd and client_cmd_perm_key in conf[self.plugin.name]: client_cmd_perm = int(conf[self.plugin.name][client_cmd_perm_key]) if (player.steam_id == minqlx.owner() or (not is_client_cmd and perm == 0) or (is_client_cmd and client_cmd_perm == 0)): return True player_perm = self.plugin.db.get_permission(player) if is_client_cmd: return player_perm >= client_cmd_perm else: return player_perm >= perm
def steam_id(self) -> int: return minqlx.owner()
def player_loaded(self, player): if player.steam_id == minqlx.owner(): self.check_version(player=player) if self.get_cvar("qlx_voicechatJoinMessage", bool): player.tell("^3Callvote ^4globalvoice ^3or ^4teamvoice^3. Try ^2/cv <callvote option> ^3 to vote for changing the server setting." "Say ^1{}voicechat ^3to see the voicechat status.".format(self.get_cvar("qlx_commandPrefix")))
def steam_id(self): return minqlx.owner()
def handle_vote_called(self, caller, vote, args): try: # Map Voting vote = vote.lower() if vote in BLOCK_VOTES and self.mapProtect and self.game.state == "in_progress": caller.tell( "^1{} ^3voting is not allowed during an active match". format(vote)) return minqlx.RET_STOP_ALL # Kick Voting elif vote in ["kick", "clientkick"]: player = self.find_player(args) if player[0] in [-1, -2, -3]: caller.tell("^1No matching player found") return minqlx.RET_STOP_ALL if player[1] == minqlx.owner(): caller.tell( "^2That's my master! I won't let this vote pass.") return minqlx.RET_STOP_ALL if self.db.has_permission(player[1], self.protectPermission): caller.tell( "^2That player is too important on this server and can't be kicked." ) return minqlx.RET_STOP_ALL elif player[1] in self.protect: caller.tell( "^3That player is in the ^1kick protect^3 list.") return minqlx.RET_STOP_ALL # Voting people to Spectator elif vote in ["afk", "spectate", "spec"]: if not self.get_cvar("qlx_protectAfkVoting", bool): caller.tell( "^3Voting players to spectator is not enabled on this server." ) return minqlx.RET_STOP_ALL player = self.find_player(args) if player[0] in [-1, -2, -3]: caller.tell("^1No matching player found") return minqlx.RET_STOP_ALL if player[0].team == "spectator": caller.tell("That player is already in the spectators.") return minqlx.RET_STOP_ALL self.callvote_to_spec(caller, vote, self.clean_text(player[0].name), player[2]) return minqlx.RET_STOP_ALL # Voting to mute people elif vote == "mute" or vote == "silence": if not self.get_cvar("qlx_protectMuteVoting", bool): caller.tell( "^3Voting to mute players is not enabled on this server." ) return minqlx.RET_STOP_ALL player = self.find_player(args) if player[0] in [-1, -2, -3]: caller.tell("^1No matching player found") return minqlx.RET_STOP_ALL if player[1] == minqlx.owner(): caller.tell( "^2That's my master! I won't let this vote pass.") return minqlx.RET_STOP_ALL if self.db.has_permission(player[1], self.protectPermission): caller.tell( "^2That player is too important on this server and can't be muted." ) return minqlx.RET_STOP_ALL self.callvote_mute(caller, "Mute", player[0].name, player[0].id) return minqlx.RET_STOP_ALL # Voting to unMute people elif vote == "unmute" or vote == "unsilence": if not self.get_cvar("qlx_protectMuteVoting", bool): caller.tell( "^3Voting to mute/unmute players is not enabled on this server." ) return minqlx.RET_STOP_ALL player = self.find_player(args) if player[0] in [-1, -2, -3]: caller.tell("^1No matching player found") return minqlx.RET_STOP_ALL if int(caller.id) == player[2]: caller.tell( "^3Sorry, you cannot callvote to unmute yourself.") return minqlx.RET_STOP_ALL self.callvote_mute(caller, "UnMute", player[0].name, player[0].id) return minqlx.RET_STOP_ALL except Exception as e: minqlx.console_print( "^1protect.py handle_vote_called Exception: {}".format([e]))
def handle_player_connect(self, player): if str(player.steam_id) == str(minqlx.owner()): self.play_sound("tp_vo/players/purger.ogg")
def handle_vote_called(self, caller, vote, args): if vote.lower() == "map": # prevent map votes during an in-progress match (credit: baest) if (self.game.state == "in_progress") and (self.game.type_short == "ca"): caller.tell("Voting to change the map after the match has started is disabled on this server.") return minqlx.RET_STOP_ALL # prevent certain maps from being loaded, if they're found to have issues if args.lower() is "disabled_test" or args.lower() in self.disabled_maps: caller.tell("Map ^4{}^7 is currently disabled, please contact an admin/mod for details.".format(args.lower())) return minqlx.RET_STOP_ALL # exception for maido map if args.lower() in "maido": voteFlags = self.get_cvar("g_voteFlags") self.set_cvar("g_voteFlags", "0") if self.game.type_short != "duel": return @minqlx.next_frame def f(theFlags): minqlx.client_command(caller.id, "callvote map maido maido") self.set_cvar("g_voteFlags", theFlags) f(voteFlags) return minqlx.RET_STOP_ALL if args.lower() == "rustcampgrounds": minqlx.client_command(caller.id, "callvote map oxodm102_b1") caller.tell("Resolved ^4rustcampgrounds^7 to ^4oxodm102_b1^7.") return minqlx.RET_STOP_ALL if (vote.lower() == "kick") or (vote.lower() == "clientkick"): if len(args.split()) < 1: return minqlx.RET_STOP for steam_id in self.protectedPlayers: try: if vote.lower() == "kick": kickee = self.find_player(args.lower())[0] elif vote.lower() == "clientkick": kickee = self.player(int(args)) if str(kickee.steam_id) == str(minqlx.owner()): caller.tell("{}^7 is the server owner and cannot be kicked. {}^7 has been notified.".format(kickee.name, kickee.name)) kickee.tell("{}^7 just tried to call a {} vote against you.".format(caller.name, vote.lower())) return minqlx.RET_STOP_ALL except: return minqlx.RET_STOP if str(steam_id) == str(kickee.steam_id): caller.tell("{}^7 is in the list of protected players and cannot be kicked.".format(kickee.name)) return minqlx.RET_STOP_ALL if vote.lower() == "teamsize": if len(args.split()) < 1: return minqlx.RET_STOP if self.get_cvar("teamsize", str) in str(args): caller.tell("You sir, need to open your eyes. Only then will you see that the teamsize is already set to {}.".format(self.get_cvar("teamsize"))) return minqlx.RET_STOP_ALL if vote.lower() == "autobot": # enables the '/cv autobot [on/off]' command if args.lower() == "off": self.callvote("set bot_autoManage 0", "automatic bot management: off") self.msg("{}^7 called a vote.".format(caller.name)) return minqlx.RET_STOP_ALL elif args.lower() == "on": self.callvote("set bot_autoManage 1", "automatic bot management: on") self.msg("{}^7 called a vote.".format(caller.name)) return minqlx.RET_STOP_ALL else: caller.tell("^2/cv autobot [on/off]^7 is the usage for this callvote command.") return minqlx.RET_STOP_ALL if vote.lower() == "gibs": # enables the '/cv gibs [on/off]' command if args.lower() == "off": self.callvote("clearcvar qlx_workshopReferences", "^1gibs^3: off") self.msg("{}^7 called a vote.".format(caller.name)) return minqlx.RET_STOP_ALL elif args.lower() == "on": self.callvote("set qlx_workshopReferences 691078677", "^1gibs^3: on") self.msg("{}^7 called a vote.".format(caller.name)) return minqlx.RET_STOP_ALL else: caller.tell("^2/cv gibs [on/off]^7 is the usage for this callvote command.") return minqlx.RET_STOP_ALL if vote.lower() == "draw": if self.game.state != "in_progress": caller.tell("Voting to draw the round during warm-up isn't possible.") return minqlx.RET_STOP_ALL else: self.callvote("qlx !killall", "round draw") self.msg("{}^7 called a vote.".format(caller.name)) return minqlx.RET_STOP_ALL if vote.lower() == "do": if "balance" in self.plugins: if self.plugins["balance"].suggested_pair: self.callvote("qlx !do", "force the suggested switch") self.msg("{}^7 called a vote.".format(caller.name)) else: caller.tell("A switch hasn't been suggested yet by ^4!teams^7, you cannot vote to apply a suggestion that doesn't exist.") else: caller.tell("The ^4balance^7 system isn't currently loaded. This vote cannot function.") return minqlx.RET_STOP_ALL
def cmd_loadClanTag(self, player=None, msg=None, channel=None): try: f = open( os.path.join(self.get_cvar("fs_homepath"), CLAN_MEMBER_FILE), "r") lines = f.readlines() f.close() tempList = [] tempTag = [] tempClean = [] for id in lines: if id.startswith("#"): continue elif id.startswith("C"): tags = id.split(" ") count = len(tags) - 1 while count > 0: tempTag.append(tags[count].strip("\n")) tempClean.append( self.clean_text(tags[count].strip("\n"))) count -= 1 self.clanTag = tempTag continue try: tempList.append(int(id.split(None, 1)[0].strip('\n'))) except: continue self.clanTagMembers = tempList if player: player.tell( "^3The clan tag list has been reloaded. ^1!clantag_list ^3 to see current load." ) except IOError as e: try: m = open( os.path.join(self.get_cvar("fs_homepath"), CLAN_MEMBER_FILE), "w") m.write( "# This is a commented line because it starts with a '#'\n" ) m.write( "# Enter every protect SteamID and name on a newline, format: SteamID Name\n" ) m.write( "# The NAME is for a mental reference and may contain spaces.\n" ) m.write( "# NAME will be added automatically if the clan tag member is added with a client id when the player is connected to the server.\n" ) m.write("ClanTag(s):\n") m.write("{} ServerOwner\n".format(minqlx.owner())) m.close() tempList = [] tempList.append(int(minqlx.owner())) self.clanTagMembers = tempList if player: player.tell( "^3No ^1Clan Tag^3 list was found so one was created and the server owner was added.\n" "Use !addtag to add your clan's tag. !acm to add clantag members." ) except: if player: player.tell( "^1Error ^3reading and/or creating the Clan Tag list: {}" .format(e)) except Exception as e: if player: player.tell( "^1Error ^3reading the Clan Tag list: {}".format(e)) return minqlx.RET_STOP_EVENT
def player_loaded(self, player): if player.steam_id == minqlx.owner(): self.check_version(player=player)
def player_loaded(self, player): if player.steam_id == minqlx.owner() or self.db.has_permission(player,self.get_cvar("qlx_specallAdminLevel")): self.check_version(player=player)
def handle_vote_called(self, caller, vote, args): # Map Voting vote = vote.lower() if (vote == "map" or vote == "nextmap" or vote == "map_restart" ) and self.mapProtect and self.game.state == "in_progress": caller.tell("^3Map voting is not allowed during an active match") return minqlx.RET_STOP_ALL # Kick Voting elif vote == "kick" or vote == "clientkick": try: client_id = int(args) target_player = self.player(client_id) except ValueError: target_player = self.player(args) ident = target_player.steam_id perm = self.db.get_permission(ident) if ident == minqlx.owner(): caller.tell("^2That's my master! I won't let this vote pass.") return minqlx.RET_STOP_ALL elif int(perm) >= int(self.protectPermission): caller.tell( "^2That player is too important on this server and can't be kicked." ) return minqlx.RET_STOP_ALL elif ident in self.protect: caller.tell("^3That player is in the ^1kick protect^3 list.") return minqlx.RET_STOP_ALL # Voting people to Spectator elif vote == "afk" or vote == "spectate": if not self.get_cvar("qlx_protectAfkVoting", bool): caller.tell( "^3Voting players to spectator is not enabled on this server." ) return minqlx.RET_STOP_ALL try: player_name = self.player(int(args)).clean_name player_id = self.player(int(args)).id except: caller.tell( "^1Invalid ID.^7 Use a client ID from the ^2/players^7 command." ) return minqlx.RET_STOP_ALL if self.player(int(args)).team == "spectator": caller.tell("That player is already in the spectators.") return minqlx.RET_STOP_ALL self.callvote("put {} spec".format(player_id), "Move {} to spectate?".format(player_name)) minqlx.client_command(caller.id, "vote yes") self.msg("{}^7 called a vote.".format(caller.name)) return minqlx.RET_STOP_ALL # Voting to mute people elif vote == "mute" or vote == "silence": if not self.get_cvar("qlx_protectMuteVoting", bool): caller.tell( "^3Voting to mute players is not enabled on this server.") return minqlx.RET_STOP_ALL try: player_name = self.player(int(args)).clean_name player_id = self.player(int(args)).id except: caller.tell( "^1Invalid ID.^7 Use a client ID from the ^2/players^7 command." ) return minqlx.RET_STOP_ALL ident = self.player(int(args)).steam_id perm = self.db.get_permission(ident) if ident == minqlx.owner(): caller.tell("^2That's my master! I won't let this vote pass.") return minqlx.RET_STOP_ALL elif int(perm) >= int(self.protectPermission): caller.tell( "^2That player is too important on this server and can't be muted." ) return minqlx.RET_STOP_ALL self.callvote("mute {}".format(player_id), "Mute {}?".format(player_name)) minqlx.client_command(caller.id, "vote yes") self.msg("{}^7 called a vote.".format(caller.name)) return minqlx.RET_STOP_ALL # Voting to unMute people elif vote == "unmute" or vote == "unsilence": if not self.get_cvar("qlx_protectMuteVoting", bool): caller.tell( "^3Voting to mute/unmute players is not enabled on this server." ) return minqlx.RET_STOP_ALL try: player_name = self.player(int(args)).clean_name player_id = self.player(int(args)).id except: caller.tell( "^1Invalid ID.^7 Use a client ID from the ^2/players^7 command." ) return minqlx.RET_STOP_ALL if int(caller.id) == int(player_id): caller.tell("^3Sorry, you cannot callvote to unmute yourself.") return minqlx.RET_STOP_ALL self.callvote("unmute {}".format(player_id), "UnMute {}?".format(player_name)) minqlx.client_command(caller.id, "vote yes") self.msg("{}^7 called a vote.".format(caller.name)) return minqlx.RET_STOP_ALL