예제 #1
0
 def processCommand(self, schid, cmd):
     cmd = cmd.split(' ', 1)
     command = cmd[0].lower()
     if command == "ping":
         count = int(cmd[1]) if cmd[1] else 5
         c = {}
         (err, clids) = ts3lib.getClientList(schid)
         for clid in clids:
             # if len(self.c) > 10: break
             if not clid in self.c:
                 ts3lib.requestConnectionInfo(schid, clid)
                 self.c.append(clid)
             (err, ping) = ts3lib.getConnectionVariableAsUInt64(schid, clid, ts3defines.ConnectionProperties.CONNECTION_PING)
             if err == ts3defines.ERROR_ok: c[clid] = ping
         print(c)
         s = sorted(c.items(), key=lambda x: int(x[1]))
         t = take(count, s)
         string = ""
         place = 1
         for k,v in t:
             string += '{0}: {1} with [b]{2}[/b]ms\n'.format(place,clientURL(schid,k),v)
             place += 1
         (err, ownid) = ts3lib.getClientID(schid)
         (err, ownchan) = ts3lib.getChannelOfClient(schid, ownid)
         message = [string[i:i + 900] for i in range(0, len(string), 900)]
         # message = re.findall('.{1,1024}(?:\n|$)', string)
         # message = (textwrap.wrap(string, 1024))
         # message = (line.strip() for line in re.findall(r'.{1,80}(?:\s+|$)', string))
         # message = textwrap.wrap(string, 1024, break_long_words=False)
         for msg in message: ts3lib.requestSendChannelTextMsg(schid, '\n{0}'.format(msg), ownchan)
     elif command == "clear":
         self.c = []
     return 1
예제 #2
0
 def backup(self, serverConnectionHandlerID):
     ownID = ts3lib.getClientID(serverConnectionHandlerID)[1]
     ip = ts3lib.getConnectionVariableAsString(
         serverConnectionHandlerID, ownID,
         ts3defines.ConnectionProperties.CONNECTION_SERVER_IP)[1]
     self.cfg['data']['ip'] = ip
     port = ts3lib.getConnectionVariableAsUInt64(
         serverConnectionHandlerID, ownID,
         ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT)[1]
     self.cfg['data']['port'] = str(port)
     serverPassword = ts3lib.getServerConnectInfo(serverConnectionHandlerID,
                                                  256)[3]
     self.currentServerPW = serverPassword
     nickname = ts3lib.getClientSelfVariableAsString(
         serverConnectionHandlerID,
         ts3defines.ClientProperties.CLIENT_NICKNAME)[1]
     self.cfg.set('data', 'nickname', nickname)
     tabID = ts3defines.PluginConnectTab.PLUGIN_CONNECT_TAB_CURRENT
     self.cfg['data']['tabID'] = str(tabID)
     channelID = ts3lib.getChannelOfClient(serverConnectionHandlerID,
                                           ownID)[1]
     channelPassword = ts3lib.getChannelConnectInfo(
         serverConnectionHandlerID, channelID, 256)[2]
     self.currentChannelPW = channelPassword
     return
예제 #3
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
예제 #4
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)