コード例 #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
ファイル: bluscream.py プロジェクト: exp111/pyTSon-Scripts
def getClientIDByUID(schid, uid):
    (err, clids) = ts3lib.getClientList(schid)
    for clid in clids:
        (err, _uid) = ts3lib.getClientVariable(
            schid, clid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
        if uid == _uid: return clid
    return False
コード例 #3
0
ファイル: __init__.py プロジェクト: sancakbeyy/pyTSon_plugins
 def users(self):
     (err, users) = ts3lib.getClientList(self.schid)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error getting server users list: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
     for userID in users:
         yield self.getUser(userID)
コード例 #4
0
ファイル: __init__.py プロジェクト: spyderwan/pyTSon_plugins
 def processCommand(self, schid, command):
     clients = 1
     try:
         clients = int(command)
     except:
         pass
     self.clients = []
     # (err, clid) = ts3lib.getClientID(schid)
     # (err, cid) = ts3lib.getChannelOfClient(schid, clid)
     (err, clids) = ts3lib.getClientList(schid)
     self.clients.extend(clids)
     e, self.sgroup = ts3lib.getServerVariable(
         schid, ts3defines.VirtualServerPropertiesRare.
         VIRTUALSERVER_DEFAULT_SERVER_GROUP)
     e, acg = ts3lib.getServerVariable(
         schid, ts3defines.VirtualServerPropertiesRare.
         VIRTUALSERVER_DEFAULT_CHANNEL_GROUP)
     e, dcg = ts3lib.getServerVariable(
         schid, ts3defines.VirtualServerPropertiesRare.
         VIRTUALSERVER_DEFAULT_CHANNEL_ADMIN_GROUP)
     self.cgroups = [acg, dcg]
     timestamp, ret, badges = loadBadges()
     self.badges = []
     for badge in ret:
         self.badges.append(badge)
     if clients > 10:
         self.i = 1
         self.schid = schid
         self.c = clients + 1
         self.timer.start(2)
     else:
         for i in range(clients):
             self.addClient(schid)
             i += 1
     return True
コード例 #5
0
ファイル: __init__.py プロジェクト: sancakbeyy/pyTSon_plugins
 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)
コード例 #6
0
 def printAvatarUsers(self, schid):
     (err, clist) = ts3lib.getClientList(schid)
     msg = []
     for c in clist:
         (err, avatar) = ts3lib.getClientVariable(schid, c, ts3defines.ClientPropertiesRare.CLIENT_FLAG_AVATAR)
         if not avatar or avatar.strip() == "": continue
         msg.append("{}: {}".format(clientURL(schid, c), avatar))
     ts3lib.printMessageToCurrentTab("{}[u]Online users with avatars[/u]: [b]{}[/b]".format(timestamp(), len(msg)))
     i = 1
     for m in msg: ts3lib.printMessageToCurrentTab("{} {}".format(i, m)); i += 1
コード例 #7
0
ファイル: __init__.py プロジェクト: spyderwan/pyTSon_plugins
 def checkAllUsers(self):
     if not self.check: return False
     if self.toggle:
         _schid = ts3lib.getCurrentschid()
         (error, _clid) = ts3lib.getClientID(_schid)
         (error, cl) = ts3lib.getClientList(_schid)
         for user in cl:
             if user != _clid:
                 (error, uid) = ts3lib.getClientVariableAsString(_schid, user, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
                 self.checkUser(uid)
コード例 #8
0
ファイル: __init__.py プロジェクト: arrellik1337/TestScript
 def infoData(self, schid, id, atype):
     if self.count < 3:
         self.count += 1
         return None
     clist = list()
     if atype == ts3defines.PluginItemType.PLUGIN_SERVER:
         (err, clist) = ts3lib.getClientList(schid)
     elif atype == ts3defines.PluginItemType.PLUGIN_CHANNEL:
         return None
         (err, clist) = ts3lib.getChannelClientList(schid, id)
     else:
         return None
     sum = 0
     buddies = 0
     blocked = 0
     neutral = 0
     unknown = 0
     uidlist = []
     for clid in clist:
         (err, uid) = ts3lib.getClientVariable(
             schid, clid,
             ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
         uidlist.append(uid)
     db = ts3client.Config()
     q = db.query("SELECT * FROM contacts")
     while q.next():
         sum += 1
         val = q.value("value").split('\n')
         uid = ""
         for line in val:
             if line.startswith('IDS='):
                 uid = line.split('IDS=')[1]
         if not uid in uidlist: continue
         for line in val:
             if line.startswith('Friend='):
                 status = int(line[-1])
                 if status == ContactStatus.FRIEND: buddies += 1
                 elif status == ContactStatus.BLOCKED: blocked += 1
                 elif status == ContactStatus.NEUTRAL: neutral += 1
                 else: unknown += 1
     del db
     _return = list()
     _sum = buddies + blocked + neutral + unknown
     _return.append("Online: {} / {} ({}%)".format(_sum, sum,
                                                   percentage(_sum, sum)))
     _return.append("[color=green]Buddies[/color]: {} ({}%)".format(
         buddies, percentage(buddies, _sum)))
     _return.append("[color=red]Blocked[/color]: {} ({}%)".format(
         blocked, percentage(blocked, _sum)))
     _return.append("Neutral: {} ({}%)".format(neutral,
                                               percentage(neutral, _sum)))
     if unknown > 0:
         _return.append("[color=orange]Unknown[/color]: {} ({}%)".format(
             unknown, percentage(unknown, _sum)))
     return _return
コード例 #9
0
    def loadAvatars(self):
        pics = []
        schid = ts3.getCurrentServerConnectionHandlerID()
        err, clients = ts3.getClientList(schid)

        for client in clients:
            err, avatar = ts3.getAvatar(schid, client, 256)
            if avatar != None:
                pics.append(avatar)
        self.count = len(pics)
        self.ac.populate(pics)
コード例 #10
0
ファイル: __init__.py プロジェクト: spyderwan/pyTSon_plugins
 def checkQueries(self):
     (err, clist) = ts3lib.getClientList(self.schid)
     for c in clist:
         if c in self.queries:
             continue
         else:
             (err, ctype) = ts3lib.getClientVariable(self.schid, c, ts3defines.ClientPropertiesRare.CLIENT_TYPE)
             if ctype != ts3defines.ClientType.ClientType_SERVERQUERY: continue
             self.queries.append(c)
             (err, cid) = ts3lib.getChannelOfClient(self.schid, c)
             # (err, channelname) = ts3lib.getChannelVariable(self.schid, cid, ts3defines.ChannelProperties.CHANNEL_NAME)
             ts3lib.printMessage(self.schid, "<{0}> Found Query {1} in channel {2}".format(Time(), clientURL(self.schid, c), channelURL(self.schid, cid)), ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
コード例 #11
0
 def banName(self, schid, target, name):
     name_in_use = False
     (err, clids) = ts3lib.getClientList(schid)
     for clid in clids:
         if clid == target: continue
         (err, _name) = ts3lib.getClientVariable(
             schid, clid, ts3defines.ClientProperties.CLIENT_NICKNAME)
         if name in _name: name_in_use = True
     if not name_in_use: name = ".*{}.*".format(name)
     print("inuse:", name_in_use, "name:", name)
     ts3lib.banadd(schid, "", name, "",
                   self.cfg.getint("ban", "name duration"),
                   self.banReason())
コード例 #12
0
 def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored):
     if message == "!help":
         msg = "Dostępne komendy: "+", ".join(self.commands)
         err = ts3lib.requestSendPrivateTextMsg(schid, msg, fromID)
     elif message[0:5] == "!help" and len(message) > 6:
         self.helpInfo(schid, fromID, message[6:])
     elif message[0:6] == "!mpoke" and fromUniqueIdentifier in self.allow_uid:
         self.poke_name = message[7:message.index(",")]
         self.poke_amount = int(message[message.index(",")+1:])
         self.from_name = fromName
         self.from_uid = fromUniqueIdentifier
         self.sleep_time = 0.1
         (err, clist) = ts3lib.getClientList(schid)
         for key in clist:
             (err_name, name) = ts3lib.getClientVariableAsString(schid, key, ts3defines.ClientProperties.CLIENT_NICKNAME)
             if name == self.poke_name:
                 for i in range(0,self.poke_amount):
                     if self.from_uid == "dummy_id_for_some_reasons":
                         err_poke = ts3lib.requestClientPoke(schid, key, "dummy_message_for_some_reasons")
                     else:
                         err_poke = ts3lib.requestClientPoke(schid, key, "")
                     time.sleep(self.sleep_time)
     elif message == "!raidpoke":
         (err, groups) = ts3lib.getClientVariableAsString(schid, fromID, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
         gr = groups.split(",")
         if any(True for x in groups if x in str(self.wh_gr_list)):
             (err, clist) = ts3lib.getClientList(schid)
             for key in clist:
                 err_poke = ts3lib.requestClientPoke(schid, key, "%s mass pokes." % fromName)
     elif message[0:9] == "!raidpoke" and len(message) > 9:
         msg = message[message.index(" ")+1:]
         (err, groups) = ts3lib.getClientVariableAsString(schid, fromID, ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
         gr = groups.split(",")
         if any(True for x in groups if x in str(self.wh_gr_list)):
             (err, clist) = ts3lib.getClientList(schid)
             for key in clist:
                 err_poke = ts3lib.requestClientPoke(schid, key, "%s sends: %s" % (fromName,msg))
コード例 #13
0
 def getScores(self, schid, flag, mode, count=10):
     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.getConnectionVariable(schid, clid, flag)
         if err == ts3defines.ERROR_ok: c[clid] = ping
     if mode == 0:
         s = sorted(c.items(), key=lambda x: int(x[1]))
     elif mode == 1:
         s = sorted(c.items(), key=lambda x: int(x[1]), reverse=True)
     return take(count, s)
コード例 #14
0
ファイル: serverview.py プロジェクト: TheKilledDead/pyTSon
    def _reloadClientlist(self):
        err, clids = ts3lib.getClientList(self.schid)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting clientlist", err, self.schid)
            return

        for c in clids:
            err, parent = ts3lib.getChannelOfClient(self.schid, c)
            if err == ts3defines.ERROR_ok:
                self.onClientMoveEvent(self.schid, c, 0, parent,
                                       ts3defines.Visibility.ENTER_VISIBILITY,
                                       "")
            else:
                _errprint("Error getting client channel", err, self.schid, c)
                pass
コード例 #15
0
ファイル: serverview.py プロジェクト: pathmann/pyTSon
    def _reloadClientlist(self):
        err, clids = ts3lib.getClientList(self.schid)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting clientlist", err, self.schid)
            return

        for c in clids:
            err, parent = ts3lib.getChannelOfClient(self.schid, c)
            if err == ts3defines.ERROR_ok:
                self.onClientMoveEvent(self.schid, c, 0, parent,
                                       ts3defines.Visibility.ENTER_VISIBILITY,
                                       "")
            else:
                _errprint("Error getting client channel", err, self.schid, c)
                pass
コード例 #16
0
ファイル: __init__.py プロジェクト: sancakbeyy/pyTSon_plugins
 def checkVars(self, schid, clid):
     (err, ownID) = ts3lib.getClientID(schid)
     (err, uid) = ts3lib.getClientVariable(
         schid, clid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     if ownID == clid:
         (err, uid) = ts3lib.getClientSelfVariable(
             schid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     if err != ts3defines.ERROR_ok or not uid: uid = False
     (err, mytsid) = ts3lib.getClientVariable(schid, clid, 61)
     if ownID == clid: (err, mytsid) = ts3lib.getClientList(schid, 61)
     if err != ts3defines.ERROR_ok or not mytsid: mytsid = False
     (err, ip) = ts3lib.getConnectionVariable(
         schid, clid, ts3defines.ConnectionProperties.CONNECTION_CLIENT_IP)
     if err != ts3defines.ERROR_ok or not ip: ip = False
     return uid, mytsid, ip
コード例 #17
0
 def onConnectStatusChangeEvent(self, schid, status, errorNumber):
     if status != ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED: return
     (err, mynick) = ts3lib.getClientSelfVariable(schid, ts3defines.ClientProperties.CLIENT_NICKNAME)
     if err != ts3defines.ERROR_ok: return
     sp = re.split(r"\d", mynick)
     if len(sp) > 1 and sp[0] != mynick and sp[1] == "":
         (err, clis) = ts3lib.getClientList(schid)
         if err != ts3defines.ERROR_ok: return
         for cli in clis:
             (err, nick) = ts3lib.getClientVariable(schid, cli, ts3defines.ClientProperties.CLIENT_NICKNAME)
             if err == ts3defines.ERROR_ok and nick == sp[0]:
                 err = ts3lib.requestClientKickFromServer(schid, cli, "Client not responding")
                 self.schid = schid; self.newnick = sp[0]
                 ts3lib.printMessageToCurrentTab('err: {0}'.format(err))
                 if err == ts3defines.ERROR_ok: self.rename()
                 else: QTimer.singleShot(30000, self.rename)
コード例 #18
0
ファイル: __init__.py プロジェクト: patokonski/PyTson-scripts
 def onClientIDsEvent(self, serverConnectionHandlerID,
                      uniqueClientIdentifier, clientID, clientName):
     if self.flagnm == 1:
         self.flagnm = 0
         (err, clist) = ts3lib.getClientList(serverConnectionHandlerID)
         msg = "Client without groups, nick: " + self.last_name
         for key in clist:
             (err, groups) = ts3lib.getClientVariableAsString(
                 serverConnectionHandlerID, key,
                 ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
             if any(True for x in groups if x in str(self.wh_gr_list)):
                 err_poke = ts3lib.requestClientPoke(
                     serverConnectionHandlerID, key, msg)
         ts3lib.printMessageToCurrentTab(time.ctime(time.time()))
         ts3lib.printMessageToCurrentTab(msg)
         ts3lib.printMessageToCurrentTab(
             "------------------------------------------------")
コード例 #19
0
ファイル: bluscream.py プロジェクト: exp111/pyTSon-Scripts
def getClientIDByName(name: str,
                      schid: int = 0,
                      use_displayname: bool = False,
                      multi: bool = False):
    if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID()
    if multi: results = []
    (err, clids) = ts3lib.getClientList(schid)
    for clid in clids:
        if use_displayname:
            (err, _name) = ts3lib.getClientDisplayName(schid, clid)
        else:
            (err, _name) = ts3lib.getClientVariable(
                schid, clid, ts3defines.ClientProperties.CLIENT_NICKNAME)
        if name == _name:
            if multi: results.append(clid)
            else: return clid
    if multi and len(results): return results
コード例 #20
0
ファイル: __init__.py プロジェクト: PassiAPI/pyTSon_plugins
 def printMetaUsers(self, schid):
     (err, clist) = ts3lib.getClientList(schid)
     msg = []
     for c in clist:
         (err, mdata) = ts3lib.getClientVariable(
             schid, c, ts3defines.ClientProperties.CLIENT_META_DATA)
         if not mdata or mdata.strip() == "": continue
         mdata = (mdata[:100].replace("\n", "\\n"))
         msg.append("{}: {}".format(clientURL(schid, c), mdata))
     ts3lib.printMessageToCurrentTab(
         "{}[u]Online users with metadata[/u]: [b]{}[/b]".format(
             timestamp(), len(msg)))
     try:
         msg.sort(key=lambda s: s.split(": ")[1])
     except:
         pass
     i = 1
     for m in msg:
         ts3lib.printMessageToCurrentTab("{} {}".format(i, m))
         i += 1
コード例 #21
0
def getClientCounts(schid):
    ret = {"total": {}, "visible": {}, "hidden": {}}
    err, visible = ts3lib.getClientList(schid)
    ret["visible"]["users"] = 0
    ret["visible"]["queries"] = 0
    for clid in visible:
        (err,
         ctype) = ts3lib.getClientVariable(schid, clid,
                                           ClientPropertiesRare.CLIENT_TYPE)
        if ctype == ClientType.ClientType_NORMAL: ret["visible"]["users"] += 1
        elif ctype == ClientType.ClientType_SERVERQUERY:
            ret["visible"]["queries"] += 1
    ret["visible"]["total"] = ret["visible"]["users"] + ret["visible"][
        "queries"]  # len(visible)
    (err, ret["total"]["clients"]) = ts3lib.getServerVariable(
        schid, VirtualServerProperties.VIRTUALSERVER_CLIENTS_ONLINE)
    (err, ret["total"]["queries"]) = ts3lib.getServerVariable(
        schid, VirtualServerPropertiesRare.VIRTUALSERVER_QUERYCLIENTS_ONLINE)
    (err, ret["max"]) = ts3lib.getServerVariable(
        schid, VirtualServerProperties.VIRTUALSERVER_MAXCLIENTS)
    ret["hidden"]["total"] = ret["total"]["clients"] - ret["visible"]["total"]
    return ret
コード例 #22
0
ファイル: __init__.py プロジェクト: arrellik1337/TestScript
 def onlineContacts(self, schid, neutral=list()):
     contacts = getContacts()
     lst = {}
     for contact in contacts:
         lst[contact["IDS"]] = contact["Friend"]
     del contacts
     (err, clist) = ts3lib.getClientList(schid)
     buddies = []
     blocked = []
     unknown = []
     for clid in clist:
         (err, uid) = ts3lib.getClientVariable(
             schid, clid,
             ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
         if not uid in lst: continue
         if lst[uid] == ContactStatus.FRIEND:
             buddies.append(clientURL(schid, clid, uid))
         elif lst[uid] == ContactStatus.BLOCKED:
             blocked.append(clientURL(schid, clid, uid))
         elif lst[uid] == ContactStatus.NEUTRAL:
             if neutral: neutral.append(clientURL(schid, clid, uid))
         else: unknown.append(clientURL(schid, clid, uid))
     _sum = len(buddies) + len(blocked) + len(unknown)
     if neutral: _sum += len(neutral)
     msg = ["[u]My Online Contacts [/u]: [b]{}[/b]".format(_sum)]
     if len(buddies) > 0:
         msg.append("[b]{}[/b] [color=green]Buddies[/color]: {}".format(
             len(buddies), " | ".join(buddies)))
     if len(blocked) > 0:
         msg.append("[b]{}[/b] [color=red]Blocked[/color]: {}".format(
             len(blocked), " | ".join(blocked)))
     if neutral and len(neutral) > 0:
         msg.append("[b]{}[/b] Neutral: {}".format(len(neutral),
                                                   " | ".join(neutral)))
     if len(unknown) > 0:
         msg.append("[b]{}[/b] [color=orange]Unknown[/color]: {}".format(
             len(unknown), " | ".join(unknown)))
     return "\n".join(msg)
コード例 #23
0
 def onConnectStatusChangeEvent(self, serverConnectionHandlerID, newStatus,
                                errorNumber):
     if not self.cfg.getboolean("events", "own client connected"): return
     if newStatus == ts3defines.ConnectStatus.STATUS_CONNECTION_ESTABLISHED:
         (error, ids) = ts3.getClientList(serverConnectionHandlerID)
         if error == ts3defines.ERROR_ok:
             for _in in ids:
                 (error, _type) = ts3.getClientVariableAsInt(
                     serverConnectionHandlerID, clientID,
                     ts3defines.ClientPropertiesRare.CLIENT_TYPE)
                 if error == ts3defines.ERROR_ok and _type == 0:
                     self.requested = clientID
                     self.schid = serverConnectionHandlerID
                     ts3.requestConnectionInfo(serverConnectionHandlerID,
                                               clientID)
                 elif error == ts3defines.ERROR_ok and _type == 1:
                     return
                 else:
                     ts3.printMessageToCurrentTab(
                         "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the client type of '%s'"
                         % self.clientURL(serverConnectionHandlerID,
                                          clientID))
                     return
コード例 #24
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)