def serverURL(schid=None, name=None): if schid is None: try: schid = ts3lib.getCurrentServerConnectionHandlerID() except: pass if name is None: try: (error, name) = ts3lib.getServerVariable(schid, schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_NAME) except: name = schid return '[b][url=channelid://0]"{}"[/url][/b]'.format(name)
def __init__(self): self.requested = True ts3lib.requestChannelGroupList( ts3lib.getCurrentServerConnectionHandlerID()) 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 channelURL(schid=None, cid=0, name=None): if schid == None: try: schid = ts3lib.getCurrentServerConnectionHandlerID() except: pass if name == None: try: (error, name) = ts3lib.getChannelVariable(schid, cid, ChannelProperties.CHANNEL_NAME) except: name = cid return '[b][url=channelid://{0}]"{1}"[/url][/b]'.format(cid, name)
def getInterval(self, schid=0): if schid < 1: schid = ts3lib.getCurrentServerConnectionHandlerID() (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if not suid in self.interval: suid = "default" interval = randint(self.interval[suid][0]*1000, self.interval[suid][1]*1000) if PluginHost.cfg.getboolean("general", "verbose"): print("schid:", schid, "suid:", suid, "min:", self.interval[suid][0]*1000, "max:", self.interval[suid][1]*1000, "interval:", interval) return interval
def tick(self,schid=0, clid=0): if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID() if schid == 0: return _newnick = '%s%s%s'%(self.prefix, self.count, self.suffix) if self.debug: ts3lib.printMessageToCurrentTab('Tick %s: '%self.count + _newnick) ts3lib.setClientSelfVariableAsString(schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _newnick) ts3lib.flushClientSelfUpdates(schid) self.count += 1
def __init__(self): content = [] with open(self.pwpath, encoding="utf8") as f: content = f.readlines() self.pws = [x.strip() for x in content] self.timer.timeout.connect(self.tick) ts3lib.requestServerVariables(ts3lib.getCurrentServerConnectionHandlerID()) if self.debug: ts3lib.printMessageToCurrentTab("{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded.".format(timestamp(),self.name,self.author))
def __init__(self): schid = ts3lib.getCurrentServerConnectionHandlerID() self.requested = True ts3lib.requestChannelGroupList(schid) if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author))
def onHotkeyOrCommandEvent(self, keyword, schid=0): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() # (err, status) = ts3lib.getConnectionStatus(schid) # if status != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: return arguments = [] if keyword == "yatqa_start": pass elif keyword == "yatqa_connect_current": (err, ownID) = ts3lib.getClientID(schid) (err, ip) = ts3lib.getConnectionVariable( schid, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP) (err, port) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_PORT) title = ("{} > {}".format(self.name, ip)) qport = inputInt(title, "Query Port:", 10011, 1, 65535) name = inputBox(title, "Query Login Name:", "serveradmin") pw = inputBox( title, "Query Login Password:"******"") args = ["-c", ip, qport] if name and pw: args.extend([name, pw, port]) else: args.append(port) self.yatqa.setArguments( args) # IP Query_Port [User Pass] [Voice_Port] elif keyword == "yatqa_stats_current": (err, ownID) = ts3lib.getClientID(schid) (err, ip) = ts3lib.getConnectionVariable( schid, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP) (err, port) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_PORT) self.yatqa.setArguments(["-s", ip, port]) # IP elif keyword == "yatqa_blacklist_current": (err, ownID) = ts3lib.getClientID(schid) (err, ip) = ts3lib.getConnectionVariable( schid, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP) self.yatqa.setArguments(["-b", ip]) # IP elif keyword == "yatqa_lookup_dns": (err, host, port, pw) = ts3lib.getServerConnectInfo(schid) self.yatqa.setArguments(["-d", host]) elif keyword == "yatqa_browse_icons": (err, suid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties. VIRTUALSERVER_UNIQUE_IDENTIFIER) self.yatqa.setArguments(["-i", suid]) elif keyword == "yatqa_permission_editor": self.yatqa.setArguments(["-p"]) elif keyword == "yatqa_connect_default": self.yatqa.setArguments(["-a"]) else: return False if PluginHost.cfg.getboolean("general", "verbose"): print(self.bin, self.yatqa.arguments()) self.yatqa.start() return True
def __init__(self): schid = ts3lib.getCurrentServerConnectionHandlerID() (err, status) = ts3lib.getConnectionStatus(schid) if err == ts3defines.ERROR_ok and status == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: self.saveTab(schid) self.log( LogLevel.LogLevel_DEBUG, "Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(self.timestamp(), self.name, self.author))
def dragTarget(self, schid=0): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() (err, ownID) = ts3lib.getClientID(schid) (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) clid = self.targets[schid] (err, cid) = ts3lib.getChannelOfClient(schid, clid) if ownCID == cid: return (err, path, pw) = ts3lib.getChannelConnectInfo(schid, ownCID) ts3lib.requestClientMove(schid, clid, ownCID, pw)
def disconnect(self, schid=0, close_tab=False): if schid < 1: schid = ts3lib.getCurrentServerConnectionHandlerID() (err, status) = ts3lib.getConnectionStatus(schid) if status != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: return clipboard = QApplication.clipboard().text() msg = inputBox("Disconnect", "Message", clipboard) if close_tab: self.schid = schid ts3lib.stopConnection(schid, msg if msg else "")
def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: schid = ts3.getCurrentServerConnectionHandlerID() (error, item) = ts3.getClientDisplayName(schid, selectedItemID) ts3.printMessageToCurrentTab( '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.datetime.now()) + " [color=green]Added[/color] [color=yellow]" + item + "[/color] to Report Moderators.") if menuItemID == 1: schid = ts3.getCurrentServerConnectionHandlerID() (error, item) = ts3.getClientDisplayName(schid, selectedItemID) ts3.printMessageToCurrentTab( '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.datetime.now()) + " [color=red]Removed[/color] [color=yellow]" + item + "[/color] from Report Moderators.") if menuItemID == 2: self.dlg = ReportDialog(None) self.dlg.show()
def onSearch(name, flags, isRepeat, searchAllTabs, found): #TODO: this try: if not searchAllTabs: if self.schid != ts3lib.getCurrentServerConnectionHandlerID(): return #ret = self.svmodel.find(name, flags) #ts3lib.printMessageToCurrentTab(str(ret)) except: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
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 loadVars(self, schid=False): if not schid: return; schid = ts3lib.getCurrentServerConnectionHandlerID() self.purgeDB(schid) # for cid in clist: if schid in self.cgroups: return self.cgroups[schid] = {"groups": {}} self.requestedCGroups = True;self.requestedRVars = True ts3lib.requestChannelGroupList(schid) ts3lib.requestServerVariables(schid) if PluginHost.cfg.getboolean("general", "verbose"): print(self.name, ">", "requested vars for #", schid)
def __init__(self): loadCfg(self.path + "/config.ini", self.cfg) loadCfg(self.path + "/channel.ini", self.chan) with open(self.path + "/description.txt", 'r') as myfile: self.description = myfile.read() self.checkServer(ts3lib.getCurrentServerConnectionHandlerID()) if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author))
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 log(self, logLevel, message, schid=0): ts3lib.logMessage(message, logLevel, self.name, schid) if logLevel in [LogLevel.LogLevel_DEBUG, LogLevel.LogLevel_DEVEL ] and self.debug: ts3lib.printMessage( schid if schid else ts3lib.getCurrentServerConnectionHandlerID(), '{timestamp} [color=orange]{name}[/color]: {message}'.format( timestamp=timestamp(), name=self.name, message=message), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
def getIDByName(name: str, schid: int = 0): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() err, sname = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_NAME) if sname == name: return 0, ServerTreeItemType.SERVER cid = getChannelIDByName(name, schid) if cid: return cid, ServerTreeItemType.CHANNEL clid = getClientIDByName(name, schid, use_displayname=True) if clid: return clid, ServerTreeItemType.CLIENT return 0, ServerTreeItemType.UNKNOWN
def onHotkeyEvent(self, keyword): if keyword == "toggleMove": self.antiMoveStatus = not self.antiMoveStatus schid = ts3lib.getCurrentServerConnectionHandlerID() if self.antiMoveStatus: ts3lib.playWaveFile(schid, path.join(self.soundPath, "on.wav")) else: ts3lib.playWaveFile(schid, path.join(self.soundPath, "off.wav")) ts3lib.printMessageToCurrentTab("{0}{1}: Set Anti-Move to [color=green]{2}[/color]".format(timestamp(), self.name, self.antiMoveStatus)) return
def __init__(self): schid = ts3lib.getCurrentServerConnectionHandlerID() err, clid = ts3lib.getClientID(schid) err, cid = ts3lib.getChannelOfClient(schid, clid) (err, cgid) = ts3lib.getClientSelfVariable( schid, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) if cgid == 9: self.mychan = cid if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author))
def checkMenus(self, schid=0): if not self.name in PluginHost.active: return if schid < 1: schid = ts3lib.getCurrentServerConnectionHandlerID() err, status = ts3lib.getConnectionStatus(schid) if status != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: return (err, suid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if suid != self.suid: self.toggleMenus(False) else: self.toggleMenus(True)
def loadAvatars(self): pics = [] schid = ts3.getCurrentServerConnectionHandlerID() err, clients = ts3.getClientList(schid) for client in clients: err, avatar = ts3.getAvatar(schid, client, 256) if avatar != None: pics.append(avatar) self.count = len(pics) self.ac.populate(pics)
def __init__(self): if path.isfile(self.ini): self.cfg.read(self.ini) else: self.cfg['general'] = {"cfgversion": "1", "debug": "False", "enabled": "True", "infodata": "False", "activeonly": "False"} with open(self.ini, 'w') as cfg: self.cfg.write(cfg) schid = ts3.getCurrentServerConnectionHandlerID() err, status = ts3.getConnectionStatus(schid) if not err and status == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: self.setMeta(ts3.getCurrentServerConnectionHandlerID()) if pluginhost.PluginHost.cfg.getboolean("general", "verbose"): ts3.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 clientURL(schid=None, clid=0, uid=None, nickname=None): if schid == None: try: schid = ts3lib.getCurrentServerConnectionHandlerID() except: pass if uid == None: try: (error, uid) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) except: pass if nickname == None: try: (error, nickname) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientProperties.CLIENT_NICKNAME) except: nickname = uid return '[url=client://{0}/{1}]{2}[/url]'.format(clid, uid, nickname)
def getChannelIDByName(name: str, schid: int = 0, multi: bool = False): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() if multi: results = [] (err, cids) = ts3lib.getChannelList(schid) for cid in cids: (err, _name) = ts3lib.getChannelVariable( schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME) if name == _name: if multi: results.append(cid) else: return cid if multi and len(results): return results
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 loadVars(self, schid=False): if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID() self.purgeDB(schid) # for cid in clist: if schid in self.cgroups: return self.cgroups[schid] = {"groups": {}} self.requestedCGroups = True self.requestedRVars = True ts3lib.requestChannelGroupList(schid) ts3lib.requestServerVariables(schid) print(self.name, ">", "requested vars for #", schid)
def __init__(self): if self.enabled: schid = ts3lib.getCurrentServerConnectionHandlerID() (err, status) = ts3lib.getConnectionStatus(schid) if status == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: err, clid = ts3lib.getClientID(schid) err, self.mychan = ts3lib.getChannelOfClient(schid, clid) self.schid = schid if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author))
def __init__(self): self.ts3host = ts3SessionHost(self) schid = ts3lib.getCurrentServerConnectionHandlerID() (err, status) = ts3lib.getConnectionStatus(schid) self.onConnectStatusChangeEvent(schid, status, err) if PluginHost.cfg.getboolean("general", "verbose"): i = 1 for active in PluginHost.active: print(i, active) i += 1 ts3lib.printMessageToCurrentTab( "{0}[color=orange]{1}[/color] Plugin for pyTSon by [url=https://github.com/{2}]{2}[/url] loaded." .format(timestamp(), self.name, self.author))