def processCommand(self, schid, command): cmd = command.lower() if cmd.startswith("test"): ts3lib.printMessageToCurrentTab("Status: "+str(self.toggle)) ts3lib.printMessageToCurrentTab("Ban: "+str(self.sbgroup)) ts3lib.printMessageToCurrentTab("Mod: "+str(self.smgroup)) ts3lib.printMessageToCurrentTab("Admin: "+str(self.sagroup)) ts3lib.printMessageToCurrentTab("Own Channels: "+str(self.ownchannels)) ts3lib.printMessageToCurrentTab("requestedCs: "+str(self.requestedC)) return True elif cmd.startswith("addchan"): command = int(command.split("addchan ")[1]) self.ownchannels.extend([command]) ts3lib.printMessageToCurrentTab("[color=green]Added[/color] #"+str(command)+" to list of channels: "+str(self.ownchannels)) return True elif cmd.startswith("delchan"): command = int(command.split("delchan ")[1]) self.ownchannels.remove([command]) ts3lib.printMessageToCurrentTab("[color=red]Removed[/color] #"+str(command)+" from list of channels: "+str(self.ownchannels)) return True elif cmd == "checkall": self.checkAllUsers() return True elif cmd == "load": self.requested = True ts3lib.requestChannelGroupList(ts3lib.getCurrentschid()) return True
def clientURL(self, schid=None, clid=1, uid=None, nickname=None, encodednick=None): if not self.check: return False if schid == None: try: schid = ts3lib.getCurrentschid() except: pass if uid == None: try: (error, uid) = ts3lib.getClientVariableAsString( schid, clid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) except: pass if nickname == None: try: (error, nickname) = ts3lib.getClientDisplayName(schid, clid) except: nickname = uid if encodednick == None: try: encodednick = urlencode(nickname) except: pass return "[url=client://%s/%s~%s]%s[/url]" % (clid, uid, encodednick, nickname)
def __init__(self): if path.isfile(self.ini): self.cfg.read(self.ini) else: self.cfg['general'] = { "cfgversion": "1", "debug": "False", "enabled": "True" } self.cfg['autoban'] = {"enabled": "True"} self.cfg['automod'] = {"enabled": "True", "autotp": "True"} self.cfg['antirecord'] = {"enabled": "True"} self.cfg['autokickonban'] = {"enabled": "True"} self.cfg['groups'] = { "banned": ["BAN", "NOT WELCOME"], "mod": ["MOD", "OPERATOR"], "admin": ["ADMIN"] } with open(self.ini, 'w') as configfile: self.cfg.write(configfile) self.db = QSqlDatabase.addDatabase("QSQLITE", "channelWatcher") self.db.setDatabaseName(ts3lib.getConfigPath() + "settings.db") if self.db.isValid(): self.db.open() schid = ts3lib.getCurrentschid() if schid: self.requested = True ts3lib.requestChannelGroupList(schid) (error, ownID) = ts3lib.getClientID(schid) (error, cid) = ts3lib.getChannelOfClient(schid, ownID) self.ownchannels.extend([cid]) if self.debug: ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(self.timestamp(), self.name, self.author))
def checkAllUsers(self): if not self.check: return False if self.toggle: _schid = ts3lib.getCurrentschid() (error, _clid) = ts3lib.getClientID(_schid) (error, cl) = ts3lib.getClientList(_schid) for user in cl: if user != _clid: (error, uid) = ts3lib.getClientVariableAsString(_schid, user, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) self.checkUser(uid)
def checkUser(self, uid): if not self.check: return False if self.toggle: if len(self.ownchannels) > 0: if uid != "serveradmin" and uid != "ServerQuery": _in = self.InContacts(uid) if _in < 2: _schid = ts3lib.getCurrentschid() self.requestedC.extend([_in]) ts3lib.requestClientDBIDfromUID(_schid, uid)
def onUpdateClientEvent(self, schid, clientID, invokerID, invokerName, invokerUniqueIdentifier): return if self.check and self.toggle: (error, _clid) = ts3lib.getClientID(schid) if not clientID == _clid: (error, _tcid) = ts3lib.getChannelOfClient(schid, clientID) if _tcid in self.ownchannels: (error, _cgid) = ts3lib.getClientVariableAsInt(schid, _clid, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) if _cgid in [self.smgroup, self.sagroup]: if self.checkRecording: (error, clientRecStatus) = ts3lib.getClientVariableAsInt(schid, clientID, ts3defines.ClientProperties.CLIENT_IS_RECORDING) if clientRecStatus == 1: self.reason == "Recording" _schid = ts3lib.getCurrentschid() self.requestedC.extend([1]) _dbid = ts3lib.requestClientDBIDfromUID(_schid, invokerUniqueIdentifier)