def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT: if menuItemID == 0: (err, uid) = ts3lib.getClientVariable( schid, selectedItemID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) ts3lib.banadd(schid, "", "", uid, 0, "")
def banName(self, schid, target, name): name_in_use = False (err, clids) = ts3lib.getClientList(schid) for clid in clids: if clid == target: continue (err, _name) = ts3lib.getClientVariable( schid, clid, ts3defines.ClientProperties.CLIENT_NICKNAME) if name in _name: name_in_use = True if not name_in_use: name = ".*{}.*".format(name) print("inuse:", name_in_use, "name:", name) ts3lib.banadd(schid, "", name, "", self.cfg.getint("ban", "name duration"), self.banReason())
def banIP(self, schid, ip): if not ip: return active = PluginHost.active if "Custom Ban" in active: whitelist = active["Custom Ban"].whitelist if len(whitelist) > 1: if ip in whitelist: ts3lib.printMessageToCurrentTab( "{}: [color=red]Not banning whitelisted IP [b]{}". format(self.name, ip)) return else: ts3lib.printMessageToCurrentTab( "{}: \"Custom Ban\"'s IP Whitelist faulty, please check!". format(self.name)) return ts3lib.banadd(schid, ip, "", "", 0, self.banReason())
def on_btn_ban_clicked(self): try: ip = self.txt_ip.text if self.grp_ip.isChecked() else "" name = self.txt_name.text if self.grp_name.isChecked() else "" uid = self.txt_uid.text if self.grp_uid.isChecked() else "" reason = self.box_reason.currentText if reason[0].isdigit(): reason = "ยง" + reason duration = self.int_duration.value if self.moveBeforeBan: ts3lib.requestClientMove(self.schid, self.clid, 26, "") if ip: check = True if len(self.whitelist) < 1: check = confirm("Empty IP Whitelist!", "The IP whitelist is empty! Are you sure you want to ban \"{}\"?\n\nMake sure your whitelist URL\n{}\nis working!".format(ip, self.cfg.get("general", "whitelist"))) if ip in self.whitelist: ts3lib.printMessageToCurrentTab("{}: [color=red]Not banning whitelisted IP [b]{}".format(self.name, ip)) elif check: ts3lib.banadd(self.schid, ip, "", "", duration, reason) if name: ts3lib.banadd(self.schid, "", name, "", duration, reason) if uid: ts3lib.banadd(self.schid, "", "", uid, duration, reason) # msgBox("schid: %s\nip: %s\nname: %s\nuid: %s\nduration: %s\nreason: %s"%(self.schid, ip, name, uid, duration, reason)) self.cfg["last"] = { "ip": str(self.grp_ip.isChecked()), "name": str(self.grp_name.isChecked()), "uid": str(self.grp_uid.isChecked()), "reason": reason, "duration": str(duration), "expanded": str(self.lst_reasons.isVisible()), "height": str(self.height), "alternate": str(self.chk_alternate.isChecked()), "ban on doubleclick": str(self.chk_doubleclick.isChecked()), } if not self.chk_keep.isChecked(): self.close() except: ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def banUID(self, schid, uid): ts3lib.banadd(schid, "", "", uid, self.cfg.getint("ban", "duration"), self.banReason())
def on_btn_ban_clicked(self): try: ip = self.txt_ip.text if self.grp_ip.isChecked() else "" name = self.txt_name.text if self.grp_name.isChecked() else "" uid = self.txt_uid.text if self.grp_uid.isChecked() else "" mytsid = self.txt_mytsid.text if self.grp_mytsid.isChecked( ) else "" hwid = self.txt_hwid.text if self.grp_hwid.isVisible( ) and self.grp_hwid.isChecked() else "" _reason = self.box_reason.currentText delta = timedelta(seconds=self.int_duration_s.value, minutes=self.int_duration_m.value, hours=self.int_duration_h.value, days=self.int_duration_d.value) # duration = self.templates[_reason] err, ownnick = ts3lib.getClientSelfVariable( self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME) reason = "{}{}{}".format(self.prefix, _reason, self.suffix) # delta = timedelta(seconds=duration) print(delta) reason = reason.replace("%ownnick%", ownnick).replace("%duration%", str(delta)) # if reason[0].isdigit(): reason = "" + reason duration = int(delta.total_seconds()) if self.moveBeforeBan: ts3lib.requestClientMove(self.schid, self.clid, 26, "") # if uid: if ip: check = True if len(self.whitelist) < 1: check = confirm( "Empty IP Whitelist!", "The IP whitelist is empty! Are you sure you want to ban \"{}\"?\n\nMake sure your whitelist URL\n{}\nis working!" .format(ip, self.cfg.get("general", "whitelist"))) if ip in self.whitelist: ts3lib.printMessageToCurrentTab( "{}: [color=red]Not banning whitelisted IP [b]{}". format(self.name, ip)) elif check: ts3lib.banadd(self.schid, ip, "", "", duration, reason) if name: ts3lib.banadd(self.schid, "", name, "", duration, reason) if uid: ts3lib.banadd(self.schid, "", "", uid, duration, reason) if mytsid: ts3lib.requestSendClientQueryCommand( self.schid, "banadd mytsid={id} banreason={reason} time={duration}". format(id=mytsid, reason=escapeStr(reason), duration=duration)) if hwid: ts3lib.requestSendClientQueryCommand( self.schid, "banadd hwid={id} banreason={reason} time={duration}". format(id=hwid, reason=escapeStr(reason), duration=duration)) # msgBox("schid: %s\nip: %s\nname: %s\nuid: %s\nduration: %s\nreason: %s"%(self.schid, ip, name, uid, duration, reason)) self.cfg["last"] = { "ip": str(self.grp_ip.isChecked()), "name": str(self.grp_name.isChecked()), "uid": str(self.grp_uid.isChecked()), "mytsid": str(self.grp_mytsid.isChecked()), "hwid": str(self.grp_hwid.isChecked()), "reason": _reason, "duration": str(duration), "expanded": str(self.lst_reasons.isVisible()), "height": str(self.height), "alternate": str(self.chk_alternate.isChecked()), "ban on doubleclick": str(self.chk_doubleclick.isChecked()), } if not self.chk_keep.isChecked(): self.close() except: ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)