コード例 #1
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)
コード例 #2
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)
コード例 #3
0
 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)
コード例 #4
0
 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))
コード例 #5
0
 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
コード例 #6
0
 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)
コード例 #7
0
ファイル: __init__.py プロジェクト: sancakbeyy/pyTSon_plugins
 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)
コード例 #8
0
 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)
コード例 #9
0
 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)
コード例 #10
0
ファイル: __init__.py プロジェクト: pogolek/pyTSon_plugins
 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()
コード例 #11
0
ファイル: __init__.py プロジェクト: spyderwan/pyTSon_plugins
 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)
コード例 #12
0
ファイル: __init__.py プロジェクト: jelidi/pyTSon_plugins
 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()
コード例 #13
0
 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)
コード例 #14
0
 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)
コード例 #15
0
    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()
コード例 #16
0
 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)
コード例 #17
0
 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)
コード例 #18
0
 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
コード例 #19
0
ファイル: __init__.py プロジェクト: DerLuemmel/ImagePreview
    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)) 
コード例 #20
0
 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)
コード例 #21
0
ファイル: __init__.py プロジェクト: spyderwan/pyTSon_plugins
 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)
コード例 #22
0
 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)
コード例 #23
0
ファイル: __init__.py プロジェクト: exp111/pyTSon-Scripts
    def retrieveWidgets(self):
        if not self.main:
            for w in QApplication.instance().topLevelWidgets():
                if "MainWindow" in str(type(w)):
                    self.main = w
                    break

        if self.main and not self.svmanagerstack:
            self.svmanagerstack = findChildWidget(self.main, lambda x: x.objectName == "qt_tabwidget_stackedwidget" and "ServerViewManager" in str(type(x.parent())), True)

        if self.svmanagerstack:
            self.svmanagerstack.installEventFilter(self.svobserver)
            for tree in findAllChildWidgets(self.svmanagerstack, lambda x: "TreeView" in str(type(x)), True):
                #TODO: maybe create a new servertreeview here?
                tree.installEventFilter(self.treekeyobserver)
        else:
            QTimer.singleShot(300, self.retrieveWidgets)
コード例 #24
0
    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
コード例 #25
0
ファイル: __init__.py プロジェクト: sancakbeyy/pyTSon_plugins
 def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName,
                        fromUniqueIdentifier, message, ffIgnored):
     if fromUniqueIdentifier != "serveradmin": return
     if fromName != self.gommeBotNick: return
     print(message, self.agreeMSG, message == self.agreeMSG)
     self.schid = schid
     self.gommeBotID = fromID
     if message.endswith(self.msg):
         QTimer.singleShot(self.delay, self.sendMessage)
     elif message == self.blockMSG:
         QTimer.singleShot(self.delay, self.sendMessage)
     elif message == self.agreeMSG:
         ts3lib.requestSendPrivateTextMsg(self.schid, "agree",
                                          self.gommeBotID)
         return True
     elif message in self.ignoreMSG:
         return True
コード例 #26
0
ファイル: __init__.py プロジェクト: sancakbeyy/pyTSon_plugins
 def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber):
     if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
         (error, uid) = ts3lib.getServerVariableAsString(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
         self.schid = schid
         if uid in self.subAll: QTimer.singleShot(2500, self.subscribeAll)
         elif uid in self.subNone: QTimer.singleShot(2500, self.unsubscribeAll)
         elif uid in self.subOpen: QTimer.singleShot(2500, self.subscribeOpen)
         if uid == "QTRtPmYiSKpMS8Oyd4hyztcvLqU=":
             self.toSub = [136205,136209,545989]#support1-3,48=afk,46=iloveradio
             QTimer.singleShot(2500, self.subChannels)
コード例 #27
0
ファイル: pluginhost.py プロジェクト: pathmann/pyTSon
    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
コード例 #28
0
 def on_pageLabel_clicked(self, event):
     try:
         page = QInputDialog.getInt(self, "Goto Page", "Page:")
         if page > 0:
             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
             self.page = page
             self.listServers()
             if not self.cooldown:
                 self.cooldown_page = True
                 self.previous.setEnabled(False)
                 self.next.setEnabled(False)
                 QTimer.singleShot(self.cooldown_time_page, self.disable_cooldown_page)
     except:
         ts3.logMessage(traceback.format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
コード例 #29
0
 def __init__(self):
     self.installer = PluginInstaller(self.print_msg)
     # if self.auto_update_pip: self.to_install.append("--upgrade pip")
     _installed = installedPackages()
     installed = []
     for package in _installed:
         name = package["name"]
         if not name in installed: installed.append(name)
     """
     dir = listdir(getPluginPath("scripts"))
     print(dir)
     """
     # noinspection PyTypeChecker
     for subdir, dirs, files in walklevel(getPluginPath("scripts"), 1):
         for file in files:
             file_lower = file.lower()
             if not file_lower.endswith(".txt"): continue
             if file_lower == "requirements.txt":
                 requirements = []
                 # noinspection PyArgumentList
                 with open(path.join(subdir, file), encoding="utf-8") as f:
                     requirements = [line.strip() for line in f.readlines()]
                 if len(requirements) < 1: continue
                 for requirement in requirements:
                     requirement_stripped = self.strip(requirement)
                     if requirement in self.to_install: continue
                     if requirement_stripped in installed: continue
                     try:
                         __import__(requirement_stripped)
                     except ImportError:
                         self.to_install.append(requirement)
                 break
     if len(self.to_install) > 0:
         ts3lib.printMessageToCurrentTab(
             "[color=red]Found missing dependencies %s in \"requirements.txt\" files from scrips, installing..."
             % self.to_install)
         QTimer.singleShot(0, self.install)
     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))
コード例 #30
0
ファイル: __init__.py プロジェクト: sancakbeyy/pyTSon_plugins
 def onClientKickFromChannelEvent(self, schid, clientID, oldChannelID,
                                  newChannelID, visibility, kickerID,
                                  kickerName, kickerUniqueIdentifier,
                                  kickMessage):
     (err, ownID) = ts3lib.getClientID(schid)
     if clientID != ownID or kickerID == ownID: return
     (err, sgids) = ts3lib.getClientVariableAsString(
         schid, clientID,
         ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
     sgids = intList(sgids)
     if any(i in sgids for i in self.whitelistSGIDs): return
     (err, uid) = ts3lib.getClientVariable(
         schid, clientID,
         ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     if uid in self.whitelistUIDs: return
     self.pw = getChannelPassword(schid, oldChannelID)
     # (err, cpath, self.cpw) = ts3lib.getChannelConnectInfo(schid, oldChannelID)
     self.schid = schid
     self.clid = ownID
     self.cid = oldChannelID
     if self.delay >= 0: QTimer.singleShot(self.delay, self.moveBack)
     else: self.moveBack()
コード例 #31
0
 def onServerErrorEvent(self, schid, errorMessage, error, returnCode, extraMessage):
     if returnCode == "passwordCracker:manual":
         (err, name) = ts3lib.getChannelVariable(schid, self.cid, ChannelProperties.CHANNEL_NAME)
         errorMessage = errorMessage.title()
         msgBox("Channel: {0}\n\nPW: {1}\n\nResult: {2}".format(name, self.pw,errorMessage))
     if not returnCode == self.retcode: return
     errorMessage = errorMessage.title()
     if error == ERROR_channel_invalid_password:
         if self.flooding: self.flooding = False
         self.status = '[color=orange]{0}[/color]'.format(errorMessage)
         ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL, self.cid)
     elif error == ERROR_client_is_flooding:
         self.flooding = True
         self.timer.stop()
         QTimer.singleShot(self.antiflood_delay, self.startTimer)
         self.status = '[color=red]{0}[/color]'.format(errorMessage)
         ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL, self.cid)
     elif error == ERROR_channel_invalid_id:
         self.timer.stop()
         self.status = '[color=red]{0}[/color]'.format(errorMessage)
         ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL, self.cid)
         msgBox("Channel #{0} is invalid!\n\nStopping Cracker!".format(self.cid), QMessageBox.Warning)
     elif error == ERROR_ok:
         if self.flooding: self.flooding = False
         self.timer.stop()
         (err, name) = ts3lib.getChannelVariable(schid, self.cid, ChannelProperties.CHANNEL_NAME)
         ts3lib.printMessageToCurrentTab('Channel: {0} Password: \"{1}\"'.format(channelURL(schid, self.cid, name), self.pws[self.pwc-1] if self.mode == 0 else self.pwc-1))
         self.status = '[color=green]{0}[/color]'.format(errorMessage)
         ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL, self.cid)
         if confirm("Password found! ({0} / {1})".format(self.pwc, len(self.pws)) if self.mode == 0 else "Password found!",
                    "Password \"{0}\" was found for channel \"{1}\"\n\nDo you want to join now?".format(self.pws[self.pwc-1] if self.mode == 0 else self.pwc-1,name)):
             (err, ownID) = ts3lib.getClientID(schid)
             ts3lib.requestClientMove(schid, ownID, self.cid, self.pws[self.pwc-1] if self.mode == 0 else str(self.pwc-1))
     else:
         self.status = errorMessage
         ts3lib.requestInfoUpdate(schid, PluginItemType.PLUGIN_CHANNEL, self.cid)
     if error in [ERROR_channel_invalid_id, ERROR_ok] or returnCode in ["passwordCracker:manual"]: self.schid = 0;self.cid = 0;self.pwc = 0
     return 1