def on_navigate(self, page=1, direction=0): try: if self.cooldown_page: self.status.setText("You have to wait " + str(self.cooldown_time_page / 1000) + " second(s) before switching pages!") palette = QPalette() palette.setColor(QPalette.Foreground, Qt.red) self.status.setPalette(palette) return if direction == 2: self.page += page elif direction == 1: self.page -= page else: self.page = page self.listServers() if not self.cooldown: self.cooldown_page = True self.previous.setEnabled(False) self.next.setEnabled(False) self.first.setEnabled(False) self.last.setEnabled(False) QTimer.singleShot(self.cooldown_time_page, self.disable_cooldown_page) except: ts3.logMessage(traceback.format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
def restoreTabs(self): try: err, schids = ts3lib.getServerConnectionHandlerList() if err != ERROR_ok: return if len(schids) > 1: return for schid in schids: (err, status) = ts3lib.getConnectionStatus(schid) if err != ERROR_ok: return if status != ConnectStatus.STATUS_DISCONNECTED: return self._tabs = {} self._timers = [] with open(self.backup_file) as f: self._tabs = load(f) i = 0 self._delay = self.delay for tab in self._tabs: i += 1 # if self._tabs[tab]["status"] == ConnectStatus.STATUS_CONNECTION_ESTABLISHED: timer = QTimer() self._timers.append(timer) timer.singleShot(self._delay, self.restoreTab) # self.restoreTab(tab) self._delay += self.increase except: ts3lib.logMessage(format_exc(), LogLevel.LogLevel_ERROR, "pyTSon", 0)
def nextsong(self): meta = self.vlc.meta() if len(meta) > 0: self.vlc.dequeue(meta[0].get('id')) if len(meta) == 1 or not self.playing: self.playing = False self.nickname() return if len(meta) > 1: song = meta[1] name = song.get('name') duration = song.get('duration') if '?v=' in name: err, duration = yt_get_duration(name, CONFIG.get('token')) if err: return debug(err) err, name = yt_get_name(name, CONFIG.get('token')) if err: return debug(err) self.vlc.play() print(name, duration) self.nickname(song = name) cinfo(f'[COLOR=#0AF]▶[/COLOR] {name}') QTimer.singleShot(duration * 1000, self.nextsong)
def __init__(self): if "aaa_ts3Ext" in PluginHost.active: ts3ext = PluginHost.active["aaa_ts3Ext"] self.ts3host = ts3ext.ts3host self.tabs = ts3ext.tabs else: QTimer.singleShot(500, self.__init__) 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 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 onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage): if not returnCode in self.retcodes: return False reason = "finished" self.perms["processed"] += 1 if error == ERROR_ok: self.perms["success"] += 1 elif error == ERROR_client_is_flooding: self.perms["fail"] += 1 self.perms["stop"] = True reason = "failed because of flooding" elif error in [ ERROR_permissions_client_insufficient, ERROR_permissions_insufficient_group_power, ERROR_permissions_insufficient_permission_power ]: self.perms["fail"] += 1 # if self.perms["stop"]: self.retcodes = {} # else: del self.retcodes[returnCode] if not len(self.retcodes): ts3lib.printMessage( schid, "{} {} {}".format(self.name, reason, self.perms), PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) if self.perms["stop"]: self.flood = True QTimer.singleShot(5000, self.disableFlood) elif self.perms["success"] > 0: self.getFullPerms(schid) return True
def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored): if fromUniqueIdentifier != "serveradmin": return False if fromName != self.gommeBotNick: return False if message.endswith(self.msg): self.schid = schid; self.gommeBotID = fromID QTimer.singleShot(self.delay, self.sendMessage) elif message in self.welcomeMSG: return True elif message == self.blockMSG: QTimer.singleShot(self.delay, self.sendMessage)
def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): if not schid in self.targets: return (err, ownID) = ts3lib.getClientID(schid) if not clientID in [ownID,self.targets[schid]] : return # (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID) 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 onConnectStatusChangeEvent(self, schid, newStatus, errorNumber): if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: self.schid = schid QTimer.singleShot(10000, self.checkServer) if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab(self.name+"> Checking for channel in 10 seconds") elif newStatus == ts3defines.ConnectStatus.STATUS_DISCONNECTED: if schid in self.schids: self.schids.remove(schid) if len(self.schids) < 1 and self.supchan: self.deleteChan()
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 on_reload_clicked(self): try: self.listServers() if not self.cooldown: self.cooldown = True self.reload.setEnabled(False) QTimer.singleShot(self.cooldown_time, self.disable_cooldown) except: ts3.logMessage(traceback.format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
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
def onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage): if hasattr(self, "retcode") and self.retcode == returnCode: self.retcode = None self.setAvatar(schid, self.tmp) try: remove(self.tmp) self.tmp = None except: QTimer.singleShot(500, self.deltmp)
def onClientKickFromServerEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, kickerID, kickerName, kickerUniqueIdentifier, kickMessage): self.log(LogLevel.LogLevel_DEBUG, "kicked") if kickerID == clientID: return if clientID != self.tabs[schid]["clid"]: return if kickerUniqueIdentifier in self.whitelistUIDs: return if schid not in self.tabs: return if self.delay > 0: self.schid = schid QTimer.singleShot(self.delay, self.reconnect) else: self.reconnect(schid)
def onClientMoveMovedEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUniqueIdentifier, moveMessage): (err, ownID) = ts3lib.getClientID(schid) if clientID != ownID or moverID == ownID: return (err, sgids) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS) if set(sgids).isdisjoint(self.whitelistSGIDs): return (err, uid) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if uid in self.whitelistUIDs: return self.schid=schid;self.clid=ownID;self.cid=oldChannelID if self.delay >= 0: QTimer.singleShot(self.delay, self.moveBack) else: self.moveBack()
def retrieveWidgets(self): process = False if not hasattr(self, "main"): qapp = QApplication.instance() for w in qapp.topLevelWidgets(): if "MainWindow" in str(type(w)): self.main = w process = True else: process = True if process and not hasattr(self, "splitter"): for c in self.main.children(): if type(c) is QSplitter: self.splitter = c break if not hasattr(self, "splitter"): process = False if process and (not hasattr(self, "chat") or not hasattr(self, "tabwidget")): for c in self.splitter.children(): if c.objectName == "MainWindowChatWidget": self.chat = c elif c.objectName == "MainWindowServerTabsWidget": self.tabwidget = c if not hasattr(self, "chat") or not hasattr(self, "tabwidget"): process = False if process and not hasattr(self, "tab"): for c in self.tabwidget.children(): if "ServerViewManager" in str(type(c)): self.tab = c break if not hasattr(self, "tab"): process = False if process and not hasattr(self, "svparent"): for c in self.tab.children(): if type(c) is QStackedWidget: self.svparent = c break if not process: #it's possible that this plugin is started before the client's UI is loaded QTimer.singleShot(300, self.retrieveWidgets) else: self.tab.connect("currentChanged(int)", self.onTabIndexChanged) self.startDocking()
def on_apply_clicked(self): try: self.serverBrowser.config.set("FILTERS", "hideEmpty", str(self.hideEmpty.isChecked())) self.serverBrowser.config.set("FILTERS", "hideFull", str(self.hideFull.isChecked())) self.serverBrowser.config.set("FILTERS", "maxUsers", str(self.maxUsers.isChecked())) self.serverBrowser.config.set("FILTERS", "maxUsersMin", str(self.maxUsersMin.value)) self.serverBrowser.config.set("FILTERS", "maxUsersMax", str(self.maxUsersMax.value)) self.serverBrowser.config.set("FILTERS", "maxSlots", str(self.maxSlots.isChecked())) self.serverBrowser.config.set("FILTERS", "maxSlotsMin", str(self.maxSlotsMin.value)) self.serverBrowser.config.set("FILTERS", "maxSlotsMax", str(self.maxSlotsMax.value)) if self.filterPasswordShowWithout.isChecked(): self.serverBrowser.config.set("FILTERS", "filterPassword", "none") elif self.filterPasswordShowWith.isChecked(): self.serverBrowser.config.set("FILTERS", "filterPassword", "only") elif self.filterPasswordShowAll.isChecked(): self.serverBrowser.config.set("FILTERS", "filterPassword", "all") if self.filterChannelsCantCreate.isChecked(): self.serverBrowser.config.set("FILTERS", "filterChannels", "none") elif self.filterChannelsCanCreate.isChecked(): self.serverBrowser.config.set("FILTERS", "filterChannels", "only") elif self.filterChannelsShowAll.isChecked(): self.serverBrowser.config.set("FILTERS", "filterChannels", "all") self.serverBrowser.config.set("FILTERS", "serverNameModifier", self.serverNameModifier.currentText) self.serverBrowser.config.set("FILTERS", "filterServerName", self.filterServerName.text) self.serverBrowser.config.set( "FILTERS", "countryBox", self.countryBox.currentText.split(" (")[0]) with open(self.serverBrowser.ini, 'w') as configfile: self.serverBrowser.config.write(configfile) if self.buhl(self.serverBrowser.config['GENERAL']['morerequests']): self.listCountries() self.page = 1 self.listServers() if not self.cooldown: self.cooldown = True QTimer.singleShot(self.cooldown_time, self.disable_cooldown) except: ts3.logMessage(traceback.format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
def onMenuItemEvent(self, serverConnectionHandlerID, atype, menuItemID, selectedItemID): if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL: if menuItemID == 0: timer = QTimer(self) connect( timer, SIGNAL(timeout()), this, SLOT( self.changeName(serverConnectionHandlerID, names[self.i]))) timer.start(5000)
def deltmp(self): try: f = iopen(self.tmp) f.close() except: pass try: remove(self.tmp) self.tmp = None except: QTimer.singleShot(1000, self.tmp)
def onClientMoveMovedEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUniqueIdentifier, moveMessage): if moverID == 0 or self.backup is None: return (err, ownID) = ts3lib.getClientID(schid) if clientID != ownID or moverID == ownID or moverID == 0: return (err, sgids) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS) if not set(sgids).isdisjoint(self.whitelistSGIDs): return (err, uid) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if uid in self.whitelistUIDs: return self.backup = {"schid": schid, "cid": oldChannelID} delay = randint(self.delay[0], self.delay[1]) ts3lib.printMessageToCurrentTab("{} {}: Switching back to channel {} in {}ms".format(timestamp(),self.name,channelURL(schid, self.backup["cid"]), delay))# clientURL(schid, self.backup["schid"]), QTimer.singleShot(delay, self.moveBack)
def onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage): if not returnCode in self.retcodes: return self.retcodes.remove(returnCode) if error == ts3defines.ERROR_client_is_flooding: ts3lib.printMessageToCurrentTab( "{}: [color=red][b]Client is flooding, stopping!".format( self.name)) self.timer.stop() self._mode = self.mode QTimer.singleShot(10000, self.enable) self.mode = autoCommanderMode.OFF return True
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(10) ts3lib.printMessageToCurrentTab('Timer started!') ts3lib.printMessageToCurrentTab("{0}Set {1} to [color=yellow]{2}[/color]".format(self.timestamp(),self.name,self.toggle))
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 onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored): if self.status: (error, myid) = ts3.getClientID(schid) # get plain url from bbcode url # https://github.com/DerLuemmel/pyTSon_ts3_linkinfo/blob/master/__init__.py message = message.lower() if not myid == fromID and ("[url]" in message or "[url=" in message): start = message.find("[url]") if not start == -1: end = message.find("[/url]") message = message[start + 5:end] else: start = message.find("[url=") end = message.find("]") message = message[start + 5:end] # Open stream and read content type stream = urllib.request.urlopen(message) contenttype = stream.info().get_content_type() # if contenttype is png, gif, jpeg if contenttype in self.contenttypes: # get image data data = stream.read() # label and pixmap image = QLabel("image") pixmap = QPixmap() # load url data to pixmap pixmap.loadFromData(data) # set max width to self.imageMaxHeight pixmap = pixmap.scaledToHeight(self.imageMaxHeight, Qt.FastTransformation) # set image to label image.setPixmap(pixmap) # set margins for better looking image.setStyleSheet("QLabel{margin: 10px;}") # Get chatlayout chatlayout = self.getWidgetByObjectName("MainWindowChatWidget").layout() # Add image to chatlayout chatlayout.addWidget(image) # Deletes image label after self.showTime QTimer.singleShot(self.showTime, lambda : self.removeImage(chatlayout, image))
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 onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moveMessage): if not schid in self.targets: return if self.targets[schid] != clientID: 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-following {} in channel {} in {}ms".format( timestamp(), self.name, clientURL(schid, self.targets[schid]), channelURL(schid, newChannelID), delay)) self.cid = newChannelID QTimer.singleShot(delay, self.joinTarget)
def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored): if targetMode != ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL: return if fromUniqueIdentifier != self.botUID: return # if fromName != self.botNick: return (err, suid) = ts3lib.getServerVariable( schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER) if suid != self.sUID: return if not self.msg in message: return ts3lib.requestSendChannelTextMsg(schid, "!play", toID) self.schid = schid self.botCLID = fromID QTimer.singleShot(self.delay, self.doBet)
def onConnectStatusChangeEvent(self, schid, status, errorNumber): if status != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: return (err, mynick) = ts3lib.getClientSelfVariable(schid, ts3defines.ClientProperties.CLIENT_NICKNAME) if err != ts3defines.ERROR_ok: return sp = re.split(r"\d", mynick) if len(sp) > 1 and sp[0] != mynick and sp[1] == "": (err, clis) = ts3lib.getClientList(schid) if err != ts3defines.ERROR_ok: return for cli in clis: (err, nick) = ts3lib.getClientVariable(schid, cli, ts3defines.ClientProperties.CLIENT_NICKNAME) if err == ts3defines.ERROR_ok and nick == sp[0]: err = ts3lib.requestClientKickFromServer(schid, cli, "Client not responding") self.schid = schid; self.newnick = sp[0] ts3lib.printMessageToCurrentTab('err: {0}'.format(err)) if err == ts3defines.ERROR_ok: self.rename() else: QTimer.singleShot(30000, self.rename)
def onServerUpdatedEvent(self, schid): if not self.requested: return self.requested = False self.timers[schid] = QTimer() self.timers[schid].timeout.connect(self.tick) interval = calculateInterval(schid, AntiFloodPoints.CLIENTUPDATE, self.name) self.timers[schid].start(interval)
class guestLounge(ts3plugin): path = getScriptPath(__name__) name = "Guest Lounges" apiVersion = 22 requestAutoload = False version = "1.0" author = "Bluscream" description = "" offersConfigure = False commandKeyword = "" infoTitle = None hotkeys = [] menuItems = [] timer = QTimer() ts3host = None """ cfg = ConfigParser() cfg["9lBVIDJRSSgAGy+cWJgNlUQRd64="] = { "enabled": True } """ def __init__(self): if "aaa_ts3Ext" in PluginHost.active: ts3ext = PluginHost.active["aaa_ts3Ext"] self.ts3host = ts3ext.ts3host self.tabs = ts3ext.tabs else: retry = 1000 self.timer.singleShot(retry, self.__init__) ts3lib.printMessageToCurrentTab("{}: [color=red]Dependency not yet loaded, retrying in {} second(s)!".format(self.name, retry/1000)) return 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 stop(self): if hasattr(self, "timer"): if self.timer.isActive(): self.timer.stop() del self.timer def onClientMoveEvent(self, schid, clid, oldChannelID, newChannelID, visibility, moveMessage): client = self.ts3host.getUser(schid, clid) if client.server.me.channel.cid if not client.server.me.getChannelGroupId() in [self.tabs[schid]["channelModGroup"], client.server.defaultChannelAdminGroup]: return if clientID in self.waiting and (newChannelID == 0 or newChannelID == self.mychan): # if newChannelID == self.mychan: # (err, dbid) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) ts3lib.printMessage(schid, "{}: [color=orange]Removing channel mod from {}".format(self.name, self.waiting[clientID] if newChannelID == 0 else clientURL(schid, clientID)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) ts3lib.requestSetClientChannelGroup(schid, [self.sgid_guest], [self.mychan], [self.waiting[clientID]]) del self.waiting[clientID] return if newChannelID == 0 or oldChannelID != 0: return (err, sgids) = ts3lib.getClientVariableAsString(schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS) if not self.sgid_guest in intList(sgids): return # TODO Any way to get the cgid in another channel? (err, uid) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER) if getContactStatus(uid) == ContactStatus.BLOCKED: ts3lib.printMessage(schid, "{}: [color=red]Not allowing blocked user {} in your channel.".format(self.name, clientURL(schid, clientID)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) return (err, dbid) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID) self.waiting[clientID] = dbid ts3lib.printMessage(schid, "{}: [color=green]Found new guest {} giving him channel mod until he's here ;)".format(self.name, clientURL(schid, clientID)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER) ts3lib.requestSetClientChannelGroup(schid, [self.cgid_mod], [self.mychan], [dbid])
def initMenus(cls): cls.verboseLog(cls._tr("Initing menus"), "pyTSon.PluginHost.initMenus") cls.menus = {} ret = [(ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 0, cls._tr("Console"), os.path.join("ressources", "octicons", "terminal.svg.png")), (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 1, cls._tr("Settings"), os.path.join("ressources", "octicons", "settings.svg.png")), (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 2, cls._tr("Check for update"), os.path.join( "ressources", "octicons", "cloud-download.svg.png")), (ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL, 3, cls._tr("Changelog"), os.path.join("ressources", "octicons", "book.svg.png"))] nextid = len(ret) loadall = cls.cfg.getboolean("general", "loadAllMenus") menustates = [] for key, p in sorted(cls.plugins.items()): for (atype, locid, text, icon) in p.menuItems: if p.name in cls.active: cls.menus[nextid] = (cls.active[p.name], locid) ret.append((atype, nextid, text, icon)) menustates.append((nextid, True)) elif loadall: cls.menus[nextid] = (p.name, locid) ret.append((atype, nextid, text, icon)) # we have to remember the id, to disable it afterwards menustates.append((nextid, False)) nextid += 1 def deactivateMenus(): for key, val in menustates: ts3lib.setPluginMenuEnabled(key, val) for key, p in cls.active.items(): if hasattr(p, "menuCreated"): p.menuCreated() QTimer.singleShot(1000, deactivateMenus) return ret
def testBillboard(self): avatar = naali.getUserAvatar() avatar_pos = avatar.GetComponentRaw("EC_Placeable") self.pixmap_label = QLabel() self.pixmap_label.size = QSize(200,200) self.pixmap_label.scaledContents = True self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png')) self.text_label = QLabel() self.text_label.size = QSize(300,50) self.text_label.text = "Hello world" self.my_widget = QWidget() self.my_widget.setLayout(QVBoxLayout()) self.my_widget.layout().addWidget(self.pixmap_label) self.my_widget.layout().addWidget(self.text_label) if self.my_widget is None: print("Cannot find image file.") return self.my_entity = naali.createEntity() position = self.my_entity.GetOrCreateComponentRaw("EC_Placeable", "pos", PythonQt.private.AttributeChange.Disconnected, False) position.position = avatar_pos.position self.ec_billboard = self.my_entity.GetOrCreateComponentRaw("EC_BillboardWidget", "test", PythonQt.private.AttributeChange.Disconnected, False) if self.ec_billboard is None: print("Cannot create EC_Billboard component.") return self.ec_billboard.SetPosition(0,0,1) self.ec_billboard.SetWidth(1) self.ec_billboard.SetHeight(1) self.ec_billboard.SetWidget(self.my_widget) self.size_timer = QTimer() self.size_timer.connect("timeout()", self.animateSize) self.size_timer.start(100) self.text_timer = QTimer() self.text_timer.connect("timeout()", self.animateText) self.text_timer.start(1000)
class MyTest(): def __init__(self): pass def testBillboard(self): avatar = naali.getUserAvatar() avatar_pos = avatar.GetComponentRaw("EC_Placeable") self.pixmap_label = QLabel() self.pixmap_label.size = QSize(200,200) self.pixmap_label.scaledContents = True self.pixmap_label.setPixmap(QPixmap('./data/ui/images/naali_icon.png')) self.text_label = QLabel() self.text_label.size = QSize(300,50) self.text_label.text = "Hello world" self.my_widget = QWidget() self.my_widget.setLayout(QVBoxLayout()) self.my_widget.layout().addWidget(self.pixmap_label) self.my_widget.layout().addWidget(self.text_label) if self.my_widget is None: print("Cannot find image file.") return self.my_entity = naali.createEntity() position = self.my_entity.GetOrCreateComponentRaw("EC_Placeable", "pos", PythonQt.private.AttributeChange.Disconnected, False) position.position = avatar_pos.position self.ec_billboard = self.my_entity.GetOrCreateComponentRaw("EC_BillboardWidget", "test", PythonQt.private.AttributeChange.Disconnected, False) if self.ec_billboard is None: print("Cannot create EC_Billboard component.") return self.ec_billboard.SetPosition(0,0,1) self.ec_billboard.SetWidth(1) self.ec_billboard.SetHeight(1) self.ec_billboard.SetWidget(self.my_widget) self.size_timer = QTimer() self.size_timer.connect("timeout()", self.animateSize) self.size_timer.start(100) self.text_timer = QTimer() self.text_timer.connect("timeout()", self.animateText) self.text_timer.start(1000) def animateSize(self): min_width = 1.0 max_width = 2.0 min_height = 1.0 max_height = 2.0 delta_width = max_width-min_width delta_height = max_height-min_height width = min_width + 0.5*delta_width + 0.5*delta_width*math.sin(time.time()*1.324) height = min_height + 0.5*delta_height + 0.5*delta_height*math.cos(time.time()*2.232) self.ec_billboard.SetSize(width, height) def animateText(self): text = str(float(time.time())) self.text_label.text = text self.ec_billboard.Refresh()