def iconID(self):
     (err, icon) = ts3lib.getChannelVariableAsString(
         self.schid, self.channelID,
         ts3defines.ChannelProperties.CHANNEL_ICON_ID)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error getting channel icon id: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
     return icon
 def topic(self):
     (err, desc) = ts3lib.getChannelVariableAsString(
         self.schid, self.channelID,
         ts3defines.ChannelProperties.CHANNEL_TOPIC)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error getting channel topic: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
     return desc
 def description(self):
     (err, desc) = ts3lib.getChannelVariableAsString(
         self.schid, self.channelID,
         ts3defines.ChannelProperties.CHANNEL_DESCRIPTION)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error getting channel description: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
     return desc
Exemple #4
0
 def commandOP(self, schid, targetMode, toID, fromID, params=""):
     target = int(params)
     (error, dbid) = ts3lib.getClientVariableAsInt(schid, target, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
     (error, chan) = ts3lib.getChannelOfClient(schid, target)
     (error, name) = ts3lib.getChannelVariableAsString(schid, chan, ts3defines.ChannelProperties.CHANNEL_NAME)
     error = ts3lib.requestSetClientChannelGroup(schid, [11], [chan], [dbid])
     if error == ts3defines.ERROR_ok:
         _t = "You have been made operator of the channel [url=channelid://{0}]{1}[/url].".format(chan,name)
         self.answerMessage(schid, ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT, toID, target, _t)
Exemple #5
0
    def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
        if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL or menuItemID != 0:
            return
        err, clientID = ts3lib.getClientID(schid)
        err, channelID = ts3lib.getChannelOfClient(schid, clientID)
        # CHANNEL_NAME
        err, self.CHANNEL_NAME = ts3lib.getChannelVariableAsString(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_NAME)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_NAME,
            self.CHANNEL_NAME + "_")
        # CHANNEL_NAME_PHONETIC
        # err, CHANNEL_NAME_PHONETIC = ts3lib.getChannelVariableAsString(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC)

        # CHANNEL_TOPIC
        # err, CHANNEL_TOPIC = ts3lib.getChannelVariableAsString(schid, channelID, ts3defines.ChannelProperties.CHANNEL_TOPIC)
        # ts3lib.setChannelVariableAsString(schid,0,ts3defines.ChannelProperties.CHANNEL_TOPIC,CHANNEL_TOPIC)
        # CHANNEL_DESCRIPTION
        # err, CHANNEL_DESCRIPTION = ts3lib.getChannelVariableAsString(schid, channelID, ts3defines.ChannelProperties.CHANNEL_DESCRIPTION)
        # ts3lib.setChannelVariableAsString(schid,0,ts3defines.ChannelProperties.CHANNEL_DESCRIPTION,CHANNEL_DESCRIPTION)
        # CHANNEL_CODEC
        err, CHANNEL_CODEC = ts3lib.getChannelVariableAsInt(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC)
        ts3lib.setChannelVariableAsInt(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_CODEC,
            CHANNEL_CODEC)
        # CHANNEL_CODEC_QUALITY
        err, CHANNEL_CODEC_QUALITY = ts3lib.getChannelVariableAsInt(
            schid, channelID,
            ts3defines.ChannelProperties.CHANNEL_CODEC_QUALITY)
        ts3lib.setChannelVariableAsInt(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_CODEC_QUALITY,
            CHANNEL_CODEC_QUALITY)
        # CHANNEL_MAXCLIENTS
        err, CHANNEL_MAXCLIENTS = ts3lib.getChannelVariableAsUInt64(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS)
        ts3lib.setChannelVariableAsUInt64(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS,
            CHANNEL_MAXCLIENTS)
        # CHANNEL_MAXFAMILYCLIENTS
        err, CHANNEL_MAXFAMILYCLIENTS = ts3lib.getChannelVariableAsUInt64(
            schid, channelID,
            ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS)
        ts3lib.setChannelVariableAsUInt64(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS,
            CHANNEL_MAXFAMILYCLIENTS)
        # CHANNEL_NEEDED_TALK_POWER
        err, CHANNEL_NEEDED_TALK_POWER = ts3lib.getChannelVariableAsInt(
            schid, channelID,
            ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER)
        ts3lib.setChannelVariableAsInt(
            schid, 0,
            ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER,
            CHANNEL_NEEDED_TALK_POWER)
        # self.returncode = ts3lib.createReturnCode()
        ts3lib.flushChannelCreation(schid, 0)  #, self.returncode)
Exemple #6
0
 def onMenuItemEvent(self, schid, atype, menuItemID, channel):
     try:
         description = ts3lib.getChannelVariableAsString(
             schid, channel,
             ts3defines.ChannelProperties.CHANNEL_DESCRIPTION)[1]
         ts3lib.printMessageToCurrentTab(description)
     except:
         from traceback import format_exc
         ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                           "pyTSon", 0)
Exemple #7
0
 def onMenuItemEvent(self, schid, atype, menuItemID, channel):
     if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL: return
     try:
         (error, ownID) = ts3lib.getClientID(schid)
         (error, maxclients) = ts3lib.getChannelVariable(
             schid, channel,
             ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS)
         if self.debug:
             ts3lib.printMessageToCurrentTab(
                 "error: {0} | maxclients: {1}".format(error, maxclients))
         if menuItemID == 0:
             pw = inputBox("Enter Channel Password", "Password:"******"clients: {0}".format(clients))
             (error, maxfamilyclients) = ts3lib.getChannelVariable(
                 schid, channel,
                 ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS)
             if self.debug:
                 ts3lib.printMessageToCurrentTab(
                     "error: {0} | maxfamilyclients: {1}".format(
                         error, maxfamilyclients))
             if clients < maxclients and clients < maxfamilyclients:
                 ts3lib.requestClientMove(schid, ownID, channel, pw)
                 return True
             (error, name) = ts3lib.getChannelVariableAsString(
                 schid, channel, ts3defines.ChannelProperties.CHANNEL_NAME)
             self.schid = schid
             self.channel = channel
             self.password = pw
             self.cname = name
             if not pw:
                 ts3lib.printMessageToCurrentTab(
                     "Queued for channel [url=channelid://{0}]{1}[/url]. [color=red]{2}[/color] client(s) remaining."
                     .format(channel, name, maxclients - clients + 1))
             else:
                 ts3lib.printMessageToCurrentTab(
                     "Queued for channel [url=channelid://{0}]{1}[/url] with password \"{2}\". [color=red]{3}[/color] client(s) remaining."
                     .format(channel, name, pw, maxclients - clients + 1))
         elif menuItemID == 1:
             pw = inputBox("Enter Channel Password", "Password:"******"pyTSon", 0)
    def name(self):
        if self._name:
            return self._name

        (err, cname) = ts3lib.getChannelVariableAsString(
            self.schid, self.channelID,
            ts3defines.ChannelProperties.CHANNEL_NAME)
        if err != ts3defines.ERROR_ok:
            raise ts3Error("Error getting channel name: (%s, %s)" %
                           (err, ts3lib.getErrorMessage(err)[1]))
        self._name = cname
        return cname
Exemple #9
0
    def name(self):
        if "name" in self.cache:
            return self.cache["name"]

        err, n = ts3lib.getChannelVariableAsString(
            self.schid, self.cid, ts3defines.ChannelProperties.CHANNEL_NAME)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting channel name", err, self.schid, self.cid)
            return "ERROR_GETTING_NAME: %s" % err
        else:
            self.cache["name"] = n
            return n
Exemple #10
0
    def name(self):
        if "name" in self.cache:
            return self.cache["name"]

        err, n = ts3lib.getChannelVariableAsString(self.schid, self.cid,
                                                   ts3defines.ChannelProperties.CHANNEL_NAME)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting channel name", err, self.schid, self.cid)
            return "ERROR_GETTING_NAME: %s" % err
        else:
            self.cache["name"] = n
            return n
Exemple #11
0
 def onMenuItemEvent(self, schid, atype, menuItemID, channel):
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL and menuItemID == 0:
         try:
             x = QWidget()
             x.setAttribute(Qt.WA_DeleteOnClose)
             password = QInputDialog.getText(x, "Enter Channel Password",
                                             "Password:"******"clients: {0}".format(clients))
             (error, maxclients) = ts3lib.getChannelVariableAsUInt64(
                 schid, channel,
                 ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS)
             if self.debug:
                 ts3lib.printMessageToCurrentTab(
                     "error: {0} | maxclients: {1}".format(
                         error, maxclients))
             (error, maxfamilyclients) = ts3lib.getChannelVariableAsUInt64(
                 schid, channel,
                 ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS)
             if self.debug:
                 ts3lib.printMessageToCurrentTab(
                     "error: {0} | maxfamilyclients: {1}".format(
                         error, maxfamilyclients))
             if clients < maxclients and clients < maxfamilyclients:
                 (error, ownID) = ts3lib.getClientID(schid)
                 ts3lib.requestClientMove(schid, ownID, channel, password)
                 return True
             (error, name) = ts3lib.getChannelVariableAsString(
                 schid, channel, ts3defines.ChannelProperties.CHANNEL_NAME)
             self.schid = schid
             self.channel = channel
             self.password = password
             self.cname = name
             if password == "":
                 ts3lib.printMessageToCurrentTab(
                     "Queued for channel [url=channelid://{0}]{1}[/url]. [color=red]{2}[/color] client(s) remaining."
                     .format(channel, name, maxclients - clients + 1))
             else:
                 ts3lib.printMessageToCurrentTab(
                     "Queued for channel [url=channelid://{0}]{1}[/url] with password \"{2}\". [color=red]{3}[/color] client(s) remaining."
                     .format(channel, name, password,
                             maxclients - clients + 1))
         except:
             from traceback import format_exc
             ts3lib.logMessage(format_exc(),
                               ts3defines.LogLevel.LogLevel_ERROR, "pyTSon",
                               0)
Exemple #12
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")
Exemple #13
0
 def subscribe(self, schid, channelID):
     (error, name) = ts3lib.getChannelVariableAsString(
         schid, channelID, ts3defines.ChannelProperties.CHANNEL_NAME)
     (error, pw) = ts3lib.getChannelVariableAsInt(
         schid, channelID,
         ts3defines.ChannelProperties.CHANNEL_FLAG_PASSWORD)
     (error, subscribed) = ts3lib.getChannelVariableAsInt(
         schid, channelID,
         ts3defines.ChannelPropertiesRare.CHANNEL_FLAG_ARE_SUBSCRIBED)
     (error, codec) = ts3lib.getChannelVariableAsInt(
         schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC)
     #if self.debug: ts3lib.printMessageToCurrentTab("not pw: {0}".format(not pw))
     #if self.debug: ts3lib.printMessageToCurrentTab("any(x in name.lower() for x in self.passwords): {0}".format(any(x in name.lower() for x in self.passwords)))
     #if self.debug: ts3lib.printMessageToCurrentTab("not any(x in name.lower() for x in self.blacklist): {0}".format(not any(x in name.lower() for x in self.blacklist)))
     #if self.debug: ts3lib.printMessageToCurrentTab("not codec == ts3defines.CodecType.CODEC_OPUS_MUSIC: {0}".format(not codec == ts3defines.CodecType.CODEC_OPUS_MUSIC))
     if pw and any(x in name.lower() for x in self.passwords):
         if not subscribed:
             ts3lib.requestChannelSubscribe(schid, [channelID])
             if self.debug:
                 ts3lib.printMessageToCurrentTab(
                     "Has PW in name: {0}".format(
                         pw and any(x in name.lower()
                                    for x in self.passwords)))
     elif not pw and not any(
             x in name.lower() for x in self.blacklist
     ) and not codec == ts3defines.CodecType.CODEC_OPUS_MUSIC:
         if not subscribed:
             ts3lib.requestChannelSubscribe(schid, [channelID])
             if self.debug:
                 ts3lib.printMessageToCurrentTab(
                     "no pw, no bl, no music: {0}".format(
                         not pw and not any(x in name.lower()
                                            for x in self.blacklist)
                         and not codec
                         == ts3defines.CodecType.CODEC_OPUS_MUSIC))
     elif (pw
           and not any(x in name.lower() for x in self.passwords)) or any(
               x in name.lower() for x in self.blacklist
           ) or codec == ts3defines.CodecType.CODEC_OPUS_MUSIC:
         if subscribed:
             ts3lib.requestChannelUnsubscribe(schid, [channelID])
             if self.debug:
                 ts3lib.printMessageToCurrentTab("unsubbed: {0}".format(
                     (pw and not any(x in name.lower()
                                     for x in self.passwords))
                     or any(x in name.lower() for x in self.blacklist)
                     or codec == ts3defines.CodecType.CODEC_OPUS_MUSIC))
Exemple #14
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)
Exemple #15
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")
    def processCommand(self, schid, command):
        tokens = command.split(' ')

        if len(tokens) == 0:
            return True

        (err, myid) = ts3lib.getClientID(schid)
        if err != ts3defines.ERROR_ok:
            ts3lib.printMessageToCurrentTab("Error getting client id: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))
            return True

        (err, cid) = ts3lib.getChannelOfClient(schid, myid)
        if err != ts3defines.ERROR_ok:
            ts3lib.printMessageToCurrentTab("Error getting channel id: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))
            return True

        if tokens[0] == "time":
            err = ts3lib.requestSendChannelTextMsg(schid, "It's %s" % time.asctime(time.localtime(time.time())), cid)
            if err != ts3defines.ERROR_ok:
                ts3lib.printMessageToCurrentTab("Error sending txt message: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))
            return True
        elif tokens[0] == "greet":
            (err, svname) = ts3lib.getServerVariableAsString(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_NAME)
            if err != ts3defines.ERROR_ok:
                ts3lib.printMessageToCurrentTab("Error getting server name: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))
                return True

            (err, cname) = ts3lib.getChannelVariableAsString(schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME)
            if err != ts3defines.ERROR_ok:
                ts3lib.printMessageToCurrentTab("Error getting channel name: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))
                return True

            err = ts3lib.requestSendChannelTextMsg(schid, "Welcome in %s on %s" % (cname, svname), cid)
            if err != ts3defines.ERROR_ok:
                ts3lib.printMessageToCurrentTab("Error sending txt message: (%s, %s)" % (err, ts3lib.getErrorMessage(err)[1]))
            return True
Exemple #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)
Exemple #18
0
    def __init__(self,
                 schid,
                 cid,
                 password='',
                 path='/',
                 parent=None,
                 *,
                 staticpath=False,
                 readonly=False,
                 downloaddir=None,
                 iconpack=None):
        """
        Instantiates a new object.
        @param schid: the id of the serverconnection handler
        @type schid: int
        @param cid: the id of the channel
        @type cid: int
        @param password: password to the channel, defaults to an empty string
        @type password: str
        @param path: path to display, defaults to the root path
        @type path: str
        @param parent: parent of the dialog; optional keyword arg;
        defaults to None
        @type parent: QWidget
        @param staticpath: if set to True, the initial path can't be
        changed by the user; optional keyword arg; defaults to False
        @type staticpath: bool
        @param readonly: if set to True, the user can't download, upload
        or delete files, or create new directories; optional keyword arg;
        defaults to False
        @type readonly: bool
        @param downloaddir: directory to download files to; optional keyword
        arg; defaults to None; if set to None, the TS3 client's download
        directory is used
        @type downloaddir: str
        @param iconpack: iconpack to load icons from; optional keyword arg;
        defaults to None; if set to None, the current iconpack is used
        @type iconpack: ts3client.IconPack
        """
        super(QDialog, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)

        iconpackopened = False
        if not iconpack:
            try:
                iconpack = ts3client.IconPack.current()
                iconpack.open()
                iconpackopened = True
            except Exception as e:
                self.delete()
                raise e

        try:
            setupUi(self,
                    pytson.getPluginPath("ressources", "filebrowser.ui"),
                    iconpack=iconpack)

            self.statusbar = SmartStatusBar(self)
            self.layout().addWidget(self.statusbar)
            self.statusbar.hide()
        except Exception as e:
            self.delete()
            raise e

        err, cname = ts3lib.getChannelVariableAsString(
            schid, cid, ChannelProperties.CHANNEL_NAME)

        if err == ERROR_ok:
            self.setWindowTitle(
                self._tr("File Browser - {cname}").format(cname=cname))
        else:
            self.setWindowTitle(self._tr("File Browser"))

        self.schid = schid
        self.cid = cid
        self.password = password
        self.path = None

        self.staticpath = staticpath
        self.readonly = readonly

        self.createretcode = None
        self.delretcode = None

        if not self.readonly and not downloaddir:
            cfg = ts3client.Config()
            q = cfg.query("SELECT value FROM filetransfer "
                          "WHERE key='DownloadDir'")
            del cfg

            if q.next():
                self.downloaddir = q.value("value")
            else:
                self.delete()
                raise Exception("Error getting DownloadDir from config")
        else:
            self.downloaddir = downloaddir

        if not self.readonly:
            menu = self.menu = QMenu(self)

            self.openAction = menu.addAction(QIcon(iconpack.icon("FILE_UP")),
                                             self._tr("Open"))
            self.openAction.connect("triggered()",
                                    self.on_openAction_triggered)

            self.downAction = menu.addAction(QIcon(iconpack.icon("DOWN")),
                                             self._tr("Download"))
            self.downAction.connect("triggered()", self.downloadFiles)
            self.renameAction = menu.addAction(QIcon(iconpack.icon("EDIT")),
                                               self._tr("Rename"))
            self.renameAction.connect("triggered()",
                                      self.on_renameAction_triggered)
            self.copyAction = menu.addAction(QIcon(iconpack.icon("COPY")),
                                             self._tr("Copy URL"))
            self.copyAction.connect("triggered()",
                                    self.on_copyAction_triggered)
            self.delAction = menu.addAction(QIcon(iconpack.icon("DELETE")),
                                            self._tr("Delete"))
            self.delAction.connect("triggered()", self.deleteFiles)

            self.upAction = menu.addAction(QIcon(iconpack.icon("UP")),
                                           self._tr("Upload files"))
            self.upAction.connect("triggered()", self.uploadFiles)
            self.createAction = menu.addAction(QIcon.fromTheme("folder"),
                                               self._tr("Create Folder"))
            self.createAction.connect("triggered()", self.createFolder)
            self.refreshAction = menu.addAction(
                QIcon(iconpack.icon("FILE_REFRESH")), self._tr("Refresh"))
            self.refreshAction.connect("triggered()", self.refresh)

            self.allactions = [
                self.openAction, self.downAction, self.renameAction,
                self.copyAction, self.delAction, self.upAction,
                self.createAction, self.refreshAction
            ]

        self.collector = FileCollector(schid, cid, password, self.downloaddir)
        self.collector.collectionFinished.connect(self._startDownload)
        self.collector.collectionError.connect(self.showError)

        self.fileDoubleClicked = Signal()
        self.contextMenuRequested = Signal()

        self.transdlg = None

        self.listmodel = FileListModel(schid,
                                       cid,
                                       password,
                                       self,
                                       readonly=readonly)
        self.listmodel.pathChanged.connect(self.onPathChanged)
        self.listmodel.error.connect(self.showError)

        self.proxy = QSortFilterProxyModel(self)
        self.proxy.setSortRole(Qt.UserRole)
        self.proxy.setSortCaseSensitivity(Qt.CaseInsensitive)
        self.proxy.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.proxy.setSourceModel(self.listmodel)

        self.listmodel.path = path

        self._adjustUi()

        if iconpackopened:
            iconpack.close()

        PluginHost.registerCallbackProxy(self)
Exemple #19
0
 def getChannelName(serverConnectionHandlerID, channelID):
     return ts3lib.getChannelVariableAsString(
         serverConnectionHandlerID, channelID,
         ts3defines.ChannelProperties.CHANNEL_NAME)[1]
Exemple #20
0
    def fakeChannel(self, schid, channelID):
        (error, nick) = ts3lib.getChannelVariableAsString(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_NAME)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_NAME, nick)

        (error, phonetic) = ts3lib.getChannelVariableAsString(
            schid, channelID,
            ts3defines.ChannelProperties.CHANNEL_NAME_PHONETIC)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_NAME, phonetic)

        (error, pw) = ts3lib.getChannelVariableAsInt(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_PASSWORD)
        if pw:
            ts3lib.setChannelVariableAsString(
                schid, 0, ts3defines.ChannelProperties.CHANNEL_PASSWORD, ".")

        (error, topic) = ts3lib.getChannelVariableAsString(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_TOPIC)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_TOPIC, topic)

        (error, description) = ts3lib.getChannelVariableAsString(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_DESCRIPTION)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_DESCRIPTION,
            description)

        (error, neededtp) = ts3lib.getChannelVariableAsInt(
            schid, channelID,
            ts3defines.ChannelProperties.CHANNEL_NEEDED_TALK_POWER)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_NEEDED_TALK_POWER,
            neededtp)

        (error, codec) = ts3lib.getChannelVariableAsInt(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_CODEC)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_CODEC, codec)

        (error, quality) = ts3lib.getChannelVariableAsInt(
            schid, channelID,
            ts3defines.ChannelProperties.CHANNEL_CODEC_QUALITY)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_CODEC_QUALITY,
            quality)

        (error, latency) = ts3lib.getChannelVariableAsString(
            schid, channelID,
            ts3defines.ChannelProperties.CHANNEL_CODEC_LATENCY_FACTOR)
        ts3lib.setChannelVariableAsString(
            schid, 0,
            ts3defines.ChannelProperties.CHANNEL_CODEC_LATENCY_FACTOR, latency)

        (error, unencrypted) = ts3lib.getChannelVariableAsInt(
            schid, channelID,
            ts3defines.ChannelProperties.CHANNEL_CODEC_IS_UNENCRYPTED)
        ts3lib.setChannelVariableAsString(
            schid, 0,
            ts3defines.ChannelProperties.CHANNEL_CODEC_IS_UNENCRYPTED,
            unencrypted)

        (error, maxclients) = ts3lib.getChannelVariableAsInt(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS,
            maxclients)

        (error, maxfamilyclients) = ts3lib.getChannelVariableAsInt(
            schid, channelID,
            ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_MAXFAMILYCLIENTS,
            maxfamilyclients)

        (error, iconid) = ts3lib.getChannelVariableAsUint64(
            schid, channelID, ts3defines.ChannelProperties.CHANNEL_ICON_ID)
        ts3lib.setChannelVariableAsString(
            schid, 0, ts3defines.ChannelProperties.CHANNEL_ICON_ID, iconid)

        (error, _clid) = ts3lib.getClientID(schid)
Exemple #21
0
    def __init__(self, schid, cid, password='', path='/', parent=None, *,
                 staticpath=False, readonly=False, downloaddir=None,
                 iconpack=None):
        """
        Instantiates a new object.
        @param schid: the id of the serverconnection handler
        @type schid: int
        @param cid: the id of the channel
        @type cid: int
        @param password: password to the channel, defaults to an empty string
        @type password: str
        @param path: path to display, defaults to the root path
        @type path: str
        @param parent: parent of the dialog; optional keyword arg;
        defaults to None
        @type parent: QWidget
        @param staticpath: if set to True, the initial path can't be
        changed by the user; optional keyword arg; defaults to False
        @type staticpath: bool
        @param readonly: if set to True, the user can't download, upload
        or delete files, or create new directories; optional keyword arg;
        defaults to False
        @type readonly: bool
        @param downloaddir: directory to download files to; optional keyword
        arg; defaults to None; if set to None, the TS3 client's download
        directory is used
        @type downloaddir: str
        @param iconpack: iconpack to load icons from; optional keyword arg;
        defaults to None; if set to None, the current iconpack is used
        @type iconpack: ts3client.IconPack
        """
        super(QDialog, self).__init__(parent)
        self.setAttribute(Qt.WA_DeleteOnClose)

        iconpackopened = False
        if not iconpack:
            try:
                iconpack = ts3client.IconPack.current()
                iconpack.open()
                iconpackopened = True
            except Exception as e:
                self.delete()
                raise e

        try:
            setupUi(self, pytson.getPluginPath("ressources", "filebrowser.ui"),
                    iconpack=iconpack)

            self.statusbar = SmartStatusBar(self)
            self.layout().addWidget(self.statusbar)
            self.statusbar.hide()
        except Exception as e:
            self.delete()
            raise e

        err, cname = ts3lib.getChannelVariableAsString(schid, cid,
                                                       ChannelProperties.
                                                       CHANNEL_NAME)

        if err == ERROR_ok:
            self.setWindowTitle(self._tr("File Browser - {cname}").format(
                                cname=cname))
        else:
            self.setWindowTitle(self._tr("File Browser"))

        self.schid = schid
        self.cid = cid
        self.password = password
        self.path = None

        self.staticpath = staticpath
        self.readonly = readonly

        self.createretcode = None
        self.delretcode = None

        if not self.readonly and not downloaddir:
            cfg = ts3client.Config()
            q = cfg.query("SELECT value FROM filetransfer "
                          "WHERE key='DownloadDir'")
            del cfg

            if q.next():
                self.downloaddir = q.value("value")
            else:
                self.delete()
                raise Exception("Error getting DownloadDir from config")
        else:
            self.downloaddir = downloaddir

        if not self.readonly:
            menu = self.menu = QMenu(self)

            self.openAction = menu.addAction(QIcon(iconpack.icon("FILE_UP")),
                                             self._tr("Open"))
            self.openAction.connect("triggered()",
                                    self.on_openAction_triggered)

            self.downAction = menu.addAction(QIcon(iconpack.icon("DOWN")),
                                             self._tr("Download"))
            self.downAction.connect("triggered()", self.downloadFiles)
            self.renameAction = menu.addAction(QIcon(iconpack.icon("EDIT")),
                                               self._tr("Rename"))
            self.renameAction.connect("triggered()",
                                      self.on_renameAction_triggered)
            self.copyAction = menu.addAction(QIcon(iconpack.icon("COPY")),
                                             self._tr("Copy URL"))
            self.copyAction.connect("triggered()",
                                    self.on_copyAction_triggered)
            self.delAction = menu.addAction(QIcon(iconpack.icon("DELETE")),
                                            self._tr("Delete"))
            self.delAction.connect("triggered()", self.deleteFiles)

            self.upAction = menu.addAction(QIcon(iconpack.icon("UP")),
                                           self._tr("Upload files"))
            self.upAction.connect("triggered()", self.uploadFiles)
            self.createAction = menu.addAction(QIcon.fromTheme("folder"),
                                               self._tr("Create Folder"))
            self.createAction.connect("triggered()", self.createFolder)
            self.refreshAction = menu.addAction(QIcon(iconpack.icon(
                                                "FILE_REFRESH")),
                                                self._tr("Refresh"))
            self.refreshAction.connect("triggered()", self.refresh)

            self.allactions = [self.openAction, self.downAction,
                               self.renameAction, self.copyAction,
                               self.delAction, self.upAction,
                               self.createAction, self.refreshAction]

        self.collector = FileCollector(schid, cid, password, self.downloaddir)
        self.collector.collectionFinished.connect(self._startDownload)
        self.collector.collectionError.connect(self.showError)

        self.fileDoubleClicked = Signal()
        self.contextMenuRequested = Signal()

        self.transdlg = None

        self.listmodel = FileListModel(schid, cid, password, self,
                                       readonly=readonly)
        self.listmodel.pathChanged.connect(self.onPathChanged)
        self.listmodel.error.connect(self.showError)

        self.proxy = QSortFilterProxyModel(self)
        self.proxy.setSortRole(Qt.UserRole)
        self.proxy.setSortCaseSensitivity(Qt.CaseInsensitive)
        self.proxy.setFilterCaseSensitivity(Qt.CaseInsensitive)
        self.proxy.setSourceModel(self.listmodel)

        self.listmodel.path = path

        self._adjustUi()

        if iconpackopened:
            iconpack.close()

        PluginHost.registerCallbackProxy(self)