Esempio n. 1
0
    def _reloadChannellist(self):
        err, cids = ts3lib.getChannelList(self.schid)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting channellist", err, self.schid)
            return

        unhandled = {}
        for c in cids:
            err, pcid = ts3lib.getParentChannelOfChannel(self.schid, c)

            if err != ts3defines.ERROR_ok:
                _errprint("Error getting channel parent", err, self.schid, c)
                pass

            if pcid == 0:
                parent = self.root
            elif pcid in self.allchans:
                parent = self.allchans[pcid]
            else:
                if pcid in unhandled:
                    unhandled[pcid].append(c)
                else:
                    unhandled[pcid] = [c]
                continue

            obj = Channel(self.schid, c)
            self.allchans[c] = obj
            parent.append(obj, False)

        self._addChilds(self.root, unhandled)
        self.root.sort()
        assert len(unhandled) == 0
Esempio n. 2
0
 def unsubscribeAll(self, schid):
     try:
         error = ts3lib.requestChannelUnsubscribeAll(schid)
         if not error == ts3defines.ERROR_ok:
             raise Exception("Error in requestChannelUnsubscribeAll")
     except:
         try:
             (error, clist) = ts3lib.getChannelList(schid)
             ts3lib.requestChannelUnsubscribe(schid, clist)
         except:
             try:
                 from traceback import format_exc
                 ts3lib.logMessage(format_exc(),
                                   ts3defines.LogLevel.LogLevel_ERROR,
                                   "PyTSon", 0)
                 pass
             except:
                 try:
                     from traceback import format_exc
                     ts3lib.printMessageToCurrentTab(format_exc())
                 except:
                     try:
                         from traceback import format_exc
                         print(format_exc())
                     except:
                         print("Unknown Error")
Esempio n. 3
0
 def channels(self):
     (err, chns) = ts3lib.getChannelList(self.schid)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error getting channels list: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
     for chanID in chns:
         yield self.server.getChannel(chanID)
Esempio n. 4
0
    def _reloadChannellist(self):
        err, cids = ts3lib.getChannelList(self.schid)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting channellist", err, self.schid)
            return

        unhandled = {}
        for c in cids:
            err, pcid = ts3lib.getParentChannelOfChannel(self.schid, c)

            if err != ts3defines.ERROR_ok:
                _errprint("Error getting channel parent", err, self.schid, c)
                pass

            if pcid == 0:
                parent = self.root
            elif pcid in self.allchans:
                parent = self.allchans[pcid]
            else:
                if pcid in unhandled:
                    unhandled[pcid].append(c)
                else:
                    unhandled[pcid] = [c]
                continue

            obj = Channel(self.schid, c)
            self.allchans[c] = obj
            parent.append(obj, False)

        self._addChilds(self.root, unhandled)
        self.root.sort()
        assert len(unhandled) == 0
Esempio n. 5
0
 def unsubscribeAll(self, schid=0):
     if not schid: schid = self.schid
     try:
         error = ts3lib.requestChannelUnsubscribeAll(schid)
         if not error == ts3defines.ERROR_ok: raise Exception("Error in requestChannelUnsubscribeAll")
     except:
         (error, clist) = ts3lib.getChannelList(schid)
         ts3lib.requestChannelUnsubscribe(schid, clist)
Esempio n. 6
0
 def subscribeOpenPW(self, schid=0):
     if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("==== subscribeOpenPW START ====")
     if not schid: schid = self.schid
     (error, clist) = ts3lib.getChannelList(schid)
     for c in clist:
         if not isSubscribed(schid, c) and not isPermanent(schid, c) and not isSemiPermanent(schid, c) and not isMusicChannel(schid, c) and not isBlacklisted(schid, c) and isPWInName(schid, c):
             self.toSub.append(c)
     self.subChannels(schid)
     if PluginHost.cfg.getboolean("general", "verbose"): ts3lib.printMessageToCurrentTab("==== subscribeOpenPW END ====")
Esempio n. 7
0
 def subscribeOpenPW(self, schid=None):
     if not schid: schid = self.schid
     (error, clist) = ts3lib.getChannelList(schid)
     for c in clist:
         if not isPermanent(schid, c) and not isSemiPermanent(schid, c) and not isMusicChannel(schid, c) and not isBlacklisted(schid, c) and isPWInName(schid, c):
             self.toSub.append(c) #clist.remove(c)
     self.subChannels()
     # err = ts3lib.requestChannelSubscribe(schid, tosub)
     # ts3lib.printMessageToCurrentTab("c: {} err: {}".format(tosub, err))
     self.onlyOpen = False
Esempio n. 8
0
def countChannels(schid, find: str, case_sensitive=False):
    if not case_sensitive: find = find.lower()
    (error, cids) = ts3lib.getChannelList(schid)
    ret = {}
    for cid in cids:
        (err, name) = ts3lib.getChannelVariable(
            schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME)
        if not case_sensitive: name = name.lower()
        if find in name: ret[cid] = name
    return ret
Esempio n. 9
0
 def getChannel(self, schid):
     (err, cids) = ts3lib.getChannelList(schid)
     for cid in cids:
         (err, perm) = ts3lib.getChannelVariable(schid, cid, ts3defines.ChannelProperties.CHANNEL_FLAG_SEMI_PERMANENT)
         if not perm: continue
         (err, name) = ts3lib.getChannelVariable(schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME)
         if not self.chan.get("props", "name") in name: continue
         (err, parent) = ts3lib.getParentChannelOfChannel(schid, cid)
         if not parent == self.schids[schid]: continue
         return cid
     return 0
Esempio n. 10
0
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
Esempio n. 11
0
 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)
Esempio n. 12
0
 def purgeDB(self, schid):
     (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     (err, clist) = ts3lib.getChannelList(schid)
     d = self.execSQL("SELECT name FROM sqlite_master WHERE type='table'")
     drop = []
     while d.next():
         name = d.value("name").split('|')
         uid = name[0];cid = int(name[1])
         if uid != suid: continue
         if PluginHost.cfg.getboolean("general", "verbose"): print(self.name, "> CID:", cid)
         if not cid in clist: drop.append(cid)
     for cid in drop:
         name = "{}|{}".format(suid,cid)
         if PluginHost.cfg.getboolean("general", "verbose"): print(self.name, "> Deleting Table:", name)
         self.execSQL("DROP TABLE '{}';".format(name))
Esempio n. 13
0
 def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber):
     if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
         (error, uid) = ts3lib.getServerVariableAsString(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
         if uid == self.cfg.get("general", "uid"):
             # ts3lib.getChannelIDFromChannelNames(serverConnectionHandlerID, channelNameArray)
             (error, clist) = ts3lib.getChannelList(schid)
             for c in clist:
                 (error, permanent) = ts3lib.getChannelVariableAsInt(schid, c, ts3defines.ChannelProperties.CHANNEL_FLAG_PERMANENT)
                 if permanent:
                     (error, name) = ts3lib.getChannelVariableAsString(schid, c, ts3defines.ChannelProperties.CHANNEL_NAME)
                     if name.startswith("Support "):
                         self.supchans.append(c)
                     elif name.startswith("[cspacer10]● Support"):
                         self.supmain = c
             self.cfg.set("general", "enabled", "True")
         else: self.cfg.set("general", "enabled", "False")
Esempio n. 14
0
 def fakeClient(self, schid):
     client = {}
     client["reasonid"] = "0"
     client["cfid"] = "0"
     (err, cids) = ts3lib.getChannelList(schid)
     cid = choice(cids)
     client["ctid"] = cid
     client["client_channel_group_id"] = choice(self.cgroups)
     client["client_servergroups"] = self.sgroup
     client["client_channel_group_inherited_channel_id"] = cid
     client["client_input_muted"] = randint(0, 1)
     client["client_output_muted"] = randint(0, 1)
     client["client_outputonly_muted"] = randint(0, 1)
     client["client_input_hardware"] = randint(0, 1)
     client["client_output_hardware"] = randint(0, 1)
     client["client_is_recording"] = randint(0, 1)
     client["client_talk_request"] = randint(0, 1)
     client["client_type"] = 0  # randint(0,1)
     client["client_is_talker"] = randint(0, 1)
     client["client_away"] = randint(0, 1)
     client["client_is_channel_commander"] = randint(0, 1)
     client["client_is_priority_speaker"] = randint(0, 1)
     clid = randint(0, 65000)
     while clid in self.clients:
         clid = randint(0, 65000)
     client["clid"] = clid
     client["client_database_id"] = randint(0, 1000)
     client["client_talk_power"] = randint(0, 99999)
     client["client_unread_messages"] = randint(0, 10)
     client["client_needed_serverquery_view_power"] = 0  # randint(0,65000)
     client["client_icon_id"] = "0"  # = randint(0,65000)
     client["client_unique_identifier"] = "FakeClient#{}".format(
         self.count)  # "{}=".format(random_string(27))
     client["client_nickname"] = random_string(randint(3, 30))
     client["client_meta_data"] = random_string(randint(0, 1))  # 30
     client["client_away_message"] = random_string(randint(0, 10))  # 80
     client["client_flag_avatar"] = ""  # = random_string(1)
     client["client_talk_request_msg"] = random_string(randint(0, 50))
     client["client_description"] = random_string(randint(0, 50))
     client["client_nickname_phonetic"] = random_string(randint(3, 30))
     client["client_country"] = random_string(2).upper()  # "DE" #
     client["client_badges"] = "overwolf={}:badges={}".format(
         randint(0, 1), choice(self.badges))  # random_string(randint(0,30))
     self.count += 1
     self.clients.append(clid)
     self.fakeclients.append((clid, cid))
     return client
Esempio n. 15
0
 def onMenuItemEvent(self, schid, atype, menuItemID, channel):
     if menuItemID == 0:
         err, cids = ts3lib.getChannelList(schid)
         channels = dict()
         for cid in cids:
             (err, name) = ts3lib.getChannelVariable(
                 schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME)
             (err, order) = ts3lib.getChannelVariable(
                 schid, cid, ts3defines.ChannelProperties.CHANNEL_ORDER)
             if err == ts3defines.ERROR_ok and name: channels[order] = name
         channels = OrderedDict(sorted(channels.items(),
                                       key=lambda t: t[0]))
         for name in channels.values():
             ts3lib.printMessageToCurrentTab(name)
     elif menuItemID == 1:
         description = ts3lib.getChannelVariableAsString(
             schid, channel,
             ts3defines.ChannelProperties.CHANNEL_DESCRIPTION)[1]
         ts3lib.printMessageToCurrentTab(description)
         QApplication.clipboard().setText(description)
Esempio n. 16
0
 def subscribeOpen(self, schid):
     try:
         (error, clist) = ts3lib.getChannelList(schid)
         for c in clist:
             (error, name) = ts3lib.getChannelVariableAsString(
                 schid, c, ts3defines.ChannelProperties.CHANNEL_NAME)
             (error, pw) = ts3lib.getChannelVariableAsInt(
                 schid, c,
                 ts3defines.ChannelProperties.CHANNEL_FLAG_PASSWORD)
             (error, permanent) = ts3lib.getChannelVariableAsInt(
                 schid, c,
                 ts3defines.ChannelProperties.CHANNEL_FLAG_PERMANENT)
             (error, semiperm) = ts3lib.getChannelVariableAsInt(
                 schid, c,
                 ts3defines.ChannelProperties.CHANNEL_FLAG_SEMI_PERMANENT)
             (error, codec) = ts3lib.getChannelVariableAsInt(
                 schid, c, ts3defines.ChannelProperties.CHANNEL_CODEC)
             if not pw and not permanent and not semiperm and not codec == ts3defines.CodecType.CODEC_OPUS_MUSIC and not any(
                     x in name.lower() for x in self.blacklist):
                 ts3lib.requestChannelSubscribe(schid,
                                                [c])  #clist.remove(c)
         self.onlyOpen = True
         # ts3lib.requestChannelSubscribe(schid, clist)
     except:
         try:
             from traceback import format_exc
             ts3lib.logMessage(format_exc(),
                               ts3defines.LogLevel.LogLevel_ERROR, "PyTSon",
                               0)
             pass
         except:
             try:
                 from traceback import format_exc
                 ts3lib.printMessageToCurrentTab(format_exc())
             except:
                 try:
                     from traceback import format_exc
                     print(format_exc())
                 except:
                     print("Unknown Error")
Esempio n. 17
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     try:
         if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
             if menuItemID == 1: # Message all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msgs = self.getText(multiline=True,title="Message all %s clients on this server"%len(clients),text="Enter Private Message")
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     for msg in msgs: ts3lib.requestSendPrivateTextMsg(schid, msg, c)
             elif menuItemID == 2: # OffineMessage all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 (error, ownID) = ts3lib.getClientID(schid)
                 uids = []
                 for c in clients:
                     if c == ownID: continue
                     (error, uid) = ts3lib.getClientVariableAsString(schid, c, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
                     uids.append(uid)
                 if not self.dlg: self.dlg = MessageDialog(schid, uids)
                 self.dlg.show();self.dlg.raise_();self.dlg.activateWindow()
             elif menuItemID == 3: # Message all Channels
                 (error, channels) = ts3lib.getChannelList(schid)
                 msgs = self.getText(multiline=True,title="Message all %s channels on this server"%len(channels),text="Enter Channel Message")
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in channels:
                     error = ts3lib.requestClientMove(schid, ownID, c, "123")
                     if not error == ts3defines.ERROR_ok: continue
                     for msg in msgs: ts3lib.requestSendChannelTextMsg(schid, msg, c)
             elif menuItemID == 4: # Poke all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msgs = self.getText(title="Poke all %s clients on this server"%len(clients),text="Enter Poke Message",max=100)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     for msg in msgs: ts3lib.requestClientPoke(schid, c, msg)
             elif menuItemID == 5: # ChannelKick all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msg = self.getText(title="Kick all %s clients on this server from their channel"%len(clients),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.requestClientKickFromChannel(schid, c, msg)
             elif menuItemID == 6: # ChannelBan all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msg = self.getText(title="ChannelBan all %s clients on this server"%len(clients),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     (error, chan) = ts3lib.getChannelOfClient(schid, selectedItemID)
                     (error, dbid) = ts3lib.getClientVariableAsUInt64(schid, c, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
                     ts3lib.requestSetClientChannelGroup(schid, [self.sbgroup], [chan], [dbid])
                     ts3lib.requestClientKickFromChannel(schid, c, msg)
             elif menuItemID == 7: # Kick all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msg = self.getText(title="Kick all %s clients from this server"%len(clients),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.requestClientKickFromServer(schid, c, msg)
             elif menuItemID == 8: # Ban all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msg = self.getText(title="Ban all %s clients from this server"%len(clients),text="Enter Ban Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.banclient(schid, c, -1, msg)
             elif menuItemID == 9: # Delete all Channels
                 (error, channels) = ts3lib.getChannelList(schid)
                 confirmation = self.confirm('Delete all Channels', 'Do you really want to delete all {0} channels on this server?'.format(len(channels)))
                 if not confirmation: return
                 for c in channels: ts3lib.requestChannelDelete(schid, c, True)
         elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL:
             if menuItemID == 1: # Message all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msgs = self.getText(multiline=True,title="Message to all %s clients in channel \"%s\""%(len(clients),name),text="Enter Private Message")
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     for msg in msgs: ts3lib.requestSendPrivateTextMsg(schid, msg, c)
             if menuItemID == 2: # OfflineMessage all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID)
                 (error, ownID) = ts3lib.getClientID(schid)
                 uids = []
                 for c in clients:
                     if c == ownID: continue
                     (error, uid) = ts3lib.getClientVariableAsString(schid, c, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
                     uids.append(uid)
                 if not self.dlg: self.dlg = MessageDialog(schid, uids)
                 self.dlg.show();self.dlg.raise_();self.dlg.activateWindow()
             elif menuItemID == 3: # Poke all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msgs = self.getText(title="Poke all %s clients in channel \"%s\""%(len(clients),name),text="Enter Poke Message",max=100)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     for msg in msgs: ts3lib.requestClientPoke(schid, c, msg)
             elif menuItemID == 4: # ChannelKick all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msg = self.getText(title="Kick all %s clients from channel \"%s\""%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.requestClientKickFromChannel(schid, c, msg)
             elif menuItemID == 5: # ChannelBan all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msg = self.getText(title="ChannelBan all %s clients from channel \"%s\""%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     (error, dbid) = ts3lib.getClientVariableAsUInt64(schid, c, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
                     ts3lib.requestSetClientChannelGroup(schid, [self.sbgroup], [selectedItemID], [dbid])
                     ts3lib.requestClientKickFromChannel(schid, c, msg)
             elif menuItemID == 6: # Kick all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msg = self.getText(title="Kick all %s clients in channel \"%s\" from this server"%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.requestClientKickFromServer(schid, c, msg)
             elif menuItemID == 7: # Ban all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msg = self.getText(title="Ban all %s clients in channel \"%s\""%(len(clients),name),text="Enter Ban Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.banclient(schid, c, -1, msg)
     except: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
Esempio n. 18
0
 def getDefaultChannel(self, schid):
     (error, clist) = ts3lib.getChannelList(schid)
     for c in clist:
         (error, default) = ts3lib.getChannelVariableAsInt(
             schid, c, ts3defines.ChannelProperties.CHANNEL_FLAG_DEFAULT)
         if default: return c