Exemple #1
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
         if menuItemID == 0:
             error, ownid = ts3.getClientID(schid)
             if error == ERROR_ok:
                 error, meta = ts3.getClientVariableAsString(schid, ownid, ClientProperties.CLIENT_META_DATA)
                 if error == ERROR_ok:
                     x = QWidget()
                     _meta = QInputDialog.getMultiLineText(x, "Change own Meta Data", "Meta Data:", meta)
                     if _meta == meta: return
                     error = ts3.setClientSelfVariableAsString(schid, ClientProperties.CLIENT_META_DATA, _meta)
                     if not error == ERROR_ok:
                         _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error, "Unable to set own meta data!");_t.show()
         elif menuItemID == 1:
             error, ownid = ts3.getClientID(schid)
             if error == ERROR_ok:
                 error, flag = ts3.getClientVariableAsString(schid, ownid, ClientPropertiesRare.CLIENT_FLAG_AVATAR)
                 ts3.printMessageToCurrentTab("Your current avatar flag is: %s"%flag)
                 if error == ERROR_ok:
                     x = QWidget()
                     _flag = QInputDialog.getText(x, "Change own Avatar Flag", "Avatar File MD5:")
                     if _flag == "x" or _flag.strip() == flag.strip(): return
                     error = ts3.setClientSelfVariableAsString(schid, ClientPropertiesRare.CLIENT_FLAG_AVATAR, _flag)
                     error2 = ts3.flushClientSelfUpdates(schid)
                     if not error == ERROR_ok or not error2 == ERROR_ok:
                         _t = QMessageBox(QMessageBox.Critical, "Error", "Unable to set own avatar flag!");_t.show()
 def onUpdateClientEvent(self, schid, clid, invokerID, invokerName, invokerUniqueIdentifier):
     if schid != self.aka[0]: return
     if clid != self.aka[1]: return
     (err, name) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientProperties.CLIENT_NICKNAME)
     if name == self.aka[3]: return
     ts3lib.setClientSelfVariableAsString(schid, ts3defines.ClientProperties.CLIENT_NICKNAME, "{} aka {}".format(self.aka[2], name))
     ts3lib.flushClientSelfUpdates(schid)
Exemple #3
0
 def rename(self):
     ts3lib.setClientSelfVariableAsString(
         self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
         self.newnick)
     self.schid = 0
     self.newnick = ""
     ts3lib.flushClientSelfUpdates(self.schid)
Exemple #4
0
 def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber):
     if newStatus != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
         return
     if not self.nickname: return
     ts3lib.setClientSelfVariableAsString(
         schid, ts3defines.ClientProperties.CLIENT_NICKNAME, self.nickname)
     ts3lib.flushClientSelfUpdates(schid)
Exemple #5
0
 def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber):
     if newStatus != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
         return
     if not self.nick_enabled: return
     (err, suid) = ts3lib.getServerVariable(
         schid,
         ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     if suid != self.suid: return
     (err, name) = ts3lib.getClientSelfVariable(
         schid, ts3defines.ClientProperties.CLIENT_NICKNAME)
     _name = choice(self.nicknames)
     if "{" in _name:
         (err, ownID) = ts3lib.getClientID(schid)
         if "{ver}" in _name:
             (err, ver) = ts3lib.getClientVariable(
                 schid, ownID, ts3defines.ClientProperties.CLIENT_VERSION)
             _name = _name.replace("{ver}", ver.split(" ")[0])
         if "{os}" in _name:
             (err, os) = ts3lib.getClientVariable(
                 schid, ownID, ts3defines.ClientProperties.CLIENT_PLATFORM)
             _name = _name.replace("{os}", os)
         if "{con}" in _name:
             # ts3lib.requestClientVariables(schid, ownID)
             (err, os) = ts3lib.getClientVariable(
                 schid, ownID,
                 ts3defines.ClientPropertiesRare.CLIENT_TOTALCONNECTIONS)
             _name = _name.replace("{con}", str(os))
     if _name == name: return
     ts3lib.setClientSelfVariableAsString(
         schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _name)
     ts3lib.flushClientSelfUpdates(schid)
Exemple #6
0
 def tick(self):
     new = choice(self.suffixes)
     while new == self.last: new = choice(self.suffixes)
     ts3lib.setClientSelfVariableAsString(self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, self.prefix + new)
     self.retcode = ts3lib.createReturnCode()
     ts3lib.flushClientSelfUpdates(self.schid, self.retcode)
     self.last = new
 def onConnectStatusChangeEvent(self, schid, newStatus, errorNumber):
     if newStatus != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: return
     if not self.nick_enabled: return
     (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     if suid != self.suid: return
     ts3lib.setClientSelfVariableAsString(schid, ts3defines.ClientProperties.CLIENT_NICKNAME, choice(self.nicknames))
     ts3lib.flushClientSelfUpdates(schid)
Exemple #8
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if menuItemID == 0:
         if self.timer is None:
             self.timer = QTimer()
             self.timer.timeout.connect(self.tick)
         if self.timer.isActive():
             self.timer.stop()
             self.timer = None
             ts3lib.setClientSelfVariableAsString(
                 schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
                 self.nick)
             ts3lib.flushClientSelfUpdates(schid)
             ts3lib.printMessageToCurrentTab('Timer stopped!')
         else:
             (err, nick) = ts3lib.getClientSelfVariable(
                 schid, ts3defines.ClientProperties.CLIENT_NICKNAME)
             if len(nick) > self.max - 2:
                 errorMsgBox(
                     "Error",
                     "Nickname must be %s chars or below!" % self.max)
                 return
             self.nick = nick
             self._nick = list(nick)
             self.i = self.max - 2
             self.b = 0
             self.schid = schid
             step = inputBox(self.name, 'Interval in Milliseconds:')
             if step: interval = int(step)
             else: interval = 300
             self.timer.start(interval)
             ts3lib.printMessageToCurrentTab('Timer started!')
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == ts3defines.PluginItemType.PLUGIN_SERVER:
         if menuItemID == 0:
             self.dynamicSilence = not self.dynamicSilence
             ts3lib.printMessageToCurrentTab(
                 "{}{}: DynamicSilence set to [color=orange]{}".format(
                     timestamp(), self.name, self.dynamicSilence))
         elif menuItemID == 1:
             self.askForAvatar = not self.askForAvatar
             ts3lib.printMessageToCurrentTab(
                 "{}askForAvatar set to [color=orange]{}".format(
                     timestamp(), self.askForAvatar))
             if not self.askForAvatar:
                 self.clids = []
                 self.timer.stop()
                 return
             (err, clids) = ts3lib.getClientList(schid)
             for c in clids:
                 ts3lib.requestClientVariables(schid, c)
             for c in clids:
                 (err, uid) = ts3lib.getClientVariable(
                     schid, c,
                     ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
                 if getContactStatus(uid) == ContactStatus.BLOCKED: continue
                 if uid in self.alreadyAsked: continue
                 (err, sgroups) = ts3lib.getClientVariableAsString(
                     schid, c,
                     ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
                 sgroups = sgroups.split(",")
                 if self.ruheGroupID in sgroups: continue
                 if set(sgroups).isdisjoint(self.premiumGroupIDs): continue
                 self.clids.append(c)
             ts3lib.printMessageToCurrentTab(
                 "{}Asking {} clients for avatar".format(
                     timestamp(), len(self.clids)))
             self.schid = schid
             self.timer.start(1000)
     if atype == ts3defines.PluginItemType.PLUGIN_CHANNEL:
         ts3lib.requestSendChannelTextMsg(schid, self.steammsg,
                                          selectedItemID)
     elif atype == ts3defines.PluginItemType.PLUGIN_CLIENT:
         if menuItemID == 0:
             ts3lib.requestSendPrivateTextMsg(schid, self.steammsg,
                                              selectedItemID)
         elif menuItemID == 1:
             print(self.aka)
             if self.aka != (0, 0, "", ""):
                 self.aka = (0, 0, "", "")
                 return
             realname = inputBox(self.name, "Real name:")
             if not realname: return
             (err, name) = ts3lib.getClientVariable(
                 schid, selectedItemID,
                 ts3defines.ClientProperties.CLIENT_NICKNAME)
             ts3lib.setClientSelfVariableAsString(
                 schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
                 "{} aka {}".format(realname, name))
             ts3lib.flushClientSelfUpdates(schid)
             self.aka = (schid, selectedItemID, realname, name)
Exemple #10
0
 def tick(self,schid=0, clid=0):
     if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID()
     if schid == 0: return
     _newnick = '%s%s%s'%(self.prefix, self.count, self.suffix)
     if self.debug: ts3lib.printMessageToCurrentTab('Tick %s: '%self.count + _newnick)
     ts3lib.setClientSelfVariableAsString(schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _newnick)
     ts3lib.flushClientSelfUpdates(schid)
     self.count += 1
Exemple #11
0
 def onClientSelfVariableUpdateEvent(self, schid, flag, oldValue, newValue):
     if not self.enabled: return
     if flag in [ts3defines.ClientProperties.CLIENT_NICKNAME, ts3defines.ClientPropertiesRare.CLIENT_AWAY_MESSAGE]:
         if newValue.endswith("="): return
         encoded = b64encode(newValue.encode('utf-8')).decode('utf-8')
         if not encoded.endswith("="): encoded += "="
         ts3lib.setClientSelfVariableAsString(schid, flag, encoded)
         ts3lib.flushClientSelfUpdates(schid)
Exemple #12
0
 def stopTimer(self):
     if hasattr(self.timer, "isActive") and self.timer.isActive():
         self.timer.stop()
         # self.timer = None
         ts3lib.setClientSelfVariableAsString(
             self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
             self._nick)
         ts3lib.flushClientSelfUpdates(self.schid)
         ts3lib.printMessageToCurrentTab('Timer stopped!')
Exemple #13
0
 def tick(self):
     if self.schid == 0: return
     _newnick = self.fillnick()
     if _newnick is None: return
     ts3lib.printMessageToCurrentTab("length: {} | newnick: \"{}\"".format(
         len(_newnick), _newnick))
     ts3lib.setClientSelfVariableAsString(
         self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _newnick)
     ts3lib.flushClientSelfUpdates(self.schid)
Exemple #14
0
def avatar(img):
    hash_md5 = md5()
    with open(file, "rb") as f:
        for chunk in iter(lambda: f.read(4096), b""):
            hash_md5.update(chunk)
    ts3lib.setClientSelfVariableAsString(
        schid(), ts3defines.ClientPropertiesRare.CLIENT_FLAG_AVATAR,
        hash_md5.hexdigest())
    ts3lib.flushClientSelfUpdates(schid())
Exemple #15
0
 def onHotkeyEvent(self, keyword):
     if keyword == "fakeMute":
         self.enabled = not self.enabled
         if self.changeName:
             name = ts3.getClientDisplayName(1, ts3.getClientID(1), 128)
             if enabled:
                 ts3.setClientSelfVariableAsString(
                     1, ts3defines.CLIENT_NICKNAME, name + " [MUTED]")
             else:
                 ts3.setClientSelfVariableAsString(
                     1, ts3defines.CLIENT_NICKNAME, name[:-8])
             ts3.flushClientSelfUpdates(1, "")
Exemple #16
0
 def fakeClient(self, schid, clientID):
     (error, _clid) = ts3lib.getClientID(schid)
     (error, nick) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientProperties.CLIENT_NICKNAME)
     _nick = self.str_replace(nick)
     # if PluginHost.cfg.getboolean("general", "verbose"):
     print(_nick, "==",nick,":",_nick == nick)
     if _nick == nick: return False
     ts3lib.setClientSelfVariableAsString(schid, ts3defines.ClientProperties.CLIENT_NICKNAME, _nick)
     # (error, nickp) = ts3lib.getClientVariable(schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_NICKNAME_PHONETIC)
     # ts3lib.setClientSelfVariableAsString(schid, ts3defines.ClientPropertiesRare.CLIENT_NICKNAME_PHONETIC, nickp)
     err = ts3lib.flushClientSelfUpdates(schid)
     return err
Exemple #17
0
    def nickname(self, nick = None, song = None):
        MAX_SIZE = ts3defines.TS3_MAX_SIZE_CLIENT_NICKNAME_NONSDK

        if not nick:
            nick = CONFIG.get('nick')

        if self.nick == nick: return
        self.nick = nick

        if song:
            nick = f'{nick} [{ song[:(MAX_SIZE - len(nick) - 3)] }]'

        ts3lib.setClientSelfVariableAsString(schid(), ts3defines.ClientProperties.CLIENT_NICKNAME, nick)
        ts3lib.flushClientSelfUpdates(schid())
Exemple #18
0
 def tick(self, schid=0, clid=0):
     if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID()
     if clid == 0: (err, clid) = ts3lib.getClientID(schid)
     if schid == 0 or clid == 0: return
     if self.debug:
         self.int += 1
         ts3lib.printMessageToCurrentTab('Tick %s' % self.int)
     (err, ping) = ts3lib.getConnectionVariableAsUInt64(
         schid, clid, ts3defines.ConnectionProperties.CONNECTION_PING)
     if ping == self.lastPing: return
     ts3lib.setClientSelfVariableAsString(
         schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
         "{0}{1}{2}".format(self.prefix, ping, self.suffix))
     ts3lib.flushClientSelfUpdates(schid)
     self.lastPing = ping
Exemple #19
0
    def tick(self):
        try:
            if self.schid == 0: return
            max = self.max - 1
            _nick = list(self.nick)
            if self.i == (len(_nick) * -1) + 2:
                self.i = max
                self.b = 0
            self.i -= 1
            self.b += 1
            # ts3lib.printMessageToCurrentTab("self.i == %s | self.b == %s"%(self.i,self.b))
            count = 0
            newnick = ["!"]

            for k in range(0, self.i):
                newnick.append(self.separator())
                count += 1

            if self.i > 1:
                for k in range(0, self.b):
                    if k < len(_nick) and k < max:
                        newnick.append(_nick[k])
                        # ts3lib.printMessageToCurrentTab("1: {} | 2: {} | 3: {}".format(0, self.b, self._nick[k]))
                        count += 1
                    else:
                        pass
                #for k in range(count, max):
                #newnick.append(separator())
            else:
                for k in range(self.i * -1, len(_nick)):
                    if k != -1 and count < max:
                        newnick.append(_nick[k])
                        count += 1
                #for k in range(count, max):
                #newnick.append(self.separator())
            # newnick.append("!")
            _newnick = ''.join(newnick)
            if _newnick is None: return
            # ts3lib.printMessageToCurrentTab("length: {} | newnick: \"{}\"".format(len(_newnick), _newnick))
            ts3lib.setClientSelfVariableAsString(
                self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
                _newnick)
            ts3lib.flushClientSelfUpdates(self.schid)
        except:
            from traceback import format_exc
            ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                              "pyTSon", 0)
Exemple #20
0
 def description(self, value):
     if len(value) > ts3defines.TS3_MAX_SIZE_CLIENT_DESCRIPTION:
         raise ts3Error(
             "Description too long. length:%s, max:%s" %
             (len(value), ts3defines.TS3_MAX_SIZE_CLIENT_DESCRIPTION))
     err = ts3lib.setClientSelfVariableAsString(
         self.schid, ts3defines.ClientPropertiesRare.CLIENT_DESCRIPTION,
         value)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error setting client description: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
Exemple #21
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if menuItemID == 0:
         if self.timer is None:
             self.timer = QTimer()
             self.timer.timeout.connect(self.tick)
         if self.timer.isActive():
             self.timer.stop()
             self.timer = None
             ts3lib.setClientSelfVariableAsString(
                 schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
                 self.nick)
             ts3lib.flushClientSelfUpdates(schid)
             ts3lib.printMessageToCurrentTab('Timer stopped!')
         else:
             (err, self.nick) = ts3lib.getClientSelfVariable(
                 schid, ts3defines.ClientProperties.CLIENT_NICKNAME)
             self.schid = schid
             (err, self.clid) = ts3lib.getClientID(schid)
             self.timer.start(1000)
             ts3lib.printMessageToCurrentTab('Timer started!')
Exemple #22
0
 def onHotkeyOrCommandEvent(self, keyword, schid=0):
     if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID()
     if keyword == "request_talk_power":
         (err, oldnick) = ts3lib.getClientSelfVariable(
             schid, ts3defines.ClientProperties.CLIENT_NICKNAME)
         ts3lib.setClientSelfVariableAsString(
             schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
             self.tpr_name)
         ts3lib.flushClientSelfUpdates(schid)
         if self.hook:
             sendCommand(self.name, "clientupdate client_is_recording=1",
                         schid)
             sendCommand(self.name, "clientupdate client_is_recording=0",
                         schid)
         else:
             ts3lib.startVoiceRecording(schid)
             ts3lib.stopVoiceRecording(schid)
         ts3lib.setClientSelfVariableAsString(
             schid, ts3defines.ClientProperties.CLIENT_NICKNAME, oldnick)
         ts3lib.flushClientSelfUpdates(schid)
Exemple #23
0
 def tick(self):
     try:
         # if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID()
         # (err, clid) = ts3lib.getClientID(self.schid)
         if self.schid == 0 or self.clid == 0: return
         if self.debug:
             self.int += 1
             ts3lib.printMessageToCurrentTab('Tick %s' % self.int)
         (err, ping) = ts3lib.getConnectionVariableAsUInt64(
             self.schid, self.clid,
             ts3defines.ConnectionProperties.CONNECTION_PING)
         if ping == self.lastPing: return
         ts3lib.setClientSelfVariableAsString(
             self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME,
             "{0}{1}{2}".format(self.prefix, ping, self.suffix))
         ts3lib.flushClientSelfUpdates(self.schid)
         self.lastPing = ping
     except:
         from traceback import format_exc
         ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                           "pyTSon", 0)
Exemple #24
0
 def setMeta(self, schid, ownID=None):
     try:
         if not self.cfg.getboolean('general', 'enabled'): return
         if ownID is None: (error, ownID) = ts3.getClientID(schid)
         (error, oldmeta) = ts3.getClientVariableAsString(schid, ownID, ts3defines.ClientProperties.CLIENT_META_DATA)
         # e = xml.etree.ElementTree.parse('<addons><pytson></pytson></addons>').getroot()
         if oldmeta and '<{}>'.format(self.tag) in oldmeta:
             oldmeta = re.sub(r"<{0}>.*</{0}>".format(self.tag), "", oldmeta)
         newmeta = xml.Element('addons')
         db = ts3client.Config()
         q = db.query("SELECT value FROM addons")
         while(q.next()):
             val = q.value("value")
             addon = xml.SubElement(newmeta, "a")
             for l in val.split('\n'):
                 try:
                     if l.startswith('name='):
                         name = l.split('=', 1)[1].strip()
                         addon.text = name
                     elif l.startswith('version='):
                         version = l.split('=', 1)[1].strip()
                         addon.set("v", version)
                     elif l.startswith('author='):
                         author = l.split('=', 1)[1].strip()
                         addon.set("a", author)
                     elif l.startswith('type='):
                         type = l.split('=', 1)[1].strip()
                         addon.set("t", type)
                 except:from traceback import format_exc;ts3.logMessage("Error reading addon from Database:\n%s"%(name,format_exc()), ts3defines.LogLevel.LogLevel_ERROR, "{c}.{f}".format(c=self.__class__,f=__name__), schid);continue
         del db
         try: pytson = [element for element in newmeta.iter() if element.text == 'pyTSon'][0]
         except: pass
         if self.cfg.getboolean("general", "activeonly"): plugins = pluginhost.PluginHost.active.items()
         else: plugins = pluginhost.PluginHost.plugins.items()
         for name, plugin in plugins:
             try:
                 script = xml.SubElement(pytson, "s",{'v': plugin.version, 'a': plugin.author})
                 script.text = name
             except:from traceback import format_exc;ts3.logMessage("Error parsing script %s:\n%s"%(name,format_exc()), ts3defines.LogLevel.LogLevel_ERROR, "{c}.{f}".format(c=self.__class__,f=__name__), schid);continue
         newmeta = "{old}{new}".format(old=oldmeta,new=xml.tostring(newmeta).decode("utf-8"))
         # if PluginHost.cfg.getboolean("general", "verbose"): ts3.printMessageToCurrentTab(newmeta)
         error = ts3.setClientSelfVariableAsString(schid, ts3defines.ClientProperties.CLIENT_META_DATA, newmeta)
         if not error == ts3defines.ERROR_ok: ts3.printMessageToCurrentTab("Error: Unable to set own meta data to \"%s\"."%newmeta);return False
     except: from traceback import format_exc;ts3.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "{c}.{f}".format(c=self.__class__,f=__name__), schid)
Exemple #25
0
    def setStatus(self, schid):
        err, ownid = ts3.getClientID(schid)
        err, schids = ts3.getServerConnectionHandlerList()

        regex = re.compile(r'.*(<{0}>.*</{0}>).*'.format(self.tag),
                           re.IGNORECASE)

        host = ""
        port = 9987
        pw = ""
        name = ""
        nick = ""

        err, host, port, pw = ts3.getServerConnectInfo(schid)
        err, name = ts3.getServerVariable(
            schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_NAME)
        err, nick = ts3.getServerVariable(
            schid, 83
        )  # ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_NICKNAME
        if err == ts3defines.ERROR_ok and nick.strip(): nick = nick.split(":")
        err, ip = ts3.getConnectionVariableAsString(
            schid, ownid, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP)
        if err != ts3defines.ERROR_ok or not ip.strip():
            err, ip = ts3.getServerVariableAsString(
                schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_IP)
        err, port = ts3.getConnectionVariableAsString(
            schid, ownid,
            ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT)
        if err != ts3defines.ERROR_ok or not port or port < 1:
            err, port = ts3.getServerVariableAsString(
                schid,
                ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_PORT)

        for tab in schids:
            err, meta_data = ts3.getClientSelfVariable(
                tab, ts3defines.ClientProperties.CLIENT_META_DATA)
            meta_data = regex.sub("", meta_data)
            if tab == schid:
                ts3.setClientSelfVariableAsInt(
                    tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY,
                    ts3defines.AwayStatus.AWAY_NONE)
            else:
                err, away = ts3.getClientSelfVariable(
                    tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY)
                if away != ts3defines.AwayStatus.AWAY_ZZZ:
                    ts3.setClientSelfVariableAsInt(
                        tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY,
                        ts3defines.AwayStatus.AWAY_ZZZ)
                if self.cfg.getboolean('general', 'enabled'):
                    if host:
                        newmeta = xml.Element(self.tag)
                        c = xml.SubElement(newmeta, "tab")
                        c.set("i", str(schid))
                        if name: c.text = escape(name.strip())
                        c.set("h", escape(host))
                        if port and port != 9987:
                            c.set("port", "{}".format(port))
                        if pw and self.cfg.getboolean('general', 'pw'):
                            c.set("p", pw)
                        # if ip and ip.strip(): c.set("ip", ip)
                        # if nick: c.set("nick", ":".join(nick))
                        meta_data = "{old}{new}".format(
                            old=meta_data,
                            new=xml.tostring(newmeta).decode("utf-8"))
                        # meta_data = "{}<server>{}{}</server>".format(meta_data, ip, ":" + port if port else "")
                try:
                    name = name[:78] + (name[78:] and '..')
                except:
                    pass
                _away_message = self.cfg.get('general', 'status')
                if "{" in _away_message:
                    _away_message = _away_message\
                    .replace('{host}', host if host else "")\
                    .replace('{nick}', nick[0] if nick and len(nick) > 0 else "")\
                    .replace('{name}', name if name else "")\
                    .replace('{nickname}', nick[0] if nick else name)\
                    .replace('{ip}', ip if ip else "")\
                    .replace('{port}', str(port) if port else "")
                err, away_message = ts3.getClientSelfVariable(
                    tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY_MESSAGE)
                if away_message != _away_message:
                    ts3.setClientSelfVariableAsString(
                        tab,
                        ts3defines.ClientPropertiesRare.CLIENT_AWAY_MESSAGE,
                        _away_message)
            ts3.setClientSelfVariableAsString(
                tab, ts3defines.ClientProperties.CLIENT_META_DATA, meta_data)
            ts3.flushClientSelfUpdates(tab)
Exemple #26
0
 def setStatus(self, schid):
     try:
         err, ownid = ts3.getClientID(schid)
         err, schids = ts3.getServerConnectionHandlerList()
         regex = re.compile(r'.*(<{0}>.*</{0}>).*'.format(self.tag),
                            re.IGNORECASE)
         for tab in schids:
             err, meta_data = ts3.getClientSelfVariable(
                 tab, ts3defines.ClientProperties.CLIENT_META_DATA)
             meta_data = regex.sub("", meta_data)
             if tab == schid:
                 ts3.setClientSelfVariableAsInt(
                     tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY,
                     ts3defines.AwayStatus.AWAY_NONE)
             else:
                 err, away_message = ts3.getClientSelfVariable(
                     tab,
                     ts3defines.ClientPropertiesRare.CLIENT_AWAY_MESSAGE)
                 err, away = ts3.getClientSelfVariable(
                     tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY)
                 if away != ts3defines.AwayStatus.AWAY_ZZZ:
                     ts3.setClientSelfVariableAsInt(
                         tab, ts3defines.ClientPropertiesRare.CLIENT_AWAY,
                         ts3defines.AwayStatus.AWAY_ZZZ)
                 host = ""
                 port = 0
                 name = ""
                 if self.cfg.getboolean('general', 'enabled'):
                     err, host, port, pw = ts3.getServerConnectInfo(schid)
                     # err, ip = ts3.getConnectionVariableAsString(schid, ownid, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP)
                     # err, port = ts3.getConnectionVariableAsString(schid, ownid, ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT)
                     # err, ip = ts3.getServerVariableAsString(schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_IP)
                     # err, port = ts3.getServerVariableAsString(schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_PORT)
                     if host:
                         newmeta = xml.Element(self.tag)
                         c = xml.SubElement(newmeta, "tab")
                         c.set("id", str(schid))
                         err, name = ts3.getServerVariable(
                             schid, ts3defines.VirtualServerProperties.
                             VIRTUALSERVER_NAME)
                         if name: c.text = escape(name.strip())
                         c.set("host", escape(host))
                         if port and port != 9987:
                             c.set("port", "{}".format(port))
                         if pw and self.cfg.getboolean('general', 'pw'):
                             c.set("pw", pw)
                         meta_data = "{old}{new}".format(
                             old=meta_data,
                             new=xml.tostring(newmeta).decode("utf-8"))
                         # meta_data = "{}<server>{}{}</server>".format(meta_data, ip, ":" + port if port else "")
                 _away_message = self.cfg.get('general', 'status').replace(
                     '{host}', host if host else "").replace(
                         '{name}', name if name else "").replace(
                             '{port}',
                             str(port) if port else "")
                 if away_message != _away_message:
                     ts3.setClientSelfVariableAsString(
                         tab, ts3defines.ClientPropertiesRare.
                         CLIENT_AWAY_MESSAGE, _away_message)
             ts3.setClientSelfVariableAsString(
                 tab, ts3defines.ClientProperties.CLIENT_META_DATA,
                 meta_data)
             ts3.flushClientSelfUpdates(tab)
     except:
         from traceback import format_exc
         ts3.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                        "pyTSon", 0)
         pass
Exemple #27
0
 def commandNick(self, schid, targetMode, toID, fromID, params=""):
     ts3lib.setClientSelfVariableAsString(schid, ts3defines.ClientProperties.CLIENT_NICKNAME, params)
     ts3lib.flushClientSelfUpdates(schid)
Exemple #28
0
 def setAvatar(self, schid, img):
     ts3lib.setClientSelfVariableAsString(
         schid, ts3defines.ClientPropertiesRare.CLIENT_FLAG_AVATAR,
         self.getMd5FromFile(img))
     ts3lib.flushClientSelfUpdates(schid)
Exemple #29
0
 def changeName(self, schid, name=""):
     ts3lib.setClientSelfVariableAsString(
         schid, ts3defines.ClientProperties.CLIENT_NICKNAME, name)
     ts3lib.flushClientSelfUpdates(schid)
Exemple #30
0
 def tick(self):
     if self.getString('client_nickname') != "":
         ts3lib.setClientSelfVariableAsString(self.schid, ts3defines.ClientProperties.CLIENT_NICKNAME, self.buildString(self.getString('client_nickname')))
         ts3lib.flushClientSelfUpdates(self.schid)