Esempio n. 1
0
 def fakeClient(self, schid, clientID):
     (error, _clid) = ts3lib.getClientID(schid)
     (error, tnick) = ts3lib.getClientVariableAsUInt64(
         schid, clientID, ts3defines.ClientProperties.CLIENT_NICKNAME)
     (error, tnickp) = ts3lib.getClientVariableAsUInt64(
         schid, clientID,
         ts3defines.ClientProperties.CLIENT_NICKNAME_PHONETIC)
Esempio n. 2
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL:
         if menuItemID == 0:
             self.channel = selectedItemID
             ts3lib.printMessageToCurrentTab('[{:%Y-%m-%d %H:%M:%S}] '.format(datetime.now())+" Set target channel to [color=yellow]"+str(self.channel)+"[/color]")
         elif menuItemID == 1:
             (e, cgid) = ts3lib.getServerVariableAsUInt64(schid, ts3defines.VirtualServerPropertiesRare.VIRTUALSERVER_DEFAULT_CHANNEL_GROUP)
             x = QDialog()
             x.setAttribute(Qt.WA_DeleteOnClose)
             dbid = QInputDialog.getInt(x, "Manually change channel group", "Enter DBID", QLineEdit.Normal)
             if self.channel == 0:
                 (e, ownID) = ts3lib.getClientID(schid)
                 (e, self.channel) = ts3lib.getChannelOfClient(schid, ownID)
             name = "DBID: %s"%dbid
             if self.debug:
                 ts3lib.printMessageToCurrentTab("toggle: {0} | debug: {1} | channel: {2} | groups: {3} | dbid: {4} | name: {5}".format(self.toggle,self.debug,self.channel,self.groups,dbid,name))
                 ts3lib.printMessageToCurrentTab("schid: {0} | cgid: {1} | dbid: {2}".format(schid,cgid,dbid))
             if not self.dlg: self.dlg = ChannelGroupDialog(schid, cgid, dbid, name, self.channel, self.groups)
             self.dlg.show();self.dlg.raise_();self.dlg.activateWindow()
     elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT:
         if menuItemID == 0:
             if self.channel == 0:
                 (e, ownID) = ts3lib.getClientID(schid)
                 (e, self.channel) = ts3lib.getChannelOfClient(schid, ownID)
             (e, dbid) = ts3lib.getClientVariableAsUInt64(schid, selectedItemID, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
             (e, cgid) = ts3lib.getClientVariableAsUInt64(schid, selectedItemID, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID)
             (e, name) = ts3lib.getClientVariableAsString(schid, selectedItemID, ts3defines.ClientProperties.CLIENT_NICKNAME)
             if self.debug: ts3lib.printMessageToCurrentTab("toggle: {0} | debug: {1} | channel: {2} | groups: {3} | dbid: {4} | name: {5}".format(self.toggle,self.debug,self.channel,self.groups,dbid,name))
             if not self.dlg: self.dlg = ChannelGroupDialog(schid, cgid, dbid, name, self.channel, self.groups)
             self.dlg.show();self.dlg.raise_();self.dlg.activateWindow()
Esempio n. 3
0
 def getChannelGroupId(self):
     (err, cgid) = ts3lib.getClientVariableAsUInt64(
         self.schid, self.clientID,
         ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error getting client channel group id: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
     #TODO Return ChannelGroups Object.
     return cgid
Esempio n. 4
0
    def channelGroup(self):
        if "channelGroup" in self.cache:
            return self.cache["channelGroup"]

        err, g = ts3lib.getClientVariableAsUInt64(self.schid, self.clid,
                                                  ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting client channelgroup", err, self.schid,
                      self.clid)
            return 0
        else:
            self.cache["channelGroup"] = g
            return g
Esempio n. 5
0
    def channelGroup(self):
        if "channelGroup" in self.cache:
            return self.cache["channelGroup"]

        err, g = ts3lib.getClientVariableAsUInt64(
            self.schid, self.clid,
            ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting client channelgroup", err, self.schid,
                      self.clid)
            return 0
        else:
            self.cache["channelGroup"] = g
            return g
Esempio n. 6
0
    def setClientChannelGroup(self, schid, status, cid, chid):        
        (error, suid) = ts3.getServerVariableAsString(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
        (error, curr_channelgroup) = ts3.getClientVariableAsString(schid, cid, ts3defines.ClientPropertiesRare.CLIENT_CHANNEL_GROUP_ID)

        db = self.db.exec_("SELECT db_f_channelgroup, db_b_channelgroup FROM server WHERE db_suid='"+str(suid)+"' LIMIT 1")
        if not self.db.lastError().isValid():
            if db.next():
                if status == 1 and (db.value("db_b_channelgroup") == "" or db.value("db_b_channelgroup") == int(curr_channelgroup)): return
                if status == 0 and (db.value("db_f_channelgroup") == "" or db.value("db_f_channelgroup") == int(curr_channelgroup)): return
                (error, cdbid) = ts3.getClientVariableAsUInt64(schid, cid, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
                group = None
                if status == 1: group = db.value("db_b_channelgroup")
                if status == 0: group = db.value("db_f_channelgroup")
                ts3.requestSetClientChannelGroup(schid, [group], [chid], [cdbid], self.error_setClientChannelGroup)
Esempio n. 7
0
    def iconID(self):
        if "iconID" in self.cache:
            return self.cache["iconID"]

        err, i = ts3lib.getClientVariableAsUInt64(self.schid, self.clid,
                                                  ts3defines.ClientPropertiesRare.CLIENT_ICON_ID)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting client iconid", err, self.schid,
                      self.clid)
            return 0
        else:
            if i < 0:
                i = pow(2, 32) + i

            self.cache["iconID"] = i
            return i
Esempio n. 8
0
    def iconID(self):
        if "iconID" in self.cache:
            return self.cache["iconID"]

        err, i = ts3lib.getClientVariableAsUInt64(
            self.schid, self.clid,
            ts3defines.ClientPropertiesRare.CLIENT_ICON_ID)
        if err != ts3defines.ERROR_ok:
            _errprint("Error getting client iconid", err, self.schid,
                      self.clid)
            return 0
        else:
            if i < 0:
                i = pow(2, 32) + i

            self.cache["iconID"] = i
            return i
Esempio n. 9
0
 def onUpdateClientEvent(self, schid, clientID, invokerID, invokerName,
                         invokerUniqueIdentifier):
     if not self.update == clientID: return
     self.update = 0
     (error, connects) = ts3lib.getClientVariableAsUInt64(
         schid, clientID,
         ts3defines.ClientPropertiesRare.CLIENT_TOTALCONNECTIONS)
     (error, uid) = ts3lib.getClientVariableAsString(
         schid, clientID,
         ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     if self.debug:
         ts3lib.printMessageToCurrentTab(
             "error: {0} | connects: {1} | uid: {2}".format(
                 error, connects, uid))
     if connects > 1 and not uid == "x63jNGEr/PXnu9l3bFECzMzWfXk=": return
     (error, suid) = ts3lib.getServerVariableAsString(
         schid,
         ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     (error, country) = ts3lib.getClientVariableAsString(
         schid, clientID, ts3defines.ClientPropertiesRare.CLIENT_COUNTRY)
     if self.debug:
         ts3lib.printMessageToCurrentTab("error: {0} | country: {1}".format(
             error, country))
     msg = self.cfg.get(suid, country, fallback=self.cfg.get(suid, 'US'))
     if '{nick}' in msg:
         msg = msg.replace('{nick}', self.clientURL(schid, clientID, uid))
     if '{country}' in msg: msg = msg.replace('{country}', country)
     if '{cid}' in msg: msg = msg.replace('{cid}', clientID)
     if '{uid}' in msg: msg = msg.replace('{uid}', uid)
     if '{connects}' in msg: msg = msg.replace('{connects}', connects)
     msg = [msg[i:i + 1024] for i in range(0, len(msg), 1024)]
     for message in msg:
         ts3lib.requestSendPrivateTextMsg(schid, "{0}".format(message),
                                          clientID)
     (error, ownid) = ts3lib.getClientID(schid)
     (error, _uid) = ts3lib.getClientVariableAsString(
         schid, ownid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     ts3lib.clientChatClosed(schid, uid, clientID)
     ts3lib.printMessageToCurrentTab(
         "Sent client {0} the welcome message for {1}".format(
             clientID, suid))
Esempio n. 10
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)