def onUpdateChannelEditedEvent(self, schid, channelID, invokerID, invokerName, invokerUniqueIdentifier): (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if suid != self.suid: return (err, ownID) = ts3lib.getClientID(schid) if invokerID == ownID: (err, self.settings["maxclients"]) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) (err, self.settings["tp"]) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) (err, ownChannel) = ts3lib.getChannelOfClient(schid, ownID) if channelID != ownChannel: return (err, invokerChannel) = ts3lib.getChannelOfClient(schid, invokerID) if invokerChannel == channelID: return _needed = False (err, ntp) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if ntp != self.settings["tp"]: _needed = True ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER, self.settings["tp"]) (err, cmc) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_FLAG_MAXCLIENTS_UNLIMITED, 0) if cmc != self.settings["maxclients"]: _needed = True ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, self.settings["maxclients"]) if _needed: ts3lib.flushChannelUpdates(schid, channelID) self.violations[invokerUniqueIdentifier] += 1 if self.violations[invokerUniqueIdentifier] > 2: (err, dbid) = ts3lib.getClientVariable(schid, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) ts3lib.requestSetClientChannelGroup(schid, [9], [channelID], [dbid]) del self.violations[invokerUniqueIdentifier]
def onUpdateClientEvent(self, schid, clid, invokerID, invokerName, invokerUniqueIdentifier): (err, ownID) = ts3lib.getClientID(schid) (err, cid) = ts3lib.getChannelOfClient(schid, clid) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) (err, talker) = ts3lib.getClientVariable( schid, clid, ts3defines.ClientPropertiesRare.CLIENT_IS_TALKER) if cid == ownCID and talker: self.last_talk_power = clid if clid == self.requested: self.requested = 0 if talker == 1: self.revokeTalkPower(schid, clid, True) # else: self.revokeTalkPower(schid, clid, False) (err, cldbid) = ts3lib.getClientVariable( schid, clid, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) (err, sgids) = ts3lib.getClientVariable( schid, clid, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS) loc_sgids = intList(self.cfg.get("restrict", "sgids")) if set(loc_sgids).issubset(sgids): for sgid in loc_sgids: ts3lib.requestServerGroupDelClient(schid, sgid, cldbid) else: for sgid in loc_sgids: ts3lib.requestServerGroupAddClient(schid, sgid, cldbid)
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: if menuItemID == 0: self.channel = selectedItemID ts3lib.printMessageToCurrentTab('[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())+" Set target channel to [color=yellow]"+str(self.channel)+"[/color]") elif menuItemID == 1: (e, cgid) = ts3lib.getServerVariableAsUInt64(schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_DEFAULT_CHANNEL_GROUP) x = QDialog() x.setAttribute(Qt.WA_DeleteOnClose) dbid = QInputDialog.getInt(x, "Manually change channel group", "Enter DBID", QLineEdit.Normal) if self.channel == 0: (e, ownID) = ts3lib.getClientID(schid) (e, self.channel) = ts3lib.getChannelOfClient(schid, ownID) name = "DBID: %s"%dbid if self.debug: ts3lib.printMessageToCurrentTab("toggle: {0} | debug: {1} | channel: {2} | groups: {3} | dbid: {4} | name: {5}".format(self.toggle,self.debug,self.channel,self.groups,dbid,name)) ts3lib.printMessageToCurrentTab("schid: {0} | cgid: {1} | dbid: {2}".format(schid,cgid,dbid)) if not self.dlg: self.dlg = ChannelGroupDialog(schid, cgid, dbid, name, self.channel, self.groups) self.dlg.show();self.dlg.raise_();self.dlg.activateWindow() elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT: if menuItemID == 0: if self.channel == 0: (e, ownID) = ts3lib.getClientID(schid) (e, self.channel) = ts3lib.getChannelOfClient(schid, ownID) (e, dbid) = ts3lib.getClientVariableAsUInt64(schid, selectedItemID, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) (e, cgid) = ts3lib.getClientVariableAsUInt64(schid, selectedItemID, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) (e, name) = ts3lib.getClientVariableAsString(schid, selectedItemID, ts3defines.ClientProperties.CLIENT_NICKNAME) if self.debug: ts3lib.printMessageToCurrentTab("toggle: {0} | debug: {1} | channel: {2} | groups: {3} | dbid: {4} | name: {5}".format(self.toggle,self.debug,self.channel,self.groups,dbid,name)) if not self.dlg: self.dlg = ChannelGroupDialog(schid, cgid, dbid, name, self.channel, self.groups) self.dlg.show();self.dlg.raise_();self.dlg.activateWindow()
def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity): if not self.check: return False if self.toggle: (error, _clid) = ts3lib.getClientID(schid) (error, _cid) = ts3lib.getChannelOfClient(schid, _clid) if clientID == _clid: if channelGroupID == self.sagroup: if self.ownchannels.__contains__(channelID): _t = False else: self.ownchannels.append(channelID) elif channelGroupID == self.smgroup: (error, neededTP) = ts3lib.getChannelVariableAsInt(schid, _cid, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) if neededTP > 0: (error, clients) = ts3lib.getChannelClientList(schid, _cid) for client in clients: if client == _clid: continue (error, _cgid) = ts3lib.getClientVariableAsInt(schid, client, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) if _cgid == self.sagroup: continue (error, uid) = ts3lib.getClientVariableAsString(schid, client, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if self.InContacts(uid) == 0: ts3lib.requestClientSetIsTalker(schid, client, True) elif channelID == _cid and channelGroupID == self.sbgroup: #(error, uid) = ts3lib.getClientVariableAsString(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) (error, _cid) = ts3lib.getChannelOfClient(schid, clientID) if _cid in self.ownchannels: ts3lib.requestClientKickFromChannel(schid, clientID, "You were banned by \"%s\""%invokerName + (" for \"%s\""%invokerName) if self.reason != "" else "")
def joinTarget(self, schid=0): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() (err, ownID) = ts3lib.getClientID(schid) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) (err, cid) = ts3lib.getChannelOfClient(schid, self.targets[schid]) if ownCID == cid: return (err, path, pw) = ts3lib.getChannelConnectInfo(schid, cid) ts3lib.requestClientMove(schid, ownID, cid, pw)
def join(self, schid, clid, cid): (err, ownID) = ts3lib.getClientID(schid) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) if not cid: (err, cid) = ts3lib.getChannelOfClient(schid, self.targets[schid]) if ownCID == cid: return delay = randint(self.delay[0], self.delay[1]) ts3lib.printMessageToCurrentTab("{} {}: Auto-following {} in channel {} in {}ms".format(timestamp(), self.name, clientURL(schid, clid), channelURL(schid, cid), delay)) self.cid = cid QTimer.singleShot(delay, self.joinTarget)
def onHotkeyOrCommandEvent(self, keyword, schid=0): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() if keyword == "restrict_last_joined_server": self.requested = self.last_joined_server msg = self.cfg.get("restrict", "poke") if msg: ts3lib.requestClientPoke(schid, self.requested, msg) ts3lib.requestClientVariables(schid, self.last_joined_server) # self.restrictClient(schid, self.last_joined_server) elif keyword == "restrict_last_joined_channel": self.requested = self.last_joined_channel msg = self.cfg.get("restrict", "poke") if msg: ts3lib.requestClientPoke(schid, self.requested, msg) ts3lib.requestClientVariables(schid, self.last_joined_channel) # self.restrictClient(schid, self.last_joined_channel) elif keyword == "ban_last_joined_server": msg = self.cfg.get("ban", "poke") if msg: ts3lib.requestClientPoke(schid, self.last_joined_server, msg) self.banClient(schid, self.last_joined_server) elif keyword == "ban_last_joined_channel": msg = self.cfg.get("ban", "poke") if msg: ts3lib.requestClientPoke(schid, self.last_joined_channel, msg) self.banClient(schid, self.last_joined_channel) elif keyword == "revoke_last_talk_power_channel": self.revokeTalkPower(schid, self.last_talk_power) elif keyword == "restrict_last_joined_channel_from_local_channels": self.restrictForeigners(schid, self.last_joined_channel) elif keyword == "last_joined_channel_to_customBan": self.toCustomBan(schid, self.last_joined_channel) elif keyword == "last_joined_server_to_customBan": self.toCustomBan(schid, self.last_joined_server) elif keyword == "join_selected_channel_pw": window = self.app.activeWindow() if window is None or not window.className() == "MainWindow": return selected = widget("ServerTreeView", self.app).currentIndex() if not selected: return name = selected.data() item = getIDByName(name, schid) if item[1] != ServerTreeItemType.CHANNEL: return (err, clid) = ts3lib.getClientID(schid) (err, cid) = ts3lib.getChannelOfClient(schid, clid) if cid == item[0]: return pw = getChannelPassword(schid, item[0], calculate=True) if not pw: return # ts3lib.printMessageToCurrentTab("{} > Joining {} (pw: {})".format(self.name, name, pw)) ts3lib.requestClientMove(schid, clid, item[0], pw) elif keyword == "rejoin_last_channel_pw": (err, clid) = ts3lib.getClientID(schid) (err, cid) = ts3lib.getChannelOfClient(schid, clid) tcid = self.lastchans[schid] if cid == tcid: return pw = getChannelPassword(schid, tcid, calculate=True) # (err, name) = ts3lib.getChannelVariable(schid, tcid, ts3defines.ChannelProperties.CHANNEL_NAME) # ts3lib.printMessageToCurrentTab("{} > Rejoining {} (pw: {})".format(self.name, name, pw)) ts3lib.requestClientMove(schid, clid, tcid, pw if pw else "123")
def joinTarget(self, schid = 0, cid = 0): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() (err, ownID) = ts3lib.getClientID(schid) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) clid = getClientIDByUID(schid, self.targets[schid]) if not cid: (err, cid) = ts3lib.getChannelOfClient(schid, clid) if ownCID == cid: return pw = getChannelPassword(schid, cid, True) ts3lib.requestClientMove(schid, ownID, cid, pw if pw else "") self.cid = 0
def commandChannelMessage(self, schid, targetMode, toID, fromID, params=""): try: _p = params.split(" ",1);target = int(_p[0]);message = _p[1] if self.cfg.getboolean("general", "debug"): ts3lib.printMessageToCurrentTab("Found Channel ID: {0}".format(target)) except: (error, target) = ts3lib.getChannelOfClient(schid, fromID);message = params if self.cfg.getboolean("general", "debug"): ts3lib.printMessageToCurrentTab("Found No Channel ID.") (error, ownID) = ts3lib.getClientID(schid) (error, ownChan) = ts3lib.getChannelOfClient(schid, ownID) if not ownChan == target: ts3lib.requestClientMove(schid, ownID, target, "123") ts3lib.requestSendChannelTextMsg(schid, "Message from {0}: {1}".format(self.clientURL(schid, fromID), message), target) if not ownChan == target: ts3lib.requestClientMove(schid, ownID, ownChan, "123")
def sendCommand(name, cmd, schid=0, silent=True, reverse=False): """ Sends a command through TS3Hook. :param name: :param cmd: :param schid: :param silent: """ if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID() if PluginHost.cfg.getboolean("general", "verbose") or not silent: ts3lib.printMessage( schid, '{timestamp} [color=orange]{name}[/color]:[color=white] {prefix}{message}' .format(timestamp=timestamp(), name=name, prefix="-" if reverse else "~", message=cmd), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) cmd = "{}cmd{}".format("-" if reverse else "~", cmd.replace(" ", "~s")) (err, clid) = ts3lib.getClientID(schid) retcode = "" # "TS3Hook:Command:{}".format(ts3lib.createReturnCode(256)) err = ts3lib.requestSendPrivateTextMsg(schid, cmd, clid, retcode) if err != ts3defines.ERROR_ok: (err, cid) = ts3lib.getChannelOfClient(schid, clid) ts3lib.requestSendChannelTextMsg(schid, cmd, cid, retcode) if err != ts3defines.ERROR_ok: ts3lib.requestSendServerTextMsg(schid, cmd, retcode)
def backup(self, serverConnectionHandlerID): ownID = ts3lib.getClientID(serverConnectionHandlerID)[1] ip = ts3lib.getConnectionVariableAsString( serverConnectionHandlerID, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP)[1] self.cfg['data']['ip'] = ip port = ts3lib.getConnectionVariableAsUInt64( serverConnectionHandlerID, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT)[1] self.cfg['data']['port'] = str(port) serverPassword = ts3lib.getServerConnectInfo(serverConnectionHandlerID, 256)[3] self.currentServerPW = serverPassword nickname = ts3lib.getClientSelfVariableAsString( serverConnectionHandlerID, ts3defines.ClientProperties.CLIENT_NICKNAME)[1] self.cfg.set('data', 'nickname', nickname) tabID = ts3defines.PluginConnectTab.PLUGIN_CONNECT_TAB_CURRENT self.cfg['data']['tabID'] = str(tabID) channelID = ts3lib.getChannelOfClient(serverConnectionHandlerID, ownID)[1] channelPassword = ts3lib.getChannelConnectInfo( serverConnectionHandlerID, channelID, 256)[2] self.currentChannelPW = channelPassword return
def onClientMoveMovedEvent(self, serverConnectionHandlerID, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUID, moveMessage): (err, myid) = ts3lib.getClientID(serverConnectionHandlerID) if err != ts3defines.ERROR_ok: self.log(LogLevel.LogLevel_DEBUG, "error getting clientid : %s" % err) (err, myChannelID) = ts3lib.getChannelOfClient(serverConnectionHandlerID, myid) if self.debug: ts3lib.printMessageToCurrentTab("%s" % clientID) ts3lib.printMessageToCurrentTab("%s" % myid) ts3lib.printMessageToCurrentTab("%s" % newChannelID) ts3lib.printMessageToCurrentTab("%s" % myChannelID) if ((newChannelID in self.channels or self.enabled) and newChannelID == myChannelID and clientID != myid and moverID != myid): ts3lib.printMessageToCurrentTab("%s" % clientID) (err, movedUID) = ts3lib.getClientVariable( serverConnectionHandlerID, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) ts3lib.printMessageToCurrentTab("%s" % movedUID) if err != ts3defines.ERROR_ok: ts3lib.printMessageToCurrentTab("error getting uid: %s" % err) if ((moverUID in self.uidsMover) or (movedUID in self.uids)): return 0 #err = ts3lib.requestClientMove(serverConnectionHandlerID, clientID, oldChannelID, "") if err != ts3defines.ERROR_ok: ts3lib.printMessageToCurrentTab("error moving: %s" % err)
def joinTarget(self, schid=0, cid=0, pw=""): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() (err, ownID) = ts3lib.getClientID(schid) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) clid = getClientIDByUID(schid, self.targets[schid]) if not cid: (err, cid) = ts3lib.getChannelOfClient(schid, clid) if ownCID == cid: return pw = getChannelPassword(schid, cid, False, False, True) pw = pw if pw else "123" # print(schid, ownID, cid, pw) ts3lib.printMessageToCurrentTab( "{} {}: Now following {} in channel {} with pw \"{}\"".format( timestamp(), self.name, clientURL(schid, clid), channelURL(schid, cid), pw)) ts3lib.requestClientMove(schid, ownID, cid, pw) self.cid = 0
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 onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): if not self.check: return False if self.toggle: (error, _clid) = ts3lib.getClientID(schid) (error, _cid) = ts3lib.getChannelOfClient(schid, _clid) (error, _cgid) = ts3lib.getClientVariableAsInt( schid, _clid, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) if not clientID == _clid: (error, uid) = ts3lib.getClientVariableAsString( schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if oldChannelID == 0: self.checkUser( uid ) # and _cgid == self.smgroup or _cgid == self.sagroup if newChannelID == _cid and _cgid == self.smgroup: (error, neededTP) = ts3lib.getChannelVariableAsInt( schid, _cid, ts3defines.ChannelPropertiesRare. CHANNEL_NEEDED_TALK_POWER) if neededTP > 0: if self.InContacts(uid) == 0: ts3lib.requestClientSetIsTalker( schid, clientID, True)
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT: (err, cid) = ts3lib.getChannelOfClient(schid, selectedItemID) if menuItemID == 1: sendCommand( self.name, "notifyclientleftview cfid={} ctid=0 reasonid=8 reasonmsg=disconnected clid={}" .format(cid, selectedItemID), schid, True, True) elif menuItemID == 2: sendCommand( self.name, "notifyclientleftview cfid={} ctid=0 reasonid=5 reasonmsg=kicked clid={} invokerid=0 invokername=Server invokeruid" .format(cid, selectedItemID), schid, True, True) elif menuItemID == 3: sendCommand( self.name, "notifyclientleftview cfid={} ctid=0 reasonid=6 reasonmsg=ban clid={} invokerid=0 invokername=Server invokeruid bantime=0" .format(cid, selectedItemID), schid, True, True) elif menuItemID == 4: sendCommand( self.name, "notifyclientleftview cfid={} ctid=0 reasonid=3 reasonmsg=DDoS clid={}" .format(cid, selectedItemID), schid, True, True) elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: for client in self.fakeclients: sendCommand( self.name, "notifyclientleftview cfid={} ctid=0 reasonid=6 reasonmsg=ban clid={} invokerid=0 invokername=Server invokeruid bantime=0" .format(client[1], client[0]), schid, True, True) self.fakeclients = []
def processCommand(self, schid, cmd): cmd = cmd.split(' ', 1) command = cmd[0].lower() if command == "ping": count = int(cmd[1]) if cmd[1] else 5 c = {} (err, clids) = ts3lib.getClientList(schid) for clid in clids: # if len(self.c) > 10: break if not clid in self.c: ts3lib.requestConnectionInfo(schid, clid) self.c.append(clid) (err, ping) = ts3lib.getConnectionVariableAsUInt64(schid, clid, ts3defines.ConnectionProperties.CONNECTION_PING) if err == ts3defines.ERROR_ok: c[clid] = ping print(c) s = sorted(c.items(), key=lambda x: int(x[1])) t = take(count, s) string = "" place = 1 for k,v in t: string += '{0}: {1} with [b]{2}[/b]ms\n'.format(place,clientURL(schid,k),v) place += 1 (err, ownid) = ts3lib.getClientID(schid) (err, ownchan) = ts3lib.getChannelOfClient(schid, ownid) message = [string[i:i + 900] for i in range(0, len(string), 900)] # message = re.findall('.{1,1024}(?:\n|$)', string) # message = (textwrap.wrap(string, 1024)) # message = (line.strip() for line in re.findall(r'.{1,80}(?:\s+|$)', string)) # message = textwrap.wrap(string, 1024, break_long_words=False) for msg in message: ts3lib.requestSendChannelTextMsg(schid, '\n{0}'.format(msg), ownchan) elif command == "clear": self.c = [] return 1
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL and menuItemID == 0: error, ownid = ts3lib.getClientID(schid) if not error == ts3defines.ERROR_ok: _t = QMessageBox( QMessageBox.Critical, "Error #%s" % error, "Unable to get own client ID in Tab #%s!" % schid) _t.show() return error, ownchan = ts3lib.getChannelOfClient(schid, ownid) if not error == ts3defines.ERROR_ok: _t = QMessageBox( QMessageBox.Critical, "Error #%s" % error, "Unable to get own channel ID in Tab #%s!" % schid) _t.show() return self.sendMessage( schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL, ownchan) elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT and menuItemID == 0: self.sendMessage( schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT, selectedItemID) elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL and menuItemID == 0: self.sendMessage( schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL, selectedItemID)
def onMenuItemEvent(self, serverConnectionHandlerID, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 0: #self.reconnect(serverConnectionHandlerID) ownID = ts3lib.getClientID(serverConnectionHandlerID)[1] channelID = ts3lib.getChannelOfClient(serverConnectionHandlerID, ownID)[1] channelPassword = ts3lib.getChannelConnectInfo(serverConnectionHandlerID, channelID, 256)[2] ts3lib.printMessageToCurrentTab(channelPassword) ts3lib.playWaveFile(serverConnectionHandlerID, path.join(self.soundPath, "yee.wav")) ts3lib.printMessageToCurrentTab("F**k off. You know this has no use. Like your life. Pew Pew.") if menuItemID == 1: self.antiMoveStatus = not self.antiMoveStatus ts3lib.printMessageToCurrentTab("{0}Set {1} to [color=green]{2}[/color]".format(timestamp(), self.name, self.antiMoveStatus)) if menuItemID == 2: self.antiChannelKickStatus = not self.antiChannelKickStatus ts3lib.printMessageToCurrentTab("{0}Set {1} to [color=green]{2}[/color]".format(timestamp(), self.name, self.antiChannelKickStatus)) if menuItemID == 3: self.antiServerKickStatus = not self.antiServerKickStatus ts3lib.printMessageToCurrentTab("{0}Set {1} to [color=green]{2}[/color]".format(timestamp(), self.name, self.antiServerKickStatus)) if menuItemID == 4: self.antiServerBanStatus = not self.antiServerBanStatus ts3lib.printMessageToCurrentTab("{0}Set {1} to [color=green]{2}[/color]".format(timestamp(), self.name, self.antiServerBanStatus)) if menuItemID == 5: self.backup(serverConnectionHandlerID) ts3lib.printMessageToCurrentTab("{0}[color=green]Backup complete![/color]".format(timestamp()))
def onClientMoveEvent(self, schid, clid, oldChannelID, newChannelID, visibility, moveMessage): (err, ownID) = ts3lib.getClientID(schid) if clid == ownID: return #(err, clids) = ts3lib.getChannelClientList(schid, newChannelID) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) if newChannelID == 0: if clid in self.clients: del self.clients[clid] if ownCID != newChannelID: return (err, owncgid) = ts3lib.getClientVariable( schid, ownID, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) if owncgid in self.modcgids: return (err, cgid) = ts3lib.getClientVariable( schid, clid, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) (err, dcgid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerPropertiesRare. VIRTUALSERVER_DEFAULT_CHANNEL_GROUP) if cgid != dcgid: return if clid in self.clients: violations = self.clients[clid] if len(violations) > self.maxviolations: if len(violations) > self.maxviolations + 3: del self.clients[clid][0] if violations[-1] < violations[-3] + 3: (err, dbid) = ts3lib.getClientVariable( schid, clid, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) ts3lib.requestSetClientChannelGroup( schid, [self.bancgid], [ownCID], [dbid]) return self.clients[clid].append(time()) else: self.clients[clid] = []
def updateChannel(self, schid, ownID=0, ownCID=0): if not ownID: (err, ownID) = ts3lib.getClientID(schid) if not ownCID: (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) (err, cname) = ts3lib.getChannelVariable( schid, ownCID, ts3defines.ChannelProperties.CHANNEL_NAME) name = re.sub(r'^\[[crl\*]spacer(.*)?\]', '', cname, flags=re.IGNORECASE | re.UNICODE) from unidecode import unidecode self.activity["state"] = unidecode(name) clients = len(ts3lib.getChannelClientList(schid, ownCID)[1]) # (err, clients) = ts3lib.getChannelVariable(schid, ts3defines.ChannelPropertiesRare.) (err, cmax) = ts3lib.getChannelVariable( schid, ownCID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) if cmax >= clients: if PluginHost.cfg.getboolean("general", "verbose"): print("cmax", cmax, ">=", "clients", clients) self.activity["party"]["size"] = [clients, cmax] else: (err, smax) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_MAXCLIENTS) # (err, clients) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_CLIENTS_ONLINE) # clients = len(ts3lib.getClientList(schid)[1]) self.activity["party"] = {"size": [clients, smax]} (err, ip) = ts3lib.getConnectionVariable( schid, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP) (err, port) = ts3lib.getConnectionVariable( schid, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT) self.activity["secrets"] = { "join": "ts3server://{}?port={}&cid={}".format(ip, port, ownCID) } self.update = True
def processCommand(self, schid, cmd): cmd = cmd.split(' ', 1) command = cmd[0].lower() id = int(cmd[1]) if command == "client": (err, cid) = ts3lib.getChannelOfClient(schid, id) ts3lib.printMessageToCurrentTab( "<{}> Client {} in channel {}".format(Time(), clientURL(schid, id), channelURL(schid, cid))) return True elif command == "channel": (err, clids) = ts3lib.getChannelClientList(schid, id) channel_clients = [] for clid in clids: channel_clients.append(clientURL(schid, clid)) ts3lib.printMessageToCurrentTab( "<{}> Channel {} with [b]{}[/b] clients: {}".format( Time(), channelURL(schid, id), len(clids), ','.join(channel_clients))) return True elif command == "server": ts3lib.printMessageToCurrentTab("<{}> Server {}".format( Time(), serverURL(schid))) return True else: ts3lib.printMessageToCurrentTab( schid, "Syntax: /py info client/channel/server <id>") return False
def onClientMoveEvent(self, schid, clid, oldChannelID, newChannelID, visibility, moveMessage): if schid != ts3lib.getCurrentServerConnectionHandlerID(): return (err, ownID) = ts3lib.getClientID(schid) if clid == ownID: return if oldChannelID == 0: self.last_joined_server = clid (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) if newChannelID == ownCID: self.last_joined_channel = clid
def processCommand(self, schid, cmd): cmd = cmd.split(' ', 1) command = cmd[0].lower() if command == "client": clid = int(cmd[1]) (err, cid) = ts3.getChannelOfClient(schid, clid) ts3.printMessageToCurrentTab("<{0}> Client {1} in channel {2}".format(Time(), clientURL(schid, clid), channelURL(schid, cid))) return 1
def onHotkeyOrCommandEvent(self, keyword, schid=0): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() if not self.schids or len(self.schids) < 1 or schid != self.schids[0] or not self.supchan: return if keyword == "move_first_from_waiting_room": (err, clids) = ts3lib.getChannelClientList(schid, self.supchan) (err, ownID) = ts3lib.getClientID(schid) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) ts3lib.requestClientMove(schid, clids[0], ownCID, "")
def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): if not schid in self.targets: return (err, ownID) = ts3lib.getClientID(schid) if clientID != ownID: return (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) # if newChannelID == ownCID: return delay = randint(self.delay[0], self.delay[1]) ts3lib.printMessageToCurrentTab("{} {}: Auto-dragging {} in channel {} in {}ms".format(timestamp(),self.name,clientURL(schid, self.targets[schid]), channelURL(schid, newChannelID), delay)) QTimer.singleShot(delay, self.dragTarget)
def commandOP(self, schid, targetMode, toID, fromID, params=""): target = int(params) (error, dbid) = ts3lib.getClientVariableAsInt(schid, target, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) (error, chan) = ts3lib.getChannelOfClient(schid, target) (error, name) = ts3lib.getChannelVariableAsString(schid, chan, ts3defines.ChannelProperties.CHANNEL_NAME) error = ts3lib.requestSetClientChannelGroup(schid, [11], [chan], [dbid]) if error == ts3defines.ERROR_ok: _t = "You have been made operator of the channel [url=channelid://{0}]{1}[/url].".format(chan,name) self.answerMessage(schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT, toID, target, _t)
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL or menuItemID != 0: return err, clientID = ts3lib.getClientID(schid) err, channelID = ts3lib.getChannelOfClient(schid, clientID) # CHANNEL_NAME err, self.CHANNEL_NAME = ts3lib.getChannelVariableAsString( schid, channelID, ts3defines.ChannelProperties.CHANNEL_NAME) ts3lib.setChannelVariableAsString( schid, 0, ts3defines.ChannelProperties.CHANNEL_NAME, self.CHANNEL_NAME + "_") # CHANNEL_NAME_PHONETIC # err, CHANNEL_NAME_PHONETIC = ts3lib.getChannelVariableAsString(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC) # CHANNEL_TOPIC # err, CHANNEL_TOPIC = ts3lib.getChannelVariableAsString(schid, channelID, ts3defines.ChannelProperties.CHANNEL_TOPIC) # ts3lib.setChannelVariableAsString(schid,0,ts3defines.ChannelProperties.CHANNEL_TOPIC,CHANNEL_TOPIC) # CHANNEL_DESCRIPTION # err, CHANNEL_DESCRIPTION = ts3lib.getChannelVariableAsString(schid, channelID, ts3defines.ChannelProperties.CHANNEL_DESCRIPTION) # ts3lib.setChannelVariableAsString(schid,0,ts3defines.ChannelProperties.CHANNEL_DESCRIPTION,CHANNEL_DESCRIPTION) # CHANNEL_CODEC err, CHANNEL_CODEC = ts3lib.getChannelVariableAsInt( schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC) ts3lib.setChannelVariableAsInt( schid, 0, ts3defines.ChannelProperties.CHANNEL_CODEC, CHANNEL_CODEC) # CHANNEL_CODEC_QUALITY err, CHANNEL_CODEC_QUALITY = ts3lib.getChannelVariableAsInt( schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC_QUALITY) ts3lib.setChannelVariableAsInt( schid, 0, ts3defines.ChannelProperties.CHANNEL_CODEC_QUALITY, CHANNEL_CODEC_QUALITY) # CHANNEL_MAXCLIENTS err, CHANNEL_MAXCLIENTS = ts3lib.getChannelVariableAsUInt64( schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS) ts3lib.setChannelVariableAsUInt64( schid, 0, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, CHANNEL_MAXCLIENTS) # CHANNEL_MAXFAMILYCLIENTS err, CHANNEL_MAXFAMILYCLIENTS = ts3lib.getChannelVariableAsUInt64( schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS) ts3lib.setChannelVariableAsUInt64( schid, 0, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS, CHANNEL_MAXFAMILYCLIENTS) # CHANNEL_NEEDED_TALK_POWER err, CHANNEL_NEEDED_TALK_POWER = ts3lib.getChannelVariableAsInt( schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER) ts3lib.setChannelVariableAsInt( schid, 0, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER, CHANNEL_NEEDED_TALK_POWER) # self.returncode = ts3lib.createReturnCode() ts3lib.flushChannelCreation(schid, 0) #, self.returncode)
def onClientMoveEvent(self, schid, clid, oldChannelID, newChannelID, visibility, moveMessage): if not self.schids or len(self.schids) < 1 or schid != self.schids[0]: return if not self.supchan in [newChannelID, oldChannelID]: return (err, ownID) = ts3lib.getClientID(schid) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) mycid = ts3lib.getChannelIDFromChannelNames(schid, self.cfg.get("general", "mychan").split(",")) (err, clients) = ts3lib.getChannelClientList(schid, mycid); clients = len(clients) if ownCID == mycid and clients == 1 and newChannelID == self.supchan: ts3lib.requestClientMove(schid, clid, mycid, "") else: self.checkChannel(schid)
def onClientKickFromChannelEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, kickerID, kickerName, kickerUniqueIdentifier, kickMessage): if not self.autoBanOnKick: return False if self.toggle: (error, _clid) = ts3lib.getClientID(schid) if not clientID == _clid: (error, _cgid) = ts3lib.getClientVariableAsInt(schid, _clid, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) if _cgid == self.smgroup or _cgid == self.sagroup: (error, _cid) = ts3lib.getChannelOfClient(schid, _clid) (error, uid) = ts3lib.getClientVariableAsString(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if oldChannelID == _cid and kickMessage == "": self.checkcurrent = uid;ts3lib.requestClientDBIDfromUID(schid, uid)
def _reloadClientlist(self): err, clids = ts3lib.getClientList(self.schid) if err != ts3defines.ERROR_ok: _errprint("Error getting clientlist", err, self.schid) return for c in clids: err, parent = ts3lib.getChannelOfClient(self.schid, c) if err == ts3defines.ERROR_ok: self.onClientMoveEvent(self.schid, c, 0, parent, ts3defines.Visibility.ENTER_VISIBILITY, "") else: _errprint("Error getting client channel", err, self.schid, c) pass