class countNick(ts3plugin): name = "Count Nickname" apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle Auto incrementing nickname", "")] hotkeys = [] timer = None debug = False prefix = "Ich bin " suffix = " jahre alt" count = 0 @staticmethod def timestamp(): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): 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 onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: if self.timer == None: self.timer = QTimer() self.timer.timeout.connect(self.tick) if self.timer.isActive(): self.timer.stop() self.timer = None ts3lib.printMessageToCurrentTab('Timer stopped!') else: self.timer.start(1000) ts3lib.printMessageToCurrentTab('Timer started!') ts3lib.printMessageToCurrentTab( "{0}Set {1} to [color=yellow]{2}[/color]".format( self.timestamp(), self.name, self.toggle)) 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
class autoCommander(ts3plugin): name = "Auto Channel Commander" apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "Automatically enable channel commander when switching channels.\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle Auto Channel Commander", ""), (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 1, "Toggle Channel Commander Spam", "")] hotkeys = [] debug = False toggle = False timer = None schid = 0 current = False requested = False mod_names = ["ADMIN", "MOD", "OPERATOR"] smgroup = [] @staticmethod def timestamp(): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): 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 toggleTimer(self, schid): if self.timer is None: self.timer = QTimer() self.timer.timeout.connect(self.tick) if self.timer.isActive(): self.timer.stop() self.timer = None ts3lib.printMessageToCurrentTab('Timer stopped!') else: step = inputBox(self.name, 'Interval in Milliseconds:') if step: interval = int(step) else: interval = 1000 self.schid = schid self.timer.start(interval) ts3lib.printMessageToCurrentTab('Timer started!') def tick(self): self.current = not self.current ts3lib.setClientSelfVariableAsInt( self.schid, ts3lib.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, self.current) ts3lib.flushClientSelfUpdates(self.schid) def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: self.toggle = not self.toggle ts3lib.printMessageToCurrentTab( "{0}Set {1} to [color=yellow]{2}[/color]".format( self.timestamp(), self.name, self.toggle)) elif menuItemID == 1: self.toggleTimer(schid) def onConnectStatusChangeEvent(self, serverConnectionHandlerID, newStatus, errorNumber): if not self.toggle: return if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHING: self.requested = True ts3lib.requestChannelGroupList( ts3lib.getCurrentServerConnectionHandlerID()) def onChannelGroupListEvent(self, serverConnectionHandlerID, channelGroupID, name, atype, iconID, saveDB): if not self.toggle: return if self.requested == True: for _name in self.mod_names: if name.upper().__contains__(_name): self.smgroup.extend([channelGroupID]) def onChannelGroupListFinishedEvent(self, serverConnectionHandlerID): if self.toggle: self.requested = False # def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): #if not self.toggle: return # (error, cID) = ts3lib.getClientID(schid) # if error == ts3defines.ERROR_ok: # if cID == clientID: # ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, 1) # ts3lib.flushClientSelfUpdates(schid) # # def onClientMoveMovedEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUniqueIdentifier, moveMessage): # if not self.toggle: return # (error, cID) = ts3lib.getClientID(schid) # if error == ts3defines.ERROR_ok: # if cID == clientID: # ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientPropertiesRare.CLIENT_IS_CHANNEL_COMMANDER, 1) # ts3lib.flushClientSelfUpdates(schid) def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity): if not self.toggle: return (error, cID) = ts3lib.getClientID(schid) if error == ts3defines.ERROR_ok: if cID == clientID: (error, cgID) = ts3lib.getClientVariableAsInt( schid, cID, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID) for _group in self.smgroup: if cgID == _group: ts3lib.setClientSelfVariableAsInt( schid, ts3defines.ClientPropertiesRare. CLIENT_IS_CHANNEL_COMMANDER, 1) ts3lib.flushClientSelfUpdates(schid) break
class pingNick(ts3plugin): name = "Ping Nickname" apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "Automatically enable channel commander when switching channels.\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle Auto Ping as nickname", "")] hotkeys = [] timer = None debug = False prefix = "" suffix = "ms :O" int = 0 lastPing = 0 @staticmethod def timestamp(): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): 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 onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: if self.timer == None: self.timer = QTimer() self.timer.timeout.connect(self.tick) if self.timer.isActive(): self.timer.stop() self.timer = None ts3lib.printMessageToCurrentTab('Timer stopped!') else: self.timer.start(1000) ts3lib.printMessageToCurrentTab('Timer started!') ts3lib.printMessageToCurrentTab( "{0}Set {1} to [color=yellow]{2}[/color]".format( self.timestamp(), self.name, self.toggle)) def tick(self, schid=0, clid=0): if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID() if clid == 0: (err, clid) = ts3lib.getClientID(schid) if schid == 0 or clid == 0: return if self.debug: self.int += 1 ts3lib.printMessageToCurrentTab('Tick %s' % self.int) (err, ping) = ts3lib.getConnectionVariableAsUInt64( schid, clid, ts3defines.ConnectionProperties.CONNECTION_PING) if ping == self.lastPing: return ts3lib.setClientSelfVariableAsString( schid, ts3defines.ClientProperties.CLIENT_NICKNAME, "{0}{1}{2}".format(self.prefix, ping, self.suffix)) ts3lib.flushClientSelfUpdates(schid) self.lastPing = ping
class showQueries(ts3plugin): name = "Query Viewer" apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "Shows you queries in channels.\n\nHomepage: https://github.com/Bluscream/Extended-Info-Plugin\n\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "query" infoTitle = "[b]Queries:[/b]" menuItems = [] hotkeys = [] debug = False timer = QTimer() cleartimer = QTimer() schid = 0 queries = [] hqueries = [] hqueries_cache = [] query_uids = ["serveradmin", "ServerQuery"] waitingFor = "" retcode = "" def __init__(self): self.cleartimer.timeout.connect(self.clearQueries) self.cleartimer.start(1000*18000) if self.debug: ts3lib.printMessageToCurrentTab("[{0} {1}] [color=orange]{2}[/color] Plugin for pyTSon by [url=https://github.com/{3}]{4}[/url] loaded.".format(date(), Time(), self.name, self.author)) def stop(self): self.timer.stop() self.timer = None del self.timer self.timer = QTimer() def onConnectStatusChangeEvent(self, schid, status, errorNumber): if status == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: self.schid = schid self.timer.timeout.connect(self.checkQueries) self.timer.start(1000) ts3lib.printMessageToCurrentTab('Timer started!') elif status == ts3defines.ConnectStatus.STATUS_DISCONNECTED: if self.timer.isActive(): self.timer.stop() self.schid = 0 ts3lib.printMessageToCurrentTab('Timer stopped!') def checkQueries(self): (err, clist) = ts3lib.getClientList(self.schid) for c in clist: if c in self.queries: continue else: (err, ctype) = ts3lib.getClientVariable(self.schid, c, ts3defines.ClientPropertiesRare.CLIENT_TYPE) if ctype != ts3defines.ClientType.ClientType_SERVERQUERY: continue self.queries.append(c) (err, cid) = ts3lib.getChannelOfClient(self.schid, c) # (err, channelname) = ts3lib.getChannelVariable(self.schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME) ts3lib.printMessage(self.schid, "<{0}> Found Query {1} in channel {2}".format(Time(), clientURL(self.schid, c), channelURL(self.schid, cid)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) # self.waitingFor = self.query_uids[0] # self.retcode = ts3lib.createReturnCode() # ts3lib.requestClientIDs(self.schid, self.query_uids[0], self.retcode) def clearQueries(self): self.queries = [] ts3lib.printMessage(self.schid, "<{0}> Cleared Query List".format(Time()), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) def infoData(self, schid, id, atype): try: if atype == ts3defines.PluginItemType.PLUGIN_CHANNEL: (error, clist) = ts3lib.getChannelClientList(schid, id) i = [] for c in clist: (error, clienttype) = ts3lib.getClientVariable(schid, c, ts3defines.ClientPropertiesRare.CLIENT_TYPE) if clienttype == ts3defines.ClientType.ClientType_SERVERQUERY: i.append(clientURL(schid, c)) if len(i) < 1: return else: return i except: return def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): # if oldChannelID != 0: return (err, clienttype) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_TYPE) if clienttype != ts3defines.ClientType.ClientType_SERVERQUERY: return # (err, channelname) = ts3lib.getChannelVariable(schid, newChannelID, ts3defines.ChannelProperties.CHANNEL_NAME) if visibility == ts3defines.Visibility.ENTER_VISIBILITY: ts3lib.printMessage(schid, "<{0}> {1} enters view to channel {2}".format(Time(), clientURL(schid, clientID), channelURL(schid, newChannelID)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) elif visibility == ts3defines.Visibility.LEAVE_VISIBILITY: ts3lib.printMessage(schid, "<{0}> {1} leaves from channel {2}{3}".format(Time(), clientURL(schid, clientID), channelURL(schid, oldChannelID), " ({})".format(moveMessage) if moveMessage else ""), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) else: ts3lib.printMessage(schid, "<{0}> {1} switched from channel {2} to {3}".format(Time(), clientURL(schid, clientID), channelURL(schid, oldChannelID), channelURL(schid, newChannelID)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) # <16:11:43> "charlie sheen" switched from channel "Intros Gratis <3" to "Serverteam-Gesucht Builder" def onClientIDsEvent(self, schid, uid, clid, nickname): # print('{0} == {1}: {2}'.format(uid, self.waitingFor, uid == self.waitingFor)) if not uid == self.waitingFor: return (err, chan) = ts3lib.getChannelOfClient(schid, clid) if err != ts3defines.ERROR_ok: self.hqueries.append((clid, uid, nickname)) def onClientIDsFinishedEvent(self, schid): if not self.waitingFor in self.query_uids: return if len(self.hqueries) > 0: # qstring = ", ".join("[url=client://{0}/{1}]{2}[/url]".format(tup) for tup in self.queries) qlist = ["[url=client://{}/{}]{}[/url]".format(*tup) for tup in self.hqueries] qstring = ", ".join(qlist) ts3lib.printMessage(schid, "<{0}> Found {1} hidden Queries with UID \"{2}\": {3}".format(Time(), len(self.hqueries), self.waitingFor, qstring), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) self.hqueries = [] if self.waitingFor == self.query_uids[0]: self.waitingFor = self.query_uids[-1] ts3lib.requestClientIDs(schid, self.query_uids[-1], self.retcode) if self.waitingFor == self.query_uids[-1]: self.waitingFor = False def onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage): if returnCode == self.retcode: return True def printQueries(self): (err, schids) = ts3lib.getServerConnectionHandlerList() for schid in schids: (err, cids) = ts3lib.getChannelList(schid) for cid in cids: (err, clids) = ts3lib.getChannelClientList(schid, cid) msg = [] for clid in clids: (err, ctype) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientPropertiesRare.CLIENT_TYPE) if ctype != ts3defines.ClientType.ClientType_SERVERQUERY: continue msg.append(clientURL(schid, clid)) if len(msg) < 1: continue ts3lib.printMessage(schid, "<{0}> {1} has [b]{2}[/b] Query Clients: {3}".format(Time(), channelURL(schid, cid), len(msg), ", ".join(msg)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) self.waitingFor = self.query_uids[0] self.retcode = ts3lib.createReturnCode() ts3lib.requestClientIDs(schid, self.query_uids[0], self.retcode) def processCommand(self, schid, cmd): cmd = cmd.split(' ', 1) command = cmd[0].lower() if command == "list": self.printQueries() return 1
class nowPlaying(ts3plugin): name = "Now Playing" apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "Now playing plugin in pyTSon" offersConfigure = True commandKeyword = "info" infoTitle = "[b]"+name+":[/b]" menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle Now Playing", "")] hotkeys = [] ini = path.join(ts3lib.getConfigPath(), "plugins", "pyTSon", "scripts", "nowPlaying", "settings.ini") cfg = configparser.ConfigParser() cfg.optionxform = str timer = None schid = 0 prefix = "" suffix = "" interval = 10000 enabled = False def __init__(self): self.dlg = None if path.isfile(self.ini): self.cfg.read(self.ini) else: self.cfg['general'] = { "Debug": "False" } self.cfg['nowplaying'] = { "client_nickname": "{title}" } with open(self.ini, 'w') as configfile: self.cfg.write(configfile) # self.timer.timeout.connect(self.tick) if self.cfg.getboolean('general', '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 onConnectStatusChangeEvent(self, schid, newStatus, errorNumber): if not self.enabled: return if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: self.schid = schid;self.timer.start(self.interval) elif newStatus == ts3defines.ConnectStatus.STATUS_DISCONNECTED: self.schid = 0;self.timer.stop() def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: if self.timer is None: self.timer = QTimer() self.timer.timeout.connect(self.tick) if self.timer.isActive(): self.timer.timeout.disconnect(self.tick) self.timer.stop() self.timer = None del self.timer ts3lib.printMessageToCurrentTab('Timer stopped!') else: self.timer.start(self.interval) ts3lib.printMessageToCurrentTab('Timer started!') self.enabled = not self.enabled ts3lib.printMessageToCurrentTab("{0}Set {1} to [color=yellow]{2}[/color]".format(self.timestamp(),self.name,self.toggle)) def buildString(self, value): return "{0}{1}{2}".format(self.prefix, value.replace('{title}',spotilib.song()).replace('{artist}',spotilib.artist()).replace('{artists}',spotimeta.artists()), self.suffix) def getString(self, value): return self.cfg.get('nowplaying', value) def tick(self): if self.getString('client_nickname') != "": ts3lib.setClientSelfVariableAsString(self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, self.buildString(self.getString('client_nickname'))) ts3lib.flushClientSelfUpdates(self.schid) def configDialogClosed(self, r, vals): try: ts3lib.printMessageToCurrentTab("vals: "+str(vals)) if r == QDialog.Accepted: for name, val in vals.items(): try: if not val == self.cfg.getboolean('general', name): self.cfg.set('general', str(name), str(val)) except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0) with open(self.ini, 'w') as configfile: self.cfg.write(configfile) except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0) def configure(self, qParentWidget): try: if not self.dlg: self.dlg = SettingsDialog(self) self.dlg.show() self.dlg.raise_() self.dlg.activateWindow() except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
class rotateNick(ts3plugin): name = "Rotate Nickname" apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "Converts your nickname into an ugly marquee\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle rotating nickname", "")] hotkeys = [] timer = None debug = False max = ts3defines.TS3_MAX_SIZE_CLIENT_NICKNAME_NONSDK nick = "TeamspeakUser" seperator = "꧂" schid = 0 i = max - 2 b = 0 dlg = None ini = path.join(ts3lib.getPluginPath(), "pyTSon", "scripts", "rotateNick", "config.ini") config = configparser.ConfigParser() def separator(self, sep=None): if sep: self.config.set('general', 'separator', sep.replace(" ", "\s")) else: return self.config.get('general', 'separator').replace("\s", " ") @staticmethod def timestamp(): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): if path.isfile(self.ini): self.config.read(self.ini) else: self.config["general"] = { "cfgver": "1", "debug": "False", "nick": "TeamspeakUser", "customNick": "False", "interval": "1000", "separator": " " } with open(self.ini, 'w') as configfile: self.config.write(configfile) # if self.timer is None: self.timer = QTimer() self.timer.timeout.connect(self.tick) 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 stop(self): self.stopTimer() def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: if hasattr(self.timer, "isActive") and self.timer.isActive(): self.stopTimer() else: self.schid = schid if not self.dlg: self.dlg = dialog(self) self.dlg.show() self.dlg.raise_() self.dlg.activateWindow() def startTimer(self, interval=1000, nick=None): try: self.nick = nick # if len(nick) > self.max-2: errorMsgBox("Error", "Nickname must be %s chars or below!"%self.max); return self.i = self.max - 2 self.b = 0 # step = inputBox(self.name, 'Interval in Milliseconds:') # if step: interval = int(step) # else: interval = 300 self.timer.start(interval) ts3lib.printMessageToCurrentTab('Timer started!') except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0) def stopTimer(self): if hasattr(self.timer, "isActive") and self.timer.isActive(): self.timer.stop() # self.timer = None ts3lib.setClientSelfVariableAsString( self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, self._nick) ts3lib.flushClientSelfUpdates(self.schid) ts3lib.printMessageToCurrentTab('Timer stopped!') def tick(self): try: if self.schid == 0: return max = self.max - 1 _nick = list(self.nick) if self.i == (len(_nick) * -1) + 2: self.i = max self.b = 0 self.i -= 1 self.b += 1 # ts3lib.printMessageToCurrentTab("self.i == %s | self.b == %s"%(self.i,self.b)) count = 0 newnick = ["!"] for k in range(0, self.i): newnick.append(self.separator()) count += 1 if self.i > 1: for k in range(0, self.b): if k < len(_nick) and k < max: newnick.append(_nick[k]) # ts3lib.printMessageToCurrentTab("1: {} | 2: {} | 3: {}".format(0, self.b, self._nick[k])) count += 1 else: pass #for k in range(count, max): #newnick.append(separator()) else: for k in range(self.i * -1, len(_nick)): if k != -1 and count < max: newnick.append(_nick[k]) count += 1 #for k in range(count, max): #newnick.append(self.separator()) # newnick.append("!") _newnick = ''.join(newnick) if _newnick is None: return # ts3lib.printMessageToCurrentTab("length: {} | newnick: \"{}\"".format(len(_newnick), _newnick)) ts3lib.setClientSelfVariableAsString( self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _newnick) ts3lib.flushClientSelfUpdates(self.schid) except: from traceback import format_exc ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
class antiAFK(ts3plugin): name = "Anti AFK" apiVersion = 22 requestAutoload = True version = "1.0" author = "Bluscream" description = "Never get moved by being AFK again." offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle " + name, "")] hotkeys = [] debug = False timer = None schid = 0 clid = 0 text = "." @staticmethod def timestamp(): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): 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 stop(self): if hasattr(self.timer, "isActive") and self.timer.isActive(): self.toggleTimer(self.schid) def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL and menuItemID == 0: self.toggleTimer(schid) def toggleTimer(self, schid): if self.timer is None: self.timer = QTimer() self.timer.timeout.connect(self.tick) if self.timer.isActive(): self.timer.stop() self.timer = None ts3lib.printMessageToCurrentTab('Timer stopped!') else: self.schid = schid err, self.clid = ts3lib.getClientID(schid) self.timer.start(randint(30 * 1000, 120 * 1000)) ts3lib.printMessageToCurrentTab('Timer started!') def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber): if newStatus == ts3defines.ConnectStatus.STATUS_DISCONNECTED: if hasattr(self.timer, "isActive") and self.timer.isActive(): self.toggleTimer(schid) def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored): if fromID == self.clid and targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT and message == self.text: return 1 def tick(self): ts3lib.requestSendPrivateTextMsg(self.schid, self.text, self.clid)
class countNick(ts3plugin): name = "Rotate Nickname" apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "Converts your nickname into an ugly marquee\n\nCheck out https://r4p3.net/forums/plugins.68/ for more plugins." offersConfigure = False commandKeyword = "" infoTitle = None menuItems = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, "Toggle rotating nickname", "")] hotkeys = [] timer = None debug = False max = ts3defines.TS3_MAX_SIZE_CLIENT_NICKNAME_NONSDK nick = "TeamspeakUser" seperator = " " _nick = [] schid = 0 i = max - 2 b = 0 @staticmethod def timestamp(): return '[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now()) def __init__(self): 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 onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID): if menuItemID == 0: if self.timer is None: self.timer = QTimer() self.timer.timeout.connect(self.tick) if self.timer.isActive(): self.timer.stop() self.timer = None ts3lib.setClientSelfVariableAsString( schid, ts3defines.ClientProperties.CLIENT_NICKNAME, self.nick) ts3lib.flushClientSelfUpdates(schid) ts3lib.printMessageToCurrentTab('Timer stopped!') else: (err, nick) = ts3lib.getClientSelfVariable( schid, ts3defines.ClientProperties.CLIENT_NICKNAME) if len(nick) > self.max - 2: errorMsgBox( "Error", "Nickname must be %s chars or below!" % self.max) return self.nick = nick self._nick = list(nick) self.i = self.max - 2 self.b = 0 self.schid = schid step = inputBox(self.name, 'Interval in Milliseconds:') if step: interval = int(step) else: interval = 300 self.timer.start(interval) ts3lib.printMessageToCurrentTab('Timer started!') def tick(self): if self.schid == 0: return _newnick = self.fillnick() if _newnick is None: return ts3lib.printMessageToCurrentTab("length: {} | newnick: \"{}\"".format( len(_newnick), _newnick)) ts3lib.setClientSelfVariableAsString( self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _newnick) ts3lib.flushClientSelfUpdates(self.schid) def fillnick(self): max = self.max - 2 if self.i == (len(self._nick) * -1): self.i = max self.b = 0 self.i -= 1 self.b += 1 ts3lib.printMessageToCurrentTab("self.i == %s | self.b == %s" % (self.i, self.b)) count = 0 newnick = ["!"] for k in range(0, self.i): newnick.append(self.seperator) count += 1 if self.i > 1: for k in range(0, self.b): if k < len(self._nick): #k anpassen das nicht über _nick len newnick.append(self._nick[k]) #((k+1)-self.max) * -1]) ts3lib.printMessageToCurrentTab( "1: {} | 2: {} | 3: {}".format(0, self.b, self._nick[k])) count += 1 else: pass for k in range(count, max): newnick.append(self.seperator) else: for k in range(self.i * -1, len(self._nick)): if k == -1: pass else: newnick.append(self._nick[k]) count += 1 for k in range(count, max): newnick.append(self.seperator) newnick.append("!") return ''.join(newnick)