Example #1
0
 def users(self):
     (err, users) = ts3lib.getChannelClientList(self.schid, self.channelID)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error getting channel users list: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
     for userID in users:
         yield self.server.getUser(userID)
Example #2
0
 def updateChannel(self, schid, ownID=0, ownCID=0):
     if not ownID: (err, ownID) = ts3lib.getClientID(schid)
     if not ownCID: (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID)
     (err, cname) = ts3lib.getChannelVariable(
         schid, ownCID, ts3defines.ChannelProperties.CHANNEL_NAME)
     name = re.sub(r'^\[[crl\*]spacer(.*)?\]',
                   '',
                   cname,
                   flags=re.IGNORECASE | re.UNICODE)
     from unidecode import unidecode
     self.activity["state"] = unidecode(name)
     clients = len(ts3lib.getChannelClientList(schid, ownCID)[1])
     # (err, clients) = ts3lib.getChannelVariable(schid, ts3defines.ChannelPropertiesRare.)
     (err, cmax) = ts3lib.getChannelVariable(
         schid, ownCID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS)
     if cmax >= clients:
         print("cmax", cmax, ">=", "clients", clients)
         self.activity["party"]["size"] = [clients, cmax]
     else:
         (err, smax) = ts3lib.getServerVariable(
             schid,
             ts3defines.VirtualServerProperties.VIRTUALSERVER_MAXCLIENTS)
         # (err, clients) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_CLIENTS_ONLINE)
         # clients = len(ts3lib.getClientList(schid)[1])
         self.activity["party"] = {"size": [clients, smax]}
     (err, ip) = ts3lib.getConnectionVariable(
         schid, ownID, ts3defines.ConnectionProperties.CONNECTION_SERVER_IP)
     (err, port) = ts3lib.getConnectionVariable(
         schid, ownID,
         ts3defines.ConnectionProperties.CONNECTION_SERVER_PORT)
     self.activity["secrets"] = {
         "join": "ts3server://{}?port={}&cid={}".format(ip, port, ownCID)
     }
     self.update = True
Example #3
0
 def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity):
     if not self.check: return False
     if self.toggle:
         (error, _clid) = ts3lib.getClientID(schid)
         (error, _cid) = ts3lib.getChannelOfClient(schid, _clid)
         if clientID == _clid:
             if channelGroupID == self.sagroup:
                 if self.ownchannels.__contains__(channelID):
                     _t = False
                 else:
                     self.ownchannels.append(channelID)
             elif channelGroupID == self.smgroup:
                 (error, neededTP) = ts3lib.getChannelVariableAsInt(schid, _cid, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER)
                 if neededTP > 0:
                     (error, clients) = ts3lib.getChannelClientList(schid, _cid)
                     for client in clients:
                         if client == _clid: continue
                         (error, _cgid) = ts3lib.getClientVariableAsInt(schid, client, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID)
                         if _cgid == self.sagroup: continue
                         (error, uid) = ts3lib.getClientVariableAsString(schid, client, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
                         if self.InContacts(uid) == 0:
                             ts3lib.requestClientSetIsTalker(schid, client, True)
         elif channelID == _cid and channelGroupID == self.sbgroup:
             #(error, uid) = ts3lib.getClientVariableAsString(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
             (error, _cid) = ts3lib.getChannelOfClient(schid, clientID)
             if _cid in self.ownchannels:
                 ts3lib.requestClientKickFromChannel(schid, clientID, "You were banned by \"%s\""%invokerName + (" for \"%s\""%invokerName) if self.reason != "" else "")
Example #4
0
 def onClientMoveEvent(self, schid, clid, oldChannelID, newChannelID,
                       visibility, moveMessage):
     srv = self.ts3host.getServer(schid)
     if clid == srv.me.clientID:
         self.clients = {}
         (err, clids) = ts3lib.getChannelClientList(schid, newChannelID)
         for clid in clids:
             if clid == srv.me.clientID: continue
             self.onClientMoveEvent(schid, clid, 0,
                                    srv.me.channel.channelID,
                                    ts3defines.Visibility.ENTER_VISIBILITY,
                                    "")
         return
     if not srv.me.channel.channelID in [newChannelID, oldChannelID]: return
     # if not srv.me.getChannelGroupId() in [self.tabs[schid]["channelModGroup"],srv.defaultChannelAdminGroup]: return
     # (err, perm) = ts3lib.getClientNeededPermission(schid, "b_client_set_flag_talker")
     # if not perm: return
     if newChannelID == srv.me.channel.channelID:
         client = srv.getUser(clid)
         if client.getChannelGroupId() != srv.defaultChannelGroup: return
         status = getContactStatus(srv.me.uid)
         if status == ContactStatus.FRIEND: return
         self.clients[clid] = 0
     elif oldChannelID == srv.me.channel.channelID:
         if clid in self.clients: del self.clients[clid]
Example #5
0
 def onHotkeyOrCommandEvent(self, keyword, schid=0):
     if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID()
     if not self.schids or len(self.schids) < 1 or schid != self.schids[0] or not self.supchan: return
     if keyword == "move_first_from_waiting_room":
         (err, clids) = ts3lib.getChannelClientList(schid, self.supchan)
         (err, ownID) = ts3lib.getClientID(schid)
         (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID)
         ts3lib.requestClientMove(schid, clids[0], ownCID, "")
Example #6
0
 def checkChannel(self, schid):
     (err, clients) = ts3lib.getChannelClientList(schid, self.supchan); clients = len(clients)
     (err, maxclients) = ts3lib.getChannelVariable(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS)
     if clients < maxclients:
         ts3lib.setChannelVariableAsString(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_NAME,self.chan.get("props", "name open"))
     elif clients >= maxclients:
         ts3lib.setChannelVariableAsString(schid, self.supchan, ts3defines.ChannelProperties.CHANNEL_NAME, self.chan.get("props", "name in use"))
     else: return
     ts3lib.flushChannelUpdates(schid, self.supchan)
Example #7
0
 def onClientMoveEvent(self, schid, clid, oldChannelID, newChannelID, visibility, moveMessage):
     if not self.schids or len(self.schids) < 1 or schid != self.schids[0]: return
     if not self.supchan in [newChannelID, oldChannelID]: return
     (err, ownID) = ts3lib.getClientID(schid)
     (err, ownCID) = ts3lib.getChannelOfClient(schid, ownID)
     mycid = ts3lib.getChannelIDFromChannelNames(schid, self.cfg.get("general", "mychan").split(","))
     (err, clients) = ts3lib.getChannelClientList(schid, mycid); clients = len(clients)
     if ownCID == mycid and clients == 1 and newChannelID == self.supchan:
         ts3lib.requestClientMove(schid, clid, mycid, "")
     else: self.checkChannel(schid)
Example #8
0
 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
Example #9
0
 def infoData(self, schid, id, atype):
     try:
         if atype == ts3defines.PluginItemType.PLUGIN_CHANNEL:
             (error, clist) = ts3lib.getChannelClientList(schid, id)
             i = []
             for c in clist:
                 (error, clienttype) = ts3lib.getClientVariable(schid, c, ts3defines.ClientPropertiesRare.CLIENT_TYPE)
                 if clienttype == ts3defines.ClientType.ClientType_SERVERQUERY:
                     i.append(clientURL(schid, c))
             if len(i) < 1: return
             else: return i
     except: return
Example #10
0
 def getNearbyClients(serverConnectionHandlerID):
     users = ts3lib.getChannelClientList(
         serverConnectionHandlerID,
         tshelp.getChannelID(serverConnectionHandlerID))[1]
     userDetailed = []
     for user in users:
         userDetailed.append([
             user,
             ts3lib.getClientDisplayName(serverConnectionHandlerID,
                                         user)[1],
             tshelp.getAvatar(serverConnectionHandlerID, user)
         ])
     return userDetailed
Example #11
0
    def onClientMoveMovedEvent(self, schid, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUniqueIdentifier, moveMessage):
        try:
            (error, ownid) = ts3lib.getClientID(schid)
            (error, ownchan) = ts3lib.getChannelOfClient(schid, ownid)
            (error, afk) = ts3lib.getClientVariableAsInt(schid, ownid, ts3defines.ClientPropertiesRare.CLIENT_AWAY)
            if self.debug: ts3lib.printMessageToCurrentTab("onClientMoveMovedEvent: 1 | insupport: {0} | cursupchan: {1} | oldchan: {2}".format(self.insupport,self.cursupchan, self.oldchan))
            if self.debug: ts3lib.printMessageToCurrentTab("{0} {1} {2}".format(ownchan, self.afkchan, afk))
            if self.insupport == 0 and moverUniqueIdentifier == self.supbot and newChannelID == self.supchanmain and not ownchan == self.afkchan and not afk:
                for c in self.supchans:
                    (error, clients) = ts3lib.getChannelClientList(schid, c)
                    if len(clients) > 0: continue
                    else:
                        # ts3lib.sendPluginCommand(schid, "S3NDuZ3r", ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER, targetIDs, returnCode)
                        for ch in self.supchans:
                            (error, clients) = ts3lib.getChannelClientList(schid, ch)
                            if clientID in clients: return

                        ts3lib.requestClientMove(schid, clientID, c, "")
                        ts3lib.requestClientMove(schid, ownid, c, "")
                        (error, muted) = ts3lib.getClientVariableAsInt(schid, ownid, ts3defines.ClientProperties.CLIENT_OUTPUT_MUTED)
                        self.wasmuted = muted
                        ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientProperties.CLIENT_OUTPUT_MUTED, 0);ts3lib.flushClientSelfUpdates(schid)
                        self.insupport = clientID;self.cursupchan = c;self.oldchan = ownchan
                        if self.debug: ts3lib.printMessageToCurrentTab("Now in support with client #{0} in channel #{1}".format(clientID, c))
                        return
                ts3lib.printMessageToCurrentTab("No free support channel found for client #{0}! Please try manually.".format(clientID))
            elif self.insupport == clientID and oldChannelID == self.cursupchan and moverID == ownid:
                if self.wasmuted: ts3lib.setClientSelfVariableAsInt(schid, ts3defines.ClientProperties.CLIENT_OUTPUT_MUTED, 1);ts3lib.flushClientSelfUpdates(schid)
                ts3lib.requestClientMove(schid, ownid, self.oldchan, "")
                ts3lib.printMessageToCurrentTab("Not longer in support with client #{0} in channel #{1}".format(self.insupport, self.cursupchan))
                self.insupport = 0;self.cursupchan = 0;self.oldchan = 0
            if self.debug: ts3lib.printMessageToCurrentTab("onClientMoveMovedEvent: 2 | insupport: {0} | cursupchan: {1} | oldchan: {2}".format(self.insupport,self.cursupchan, self.oldchan))
        except:
            try: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0);pass
            except:
                try: from traceback import format_exc;ts3lib.printMessageToCurrentTab(format_exc())
                except:
                    try: from traceback import format_exc;print(format_exc())
                    except: print("Unknown Error")
Example #12
0
 def printQueries(self):
     (err, schids) = ts3lib.getServerConnectionHandlerList()
     for schid in schids:
         (err, cids) = ts3lib.getChannelList(schid)
         for cid in cids:
             (err, clids) = ts3lib.getChannelClientList(schid, cid)
             msg = []
             for clid in clids:
                 (err, ctype) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientPropertiesRare.CLIENT_TYPE)
                 if ctype != ts3defines.ClientType.ClientType_SERVERQUERY: continue
                 msg.append(clientURL(schid, clid))
             if len(msg) < 1: continue
             ts3lib.printMessage(schid, "<{0}> {1} has [b]{2}[/b] Query Clients: {3}".format(time(), channelURL(schid, cid), len(msg), ", ".join(msg)),
                                 ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
Example #13
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)
Example #14
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL:
         if menuItemID == 0:
             if not self.dlg: self.dlg = StatusDialog(self)
             self.dlg.show()
             self.dlg.raise_()
             self.dlg.activateWindow()
         elif menuItemID == 1:
             (err, haspw) = ts3lib.getChannelVariable(
                 schid, selectedItemID,
                 ChannelProperties.CHANNEL_FLAG_PASSWORD)
             (err, name) = ts3lib.getChannelVariable(
                 schid, selectedItemID, ChannelProperties.CHANNEL_NAME)
             if not haspw:
                 msgBox(
                     "Channel \"{0}\" has no password to crack!".format(
                         name), QMessageBox.Warning)
                 return
             self.mode = 0
             self.step = 1
             self.pwc = 0
             content = []
             with open(self.pwpath, encoding="utf-8") as f:
                 content = f.readlines()
             self.pws = [x.strip() for x in content]
             (err,
              clids) = ts3lib.getChannelClientList(schid, selectedItemID)
             for clid in clids:
                 (err, cname) = ts3lib.getClientVariable(
                     schid, clid, ClientProperties.CLIENT_NICKNAME)
                 self.pws[:0] = [cname, cname.lower(), cname.upper()]
                 (err, cnamep) = ts3lib.getClientVariable(
                     schid, selectedItemID,
                     ClientPropertiesRare.CLIENT_NICKNAME_PHONETIC)
                 if cnamep:
                     self.pws[:0] = [cnamep, cnamep.lower(), cnamep.upper()]
             self.pws[:0] = [name, name.lower(), name.upper()]
             list(OrderedDict.fromkeys(self.pws))
             self.startTimer(schid, selectedItemID)
         elif menuItemID == 2:
             (err, haspw) = ts3lib.getChannelVariable(
                 schid, selectedItemID,
                 ChannelProperties.CHANNEL_FLAG_PASSWORD)
             if not haspw:
                 (err, name) = ts3lib.getChannelVariable(
                     schid, selectedItemID, ChannelProperties.CHANNEL_NAME)
                 msgBox(
                     "Channel \"{0}\" has no password to crack!".format(
                         name), QMessageBox.Warning)
                 return
             self.mode = 1
             step = inputBox(self.name, 'How much to increase per try?')
             if step: self.step = int(step)
             start = inputBox(self.name, 'Where to start?')
             if start: self.pwc = int(start)
             self.startTimer(schid, selectedItemID)
         elif menuItemID == 3:
             (err, path,
              pw) = ts3lib.getChannelConnectInfo(schid, selectedItemID)
             if pw == None or pw == False or pw == "":
                 (err, name) = ts3lib.getChannelVariable(
                     schid, selectedItemID, ChannelProperties.CHANNEL_NAME)
                 msgBox('No password saved for channel {0}'.format(name))
                 return
             elif pw in self.pws:
                 msgBox(
                     "Not adding \"{0}\" to password db\n\nIt already exists!"
                     .format(pw), QMessageBox.Warning)
                 return
             self.pws.append(pw)
             with open(self.pwpath, "a") as myfile:
                 myfile.write('\n{0}'.format(pw))
             msgBox("Added \"{0}\" to password db".format(pw))
         elif menuItemID == 4:
             (err, name) = ts3lib.getChannelVariable(
                 schid, selectedItemID, ChannelProperties.CHANNEL_NAME)
             pw = inputBox("{0} - {1}".format(self.name, name), "Password:"******"passwordCracker:manual")
     elif atype == PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
         if menuItemID == 1:
             self.timer.stop()
             ts3lib.printMessageToCurrentTab('Timer stopped!')
         elif menuItemID == 2:
             pw = inputBox("Enter Channel Password to add", "Password:"******"":
                 msgBox("Not adding \"{0}\" to password db".format(pw),
                        QMessageBox.Warning)
                 return
             elif pw in self.pws:
                 msgBox(
                     "Not adding \"{0}\" to password db\n\nIt already exists!"
                     .format(pw), QMessageBox.Warning)
                 return
             self.pws.append(pw)
             with open(self.pwpath, "a") as myfile:
                 myfile.write('\n{0}'.format(pw))
             msgBox("Added \"{0}\" to password db".format(pw))
Example #15
0
 def channelClientCount(self, schid, channelID):
     (error, clients) = ts3lib.getChannelClientList(schid, channelID)
     if error == ts3defines.ERROR_ok: return len(clients)
     else: return error