def onServerErrorEvent(cls, schid, errorMessage, error, returnCode, extraMessage): if schid not in cls.stores: return False store = cls.getStore(schid) if returnCode in store.sendKeyReturnCodes: if error != ts3defines.ERROR_ok: _ts3lib.logMessage("Sendkey failed: %s" % errorMessage, ts3defines.LogLevel.LogLevel_DEBUG, "pyTSon._PluginCommandHandler", 0) store.sendKeyReturnCodes.remove(returnCode) return True (clid, reqkey) = store.getRequest(returnCode) if clid: if error != ts3defines.ERROR_ok: store.removeRequest(clid, reqkey, returnCode) _ts3lib.logMessage("Requestkey failed: %s" % errorMessage, ts3defines.LogLevel.LogLevel_DEBUG, "pyTSon._PluginCommandHandler", 0) return True return False
def _processCommands(cls, schid, cmds): if not cmds: return (False, None, None) store = cls.getStore(schid) pubkey = store.publickey(cmds[0].sender) junkkeys = [] firecmds = [] for cmd in cmds: if cmd.pkgkey in junkkeys: continue if not cmd.verify(pubkey): junkkeys.append(cmd.pkgkey) store.removeMerge(cmd.pkgkey) elif cmd.isComplete(): firecmds.append(cmd.data) else: merge = store.getMerge(cmd.pkgkey) if not merge.add(cmd): store.removeMerge(cmd.pkgkey) _ts3lib.logMessage("Plugincommand merge junked", ts3defines.LogLevel.LogLevel_DEBUG, "pyTSon._PluginCommandHandler", 0) elif merge.isComplete(): store.removeMerge(cmd.pkgkey) firecmds.append(merge.content) if len(firecmds) > 0: return (True, cmds[0].sender, firecmds) else: return (False, None, None)
def getMerge(self, pkgkey): if pkgkey not in self.merges: if len(self.merges) > MAX_MERGES: # this is a security measure, if someone is trying to # overflow us with parts _ts3lib.logMessage("Plugincommand merges cleared", ts3defines.LogLevel.LogLevel_WARNING, "pyTSon._PluginCommandHandler", 0) self.merges.clear() self.merges[pkgkey] = _PluginCommandMerge() return self.merges[pkgkey]
def storeCommand(self, cmd): if len(self.cmdstore) > MAX_CMD_STORE: # this is a security measure, if someone is trying to # overflow us with unverified cmds _ts3lib.logMessage("Plugincommand store cleared", ts3defines.LogLevel.LogLevel_WARNING, "pyTSon._PluginCommandStore", 0) self.cmdstore.clear() if cmd.sender not in self.cmdstore: self.cmdstore[cmd.sender] = [cmd] else: self.cmdstore[cmd.sender].append(cmd)