Exemplo n.º 1
0
    def onClientPokeEvent(self, serverConnectionHandlerID, fromClientID,
                          pokerName, pokerUID, message, ffIgnored):
        #is it me?
        (err, schids) = ts3lib.getServerConnectionHandlerList()
        if err == ts3defines.ERROR_ok:
            for schid in schids:
                (err, myid) = ts3lib.getClientID(schid)
                if err == ts3defines.ERROR_ok:
                    if fromClientID == myid:
                        return 0
                else:
                    ts3lib.printMessageToCurrentTab(
                        "error getting own client id")
        else:
            ts3lib.printMessageToCurrentTab("error getting schids")

        (err, name) = ts3lib.getClientVariableAsString(
            serverConnectionHandlerID, fromClientID,
            ts3defines.ClientProperties.CLIENT_NICKNAME)
        if err != ts3defines.ERROR_ok:
            err = ts3lib.requestClientPoke(serverConnectionHandlerID,
                                           fromClientID, "?")
        else:
            err = ts3lib.requestClientPoke(serverConnectionHandlerID,
                                           fromClientID, "?")

        self.lastpoker = (serverConnectionHandlerID, fromClientID)

        if err != ts3defines.ERROR_ok:
            ts3lib.printMessageToCurrentTab("poke error: %d" % err)
            return 0
        else:
            return 0
Exemplo n.º 2
0
    def onClientPokeEvent(self, schid, fromClientID, pokerName, pokerUniqueIdentity, message, ffIgnored):
        try:
            mClientID = ts3.getClientID(schid)[1]
            if (mClientID == fromClientID):
                return

            messageL = message.lower()
            parts = message.split(" ")
            
            msg = "no "
            foundNo = False
            foundU = False

            for current in parts:
                if (current == "no"):
                    msg += "no "
                    foundNo = True
                elif (current == "u"):
                    msg += current
                    foundU = True
                    break
                else:
                    continue
            
            if (not foundNo or not foundU):
                return

            ts3.requestClientPoke(schid, fromClientID, msg, "")
        except:
            from traceback import format_exc;ts3.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
Exemplo n.º 3
0
 def onClientPokeEvent(self, schid, fromClientID, pokerName,
                       pokerUniqueIdentity, message, ffIgnored):
     if pokerUniqueIdentity not in self.white_list:
         ts3lib.requestClientPoke(schid, fromClientID, self.msg)
         return True
     else:
         return False
Exemplo n.º 4
0
 def onHotkeyOrCommandEvent(self, keyword, schid=0):
     if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID()
     if keyword == "restrict_last_joined_server":
         self.requested = self.last_joined_server
         msg = self.cfg.get("restrict", "poke")
         if msg: ts3lib.requestClientPoke(schid, self.requested, msg)
         ts3lib.requestClientVariables(schid, self.last_joined_server)
         # self.restrictClient(schid, self.last_joined_server)
     elif keyword == "restrict_last_joined_channel":
         self.requested = self.last_joined_channel
         msg = self.cfg.get("restrict", "poke")
         if msg: ts3lib.requestClientPoke(schid, self.requested, msg)
         ts3lib.requestClientVariables(schid, self.last_joined_channel)
         # self.restrictClient(schid, self.last_joined_channel)
     elif keyword == "ban_last_joined_server":
         msg = self.cfg.get("ban", "poke")
         if msg:
             ts3lib.requestClientPoke(schid, self.last_joined_server, msg)
         self.banClient(schid, self.last_joined_server)
     elif keyword == "ban_last_joined_channel":
         msg = self.cfg.get("ban", "poke")
         if msg:
             ts3lib.requestClientPoke(schid, self.last_joined_channel, msg)
         self.banClient(schid, self.last_joined_channel)
     elif keyword == "revoke_last_talk_power_channel":
         self.revokeTalkPower(schid, self.last_talk_power)
     elif keyword == "restrict_last_joined_channel_from_local_channels":
         self.restrictForeigners(schid, self.last_joined_channel)
     elif keyword == "last_joined_channel_to_customBan":
         self.toCustomBan(schid, self.last_joined_channel)
     elif keyword == "last_joined_server_to_customBan":
         self.toCustomBan(schid, self.last_joined_server)
Exemplo n.º 5
0
 def onComplainListEvent(self, schid, targetClientDatabaseID,
                         targetClientNickName, fromClientDatabaseID,
                         fromClientNickName, complainReason, timestamp):
     if not schid in self.waitingForList and not schid in self.servers:
         return
     if not self.timer.isActive() and len(self.servers) == 1:
         self.timer.start(self.interval)
     if not schid in self.servers: self.servers[schid] = []
     complaint = (targetClientDatabaseID, fromClientDatabaseID)
     if not complaint in self.servers[schid]:
         self.servers[schid].append(complaint)
         (err, ownID) = ts3lib.getClientID(schid)
         ts3lib.requestClientPoke(
             schid, ownID, 'New complaint for "{}" by "{}"'.format(
                 targetClientNickName, fromClientNickName)
         )  # clientURL(schid, nickname=targetClientNickName), clientURL(schid, nickname=fromClientNickName)
Exemplo n.º 6
0
 def onHotkeyOrCommandEvent(self, keyword, schid=0):
     if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID()
     if keyword == "restrict_last_joined_server":
         self.requested = self.last_joined_server
         msg = self.cfg.get("restrict", "poke")
         if msg: ts3lib.requestClientPoke(schid, self.requested, msg)
         ts3lib.requestClientVariables(schid, self.last_joined_server)
         # self.restrictClient(schid, self.last_joined_server)
     elif keyword == "restrict_last_joined_channel":
         self.requested = self.last_joined_channel
         msg = self.cfg.get("restrict", "poke")
         if msg: ts3lib.requestClientPoke(schid, self.requested, msg)
         ts3lib.requestClientVariables(schid, self.last_joined_channel)
         # self.restrictClient(schid, self.last_joined_channel)
     elif keyword == "ban_last_joined_server":
         msg = self.cfg.get("ban", "poke")
         if msg:
             ts3lib.requestClientPoke(schid, self.last_joined_server, msg)
         self.banClient(schid, self.last_joined_server)
     elif keyword == "ban_last_joined_channel":
         msg = self.cfg.get("ban", "poke")
         if msg:
             ts3lib.requestClientPoke(schid, self.last_joined_channel, msg)
         self.banClient(schid, self.last_joined_channel)
     elif keyword == "revoke_last_talk_power_channel":
         self.revokeTalkPower(schid, self.last_talk_power)
     elif keyword == "restrict_last_joined_channel_from_local_channels":
         self.restrictForeigners(schid, self.last_joined_channel)
     elif keyword == "last_joined_channel_to_customBan":
         self.toCustomBan(schid, self.last_joined_channel)
     elif keyword == "last_joined_server_to_customBan":
         self.toCustomBan(schid, self.last_joined_server)
     elif keyword == "join_selected_channel_pw":
         window = self.app.activeWindow()
         if window is None or not window.className() == "MainWindow": return
         selected = widget("ServerTreeView", self.app).currentIndex()
         if not selected: return
         name = selected.data()
         item = getIDByName(name, schid)
         if item[1] != ServerTreeItemType.CHANNEL: return
         (err, clid) = ts3lib.getClientID(schid)
         (err, cid) = ts3lib.getChannelOfClient(schid, clid)
         if cid == item[0]: return
         pw = getChannelPassword(schid, item[0], calculate=True)
         if not pw: return
         # ts3lib.printMessageToCurrentTab("{} > Joining {} (pw: {})".format(self.name, name, pw))
         ts3lib.requestClientMove(schid, clid, item[0], pw)
     elif keyword == "rejoin_last_channel_pw":
         (err, clid) = ts3lib.getClientID(schid)
         (err, cid) = ts3lib.getChannelOfClient(schid, clid)
         tcid = self.lastchans[schid]
         if cid == tcid: return
         pw = getChannelPassword(schid, tcid, calculate=True)
         # (err, name) = ts3lib.getChannelVariable(schid, tcid, ts3defines.ChannelProperties.CHANNEL_NAME)
         # ts3lib.printMessageToCurrentTab("{} > Rejoining {} (pw: {})".format(self.name, name, pw))
         ts3lib.requestClientMove(schid, clid, tcid, pw if pw else "123")
Exemplo n.º 7
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))
Exemplo n.º 8
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)
Exemplo n.º 9
0
 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(
             "------------------------------------------------")
Exemplo 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)
Exemplo n.º 11
0
 def onHotkeyOrCommandEvent(self, keyword, schid=0):
     try:
         if not schid: schid = ts3lib.getCurrentServerConnectionHandlerID()
         if keyword == "test":
             msg = [
                 "moveBeforeBan", self.moveBeforeBan, "sgids", self.sgids,
                 "lastchans", self.lastchans, "last_joined_server",
                 self.last_joined_server, "last_joined_channel",
                 self.last_joined_channel, "last_talk_power",
                 self.last_talk_power, "requested", self.requested,
                 "requestedIP", self.requestedIP, "retcode", self.retcode
             ]
             print(msg)
             ts3lib.printMessageToCurrentTab(' '.join(str(x) for x in msg))
         elif keyword == "restrict_last_joined_server":
             self.requested = self.last_joined_server
             msg = self.cfg.get("restrict", "poke")
             if msg: ts3lib.requestClientPoke(schid, self.requested, msg)
             ts3lib.requestClientVariables(schid, self.last_joined_server)
             # self.restrictClient(schid, self.last_joined_server)
         elif keyword == "restrict_last_joined_channel":
             self.requested = self.last_joined_channel
             msg = self.cfg.get("restrict", "poke")
             if msg: ts3lib.requestClientPoke(schid, self.requested, msg)
             ts3lib.requestClientVariables(schid, self.last_joined_channel)
             # self.restrictClient(schid, self.last_joined_channel)
         elif keyword == "ban_last_joined_server":
             msg = self.cfg.get("ban", "poke")
             if msg:
                 ts3lib.requestClientPoke(schid, self.last_joined_server,
                                          msg)
             self.banClient(schid, self.last_joined_server)
         elif keyword == "ban_last_joined_channel":
             msg = self.cfg.get("ban", "poke")
             if msg:
                 ts3lib.requestClientPoke(schid, self.last_joined_channel,
                                          msg)
             self.banClient(schid, self.last_joined_channel)
         elif keyword == "revoke_last_talk_power_channel":
             self.revokeTalkPower(schid, self.last_talk_power)
         elif keyword == "restrict_last_joined_channel_from_local_channels":
             self.restrictForeigners(schid, self.last_joined_channel)
         elif keyword == "last_joined_channel_to_customBan":
             self.toCustomBan(schid, self.last_joined_channel)
         elif keyword == "last_joined_server_to_customBan":
             self.toCustomBan(schid, self.last_joined_server)
         elif keyword == "selected_to_customBan":
             window = self.app.activeWindow()
             if window is None or not window.className() == "MainWindow":
                 return
             selected = widget("ServerTreeView", self.app).currentIndex()
             if not selected: return
             name = selected.data()
             item = getIDByName(name, schid)
             if item[1] != ServerTreeItemType.CLIENT:
                 ts3lib.playWaveFile(schid,
                                     path.join(self.path, "error.wav"))
                 ts3lib.printMessageToCurrentTab(
                     "{}: [color=red]No client with name[/color] {} [color=red]found![/color]"
                     .format(self.name, name))
                 return
             self.toCustomBan(schid, item[0])
         elif keyword == "join_selected_channel_pw":
             window = self.app.activeWindow()
             if window is None or not window.className() == "MainWindow":
                 return
             selected = widget("ServerTreeView", self.app).currentIndex()
             if not selected: return
             name = selected.data()
             item = getIDByName(name, schid)
             if item[1] != ServerTreeItemType.CHANNEL: return
             (err, clid) = ts3lib.getClientID(schid)
             (err, cid) = ts3lib.getChannelOfClient(schid, clid)
             if cid == item[0]: return
             pw = getChannelPassword(schid, item[0], calculate=True)
             if not pw: return
             # ts3lib.printMessageToCurrentTab("{} > Joining {} (pw: {})".format(self.name, name, pw))
             ts3lib.requestClientMove(schid, clid, item[0], pw)
         elif keyword == "rejoin_last_channel_pw":
             (err, clid) = ts3lib.getClientID(schid)
             (err, cid) = ts3lib.getChannelOfClient(schid, clid)
             tcid = self.lastchans[schid]
             if cid == tcid: return
             pw = getChannelPassword(schid, tcid, calculate=True)
             # (err, name) = ts3lib.getChannelVariable(schid, tcid, ts3defines.ChannelProperties.CHANNEL_NAME)
             # ts3lib.printMessageToCurrentTab("{} > Rejoining {} (pw: {})".format(self.name, name, pw))
             ts3lib.requestClientMove(schid, clid, tcid,
                                      pw if pw else "123")
     except:
         print("error")
         ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                           "pyTSon", 0)
     return True
Exemplo n.º 12
0
 def poke(self, msg):
     err = ts3lib.requestClientPoke(self.schid, self.clientID, msg)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error muting client: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
Exemplo n.º 13
0
 def onClientMoveEvent(self, serverConnectionHandlerID, clientID,
                       oldChannelID, newChannelID, visibility, moveMessage):
     # when client joins server
     if oldChannelID == 0:
         (err_name, name) = ts3lib.getClientVariableAsString(
             serverConnectionHandlerID, clientID,
             ts3defines.ClientProperties.CLIENT_NICKNAME)
         (err_desc, desc) = ts3lib.getClientVariableAsString(
             serverConnectionHandlerID, clientID,
             ts3defines.ClientPropertiesRare.CLIENT_DESCRIPTION)
         if err_name != ts3defines.ERROR_ok:
             log.error("{} - Error while obtaining client nickname".format(
                 time.ctime(time.time())))
         elif err_desc != ts3defines.ERROR_ok:
             log.error(
                 "{} - Error while obtaining client description".format(
                     time.ctime(time.time())))
         else:
             log.info(
                 "{} - New client joining server. Nickname {}, desc: {}".
                 format(time.ctime(time.time()), name, desc))
             # if nickname == desc
             if name == desc:
                 log.info("{} - Client OK. Nickname: {}".format(
                     time.ctime(time.time()), name))
             # if desc not set
             elif desc == "":
                 err_poke = ts3lib.requestClientPoke(
                     serverConnectionHandlerID, clientID,
                     "Your description is empty. Ask server admin to set it"
                 )
                 log.warning(
                     "{} - Client without description. Nickname: {}".format(
                         time.ctime(time.time()), name))
             # if nickname/desc mismatch
             elif name != desc:
                 err_kick = ts3lib.requestClientKickFromServer(
                     serverConnectionHandlerID, clientID,
                     "Set your nickname as follows: %s" % desc)
                 log.warning(
                     "{} - Nick/desc mismatch - kicking client. Nickname: {}, description: {}"
                     .format(time.ctime(time.time()), name, desc))
     # on client changing channel
     elif newChannelID != 0:
         (err_name, name) = ts3lib.getClientVariableAsString(
             serverConnectionHandlerID, clientID,
             ts3defines.ClientProperties.CLIENT_NICKNAME)
         (err_desc, desc) = ts3lib.getClientVariableAsString(
             serverConnectionHandlerID, clientID,
             ts3defines.ClientPropertiesRare.CLIENT_DESCRIPTION)
         if err_name != ts3defines.ERROR_ok:
             log.error("{} - Error while obtaining client nickname".format(
                 time.ctime(time.time())))
         elif err_desc != ts3defines.ERROR_ok:
             log.error(
                 "{} - Error while obtaining client description".format(
                     time.ctime(time.time())))
         else:
             # if desc not set
             if desc == "":
                 message = "Your description is empty. Ask server admin to set it"
                 ts3lib.requestSendPrivateTextMsg(serverConnectionHandlerID,
                                                  message, clientID)
                 log.warning(
                     "{} - Client without description. Nickname: {}".format(
                         time.ctime(time.time()), name))
             # if nickname/desc mismatch
             elif name != desc:
                 err_kick = ts3lib.requestClientKickFromServer(
                     serverConnectionHandlerID, clientID,
                     "Set your nickname as follows: %s" % desc)
                 log.warning(
                     "{} - Nick/desc mismatch - kicking client. Nickname: {}, description: {}"
                     .format(time.ctime(time.time()), name, desc))