コード例 #1
0
 def onUpdateClientEvent(self, schid, clid, invokerID, invokerName,
                         invokerUniqueIdentifier):
     (err, ownID) = ts3lib.getClientID(schid)
     (err, cid) = ts3lib.getChannelOfClient(schid, clid)
     (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID)
     (err, talker) = ts3lib.getClientVariable(
         schid, clid, ts3defines.ClientPropertiesRare.CLIENT_IS_TALKER)
     if cid == ownCID and talker: self.last_talk_power = clid
     if clid == self.requested:
         self.requested = 0
         if talker == 1: self.revokeTalkPower(schid, clid, True)
         # else: self.revokeTalkPower(schid, clid, False)
         (err, cldbid) = ts3lib.getClientVariable(
             schid, clid,
             ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
         (err, sgids) = ts3lib.getClientVariable(
             schid, clid,
             ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
         loc_sgids = intList(self.cfg.get("restrict", "sgids"))
         if set(loc_sgids).issubset(sgids):
             for sgid in loc_sgids:
                 ts3lib.requestServerGroupDelClient(schid, sgid, cldbid)
         else:
             for sgid in loc_sgids:
                 ts3lib.requestServerGroupAddClient(schid, sgid, cldbid)
コード例 #2
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT:
         (err, dbid) = ts3lib.getClientVariable(
             schid, selectedItemID,
             ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
         (err, sgroups) = ts3lib.getClientVariable(
             schid, selectedItemID,
             ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
         if menuItemID == 0:
             if self.sgid1 in sgroups:
                 ts3lib.requestServerGroupDelClient(schid, self.sgid1, dbid)
             else:
                 ts3lib.requestServerGroupAddClient(schid, self.sgid1, dbid)
         elif menuItemID == 1:
             if self.sgid2 in sgroups:
                 ts3lib.requestServerGroupDelClient(schid, self.sgid2, dbid)
             else:
                 ts3lib.requestServerGroupAddClient(schid, self.sgid2, dbid)
コード例 #3
0
ファイル: __init__.py プロジェクト: VerHext/pyTSon_plugins
 def onServerGroupListFinishedEvent(self, schid):
     try:
         sgid = self.idByName(self.tmpsgroups,self.cmdevent["params"])
         if not sgid: self.answerMessage(schid, self.cmdevent["targetMode"], self.cmdevent["toID"], self.cmdevent["fromID"], "Failed to find a servergroup like \"%s\""%self.cmdevent["params"]);return
         (error, dbid) = ts3lib.getClientVariableAsInt(schid, self.cmdevent["fromID"], ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
         (error, sgroups) = ts3lib.getClientVariableAsString(schid, self.cmdevent["fromID"], ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
         sgroups = [int(n) for n in sgroups.split(",")]
         if sgid in sgroups: _p = "added";p = "Adding"; error = ts3lib.requestServerGroupDelClient(schid, sgid, dbid)
         else: _p = "removed";p = "Removing"; error = ts3lib.requestServerGroupAddClient(schid, sgid, dbid)
         if error == ts3defines.ERROR_ok: _t = "Successfully {0} servergroup #{1}".format(_p, sgid)
         else: _t = "{0} Servergroup #{1} failed!".format(p, sgid)
         self.answerMessage(schid, self.cmdevent["targetMode"], self.cmdevent["toID"], self.cmdevent["fromID"], _t)
         self.tmpsgroups = []
     except: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
     self.cmdevent = {"event": "", "returnCode": "", "schid": 0, "targetMode": 4, "toID": 0, "fromID": 0, "params": ""}
コード例 #4
0
 def restrictForeigners(self, schid, clid):
     (err, cldbid) = ts3lib.getClientVariable(
         schid, clid, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
     (err, sgids) = ts3lib.getClientVariable(
         schid, clid, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
     loc_sgids = intList(self.cfg.get("restrict local", "sgids"))
     loc_cids = intList(self.cfg.get("restrict local", "cids"))
     if sgids and set(loc_sgids).issubset(sgids):
         for sgid in loc_sgids:
             ts3lib.requestServerGroupDelClient(schid, sgid, cldbid)
         (err, dcgid) = ts3lib.getServerVariable(
             schid, ts3defines.VirtualServerPropertiesRare.
             VIRTUALSERVER_DEFAULT_CHANNEL_GROUP)
         ts3lib.requestSetClientChannelGroup(schid, [dcgid] * len(loc_cids),
                                             loc_cids,
                                             [cldbid] * len(loc_cids))
         return
     for sgid in loc_sgids:
         ts3lib.requestServerGroupAddClient(schid, sgid, cldbid)
     ts3lib.requestSetClientChannelGroup(
         schid, [self.cfg.getint("restrict local", "cgid")] * len(loc_cids),
         loc_cids, [cldbid] * len(loc_cids))
     msg = self.cfg.get("restrict local", "poke")
     if msg: ts3lib.requestClientPoke(schid, self.last_joined_channel, msg)
コード例 #5
0
ファイル: __init__.py プロジェクト: lydemon/pyTSon_plugins
 def onClientDBIDfromUIDEvent(self, schid, uniqueClientIdentifier, cldbid):
     if not self.requested or not cldbid: return
     ts3lib.requestServerGroupAddClient(schid, self.sgid_nopoke, cldbid)
     self.requested = False
コード例 #6
0
    def processCommand(self, schid, keyword):
        args = keyword.split(' ')
        cmd = args.pop(0).lower()
        (err, clid) = ts3lib.getClientID(schid)
        (err, cldbid) = ts3lib.getClientVariable(
            schid, clid, ClientPropertiesRare.CLIENT_DATABASE_ID)
        if cmd == "grant":
            # if len(perm) < 2: return False
            # if len(perm) == 2: perm.append(False).append(False)
            skip = args[2] if len(args) > 2 else False
            val = boolean(args[1]) if len(args) > 1 else True
            perm = args[0]
            (err, pid) = ts3lib.getPermissionIDByName(schid, perm)
            ts3lib.printMessageToCurrentTab("Requesting \"{}\" ({})".format(
                perm, pid))
            ts3lib.requestClientAddPerm(schid, cldbid, [pid], [val], [skip])
            (err, ownCID) = ts3lib.getChannelOfClient(schid, clid)
            ts3lib.requestChannelClientAddPerm(schid, ownCID, cldbid, [pid],
                                               [val])
        elif cmd == "essential":
            self.getPerms(schid)
        elif cmd == "full":
            self.getFullPerms(schid)
        elif cmd == "build":
            _file = args.pop(0)
            self.p = self.buildLists(
                path.join(self.path, "{}.csv".format(_file)), schid)
            length = len(self.p[0])
            print("ids", length, "vals", len(self.p[1]), "skips",
                  len(self.p[2]), "negates", len(self.p[3]))
            print("\nIDs:\n", self.p[0])
            print("\nvals:\n", self.p[1])
            print("\nskips:\n", self.p[2])
            print("\nnegates:\n", self.p[3])
            ts3lib.printMessageToCurrentTab(
                "Loaded {} permissions".format(length))
        elif cmd == "client":
            each = len(args)
            if not each:
                ts3lib.requestClientAddPerm(schid, cldbid, self.p[0],
                                            self.p[1], self.p[2])
            else:
                length = len(self.p[0])
                for x in range(length):
                    ts3lib.requestClientAddPerm(schid, cldbid, [self.p[0][x]],
                                                [self.p[1][x]], [self.p[2][x]])
        elif cmd in ["channelclient", "clientchannel"]:
            (err, ownCID) = ts3lib.getChannelOfClient(schid, clid)
            each = len(args)
            if not each:
                ts3lib.requestChannelClientAddPerm(schid, ownCID, cldbid,
                                                   self.p[0], self.p[1])
            else:
                length = len(self.p[0])
                for x in range(length):
                    ts3lib.requestChannelClientAddPerm(schid, ownCID, cldbid,
                                                       [self.p[0][x]],
                                                       [self.p[1][x]])

        elif cmd == "channel":
            (err, ownCID) = ts3lib.getChannelOfClient(schid, clid)
            ts3lib.ts3lib.requestChannelAddPerm(schid, ownCID, self.p[0],
                                                self.p[1])
        elif cmd == "sgroup":
            sgid = int(args.pop(0))
            ts3lib.requestServerGroupAddPerm(schid, sgid, 1, self.p[0],
                                             self.p[1], self.p[2], self.p[3])
        elif cmd == "cgroup":
            cgid = int(args.pop(0))
            ts3lib.requestChannelGroupAddPerm(schid, cgid, 1, self.p[0],
                                              self.p[1])
        elif cmd == "id":
            (err, pid) = ts3lib.getPermissionIDByName(schid, args[0])
            ts3lib.printMessageToCurrentTab("{} = [b]{}".format(args[0], pid))
        elif cmd == "sgadd":
            sgid = int(args.pop(0))
            if len(args): cldbid = int(args.pop(0))
            ts3lib.requestServerGroupAddClient(schid, sgid, cldbid)
        elif cmd == "sgrem":
            sgid = int(args.pop(0))
            if len(args): cldbid = int(args.pop(0))
            ts3lib.requestServerGroupDelClient(schid, sgid, cldbid)
        else:
            return False
        return True