Пример #1
0
 def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID,
                       visibility, moveMessage):
     if not self.askForAvatar: return
     (err, suid) = ts3lib.getServerVariable(
         schid,
         ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     if suid != self.suid: return
     if oldChannelID != 0: return
     (err, uid) = ts3lib.getClientVariable(
         schid, clientID,
         ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     if getContactStatus(uid) == ContactStatus.BLOCKED: return
     if uid in self.alreadyAsked: return
     (err, sgroups) = ts3lib.getClientVariableAsString(
         schid, clientID,
         ts3defines.ClientPropertiesRare.CLIENT_SERVERGROUPS)
     sgroups = sgroups.split(",")
     if self.ruheGroupID in sgroups: return
     if set(sgroups).isdisjoint(self.premiumGroupIDs): return
     (err, myuid) = ts3lib.getClientSelfVariable(
         schid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     (err, nick) = ts3lib.getClientVariable(
         schid, clientID, ts3defines.ClientProperties.CLIENT_NICKNAME)
     ts3lib.requestSendPrivateTextMsg(
         schid,
         self.avatarmsg.replace("{nick}",
                                nick).replace("{myuid}",
                                              myuid).replace("{uid}", uid),
         clientID)
     self.alreadyAsked.append(uid)
Пример #2
0
 def tick(self):
     for schid in self.servers:
         if self.hook: sendCommand(self.name, "clientupdate", schid)
         else:
             self.retcode = ts3lib.createReturnCode()
             ts3lib.requestSendPrivateTextMsg(schid, self.text, self.servers[schid]["clid"], self.retcode)
         self.timer.setInterval(self.getInterval())
Пример #3
0
    def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName, fromUniqueIdentifier, message, ffIgnored):
        try:
            mClientID = ts3.getClientID(schid)[1]
            if (mClientID == fromID):
                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

            if (targetMode == 1): #private msg
                ts3.requestSendPrivateTextMsg(schid, msg, fromID, "")
            if (targetMode == 2): #channel msg
                ts3.requestSendChannelTextMsg(schid, msg, 0, "")
        except:
            from traceback import format_exc;ts3.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
Пример #4
0
 def doBet(self):
     ts3lib.requestSendPrivateTextMsg(self.schid,
                                      "!pay {}".format(self.bet),
                                      self.botCLID)
     ts3lib.requestSendPrivateTextMsg(
         self.schid, "!set {0}".format(randint(self.minRand, self.maxRand)),
         self.botCLID)
Пример #5
0
 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 onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if menuItemID != 0: return
     if atype == ts3defines.PluginItemType.PLUGIN_CHANNEL:
         ts3lib.requestSendChannelTextMsg(schid, self.steammsg,
                                          selectedItemID)
     elif atype == ts3defines.PluginItemType.PLUGIN_CLIENT:
         ts3lib.requestSendPrivateTextMsg(schid, self.steammsg,
                                          selectedItemID)
Пример #7
0
 def tick(self):
     if not self.askForAvatar or not self.schid or len(self.clids) < 1: self.timer.stop(); return
     (err, myuid) = ts3lib.getClientSelfVariable(self.schid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     (err, uid) = ts3lib.getClientVariable(self.schid, self.clids[0], ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     (err, nick) = ts3lib.getClientVariable(self.schid, self.clids[0], ts3defines.ClientProperties.CLIENT_NICKNAME)
     ts3lib.requestSendPrivateTextMsg(self.schid, self.avatarmsg.replace("{nick}", nick).replace("{myuid}", myuid).replace("{uid}", uid), self.clids[0])
     self.alreadyAsked.append(uid)
     del self.clids[0]
Пример #8
0
 def answerMessage(self, schid, targetMode, toID, fromID, message, hideprefix=False):
     if schid in self.noperms: ts3lib.printMessageToCurrentTab("Insufficient permissions to answer message from {0}".format(fromID)); return
     message = [message[i:i + 1024] for i in range(0, len(message), 1024)]
     if targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT:
         for msg in message: self.returnCode = ts3lib.createReturnCode(); ts3lib.requestSendPrivateTextMsg(schid, msg, fromID, self.returnCode)
     elif targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL:
         if hideprefix:
             for msg in message: self.returnCode = ts3lib.createReturnCode(); ts3lib.requestSendChannelTextMsg(schid, "{0}".format(msg), toID, self.returnCode)
         else:
             for msg in message: self.returnCode = ts3lib.createReturnCode(); ts3lib.requestSendChannelTextMsg(schid, "[url=client://]@[/url]%s: %s" % ( self.clientURL(schid, fromID), msg), toID, self.returnCode)
Пример #9
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if menuItemID != 0: return
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
         self.printContacts()
     elif atype == ts3defines.PluginItemType.PLUGIN_CHANNEL:
         ts3lib.requestSendChannelTextMsg(schid, self.contactStats(),
                                          selectedItemID)
     elif atype == ts3defines.PluginItemType.PLUGIN_CLIENT:
         ts3lib.requestSendPrivateTextMsg(schid, self.contactStats(),
                                          selectedItemID)
Пример #10
0
 def tick(self):
     for schid in self.servers:
         if self.hook: sendCommand(self.name, "clientupdate", schid)
         else:
             self.retcode = ts3lib.createReturnCode()
             ts3lib.requestSendPrivateTextMsg(schid, self.text,
                                              self.servers[schid]["clid"],
                                              self.retcode)
         interval = self.getInterval()
         # print(self.name, ">", "Sent", self.text, "for schid", schid, "to clid", self.servers[schid]["clid"], "| new interval:", interval)
         self.timer.setInterval(interval)
Пример #11
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
         if menuItemID == 0: self.printContacts()
         elif menuItemID == 1:
             ts3lib.printMessageToCurrentTab("{}{}".format(
                 timestamp(), self.onlineContacts(schid, False)))
     elif atype == ts3defines.PluginItemType.PLUGIN_CHANNEL:
         ts3lib.requestSendChannelTextMsg(schid, self.contactStats(),
                                          selectedItemID)
     elif atype == ts3defines.PluginItemType.PLUGIN_CLIENT:
         ts3lib.requestSendPrivateTextMsg(schid, self.contactStats(),
                                          selectedItemID)
Пример #12
0
 def onClientMoveMovedEvent(self, serverConnectionHandlerID, clientID, oldChannelID, newChannelID, visibility, moverID, moverName, moverUniqueIdentifier, moveMessage):
     try:
         if self.cfg['antimove']['enabled'] != 'False' and self.antiMoveStatus != False:
             if serverConnectionHandlerID != 0:
                 mClientID = ts3lib.getClientID(serverConnectionHandlerID)
                 if mClientID[1] == clientID:
                     self.TryJoinChannel(serverConnectionHandlerID, clientID, oldChannelID)
                     self.backup(serverConnectionHandlerID)
                     ts3lib.playWaveFile(serverConnectionHandlerID, path.join(self.soundPath, "noice.wav"))
                     if self.cfg['antimove']['message'] == 'True': 
                         message = 'Stop it ' + moverName + '!'
                         ts3lib.requestSendPrivateTextMsg(serverConnectionHandlerID, message, moverID) 
     except: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "PyTSon", 0)
Пример #13
0
 def onIncomingClientQueryEvent(self, schid, commandText):
     if not self.dynamicSilence: return
     (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     if suid != self.suid: return
     if commandText.split(" ", 1)[0] != "notifyclientupdated": return
     cmd, params = parseCommand(commandText)
     if len(params) > 0 and "client_nickname" in params:
         clid = int(params["clid"])
         # (err, ownID) = ts3lib.getClientID(schid)
         # if clid == ownID: return
         (err, uid) = ts3lib.getClientVariable(schid, clid, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
         if getContactStatus(uid) != ContactStatus.FRIEND: return
         if not self.dynamicSilenceName in params["client_nickname"].lower(): return
         ts3lib.requestSendPrivateTextMsg(schid, "Yes, {}-{}?".format(clientURL(schid, clid), choice(["chan","san"])), clid)
Пример #14
0
 def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID,
                       visibility, moveMessage):
     (err, ownID) = ts3lib.getClientID(schid)
     if clientID != ownID: return
     (err, needed_tp) = ts3lib.getChannelVariable(
         schid, newChannelID,
         ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER)
     if needed_tp >= 0:
         # (err, hasTP) = ts3lib.getClientSelfVariable(schid, ts3defines.ClientPropertiesRare.CLIENT_IS_TALKER)
         (err, ownTP) = ts3lib.getClientSelfVariable(
             schid, ts3defines.ClientPropertiesRare.CLIENT_TALK_POWER)
         if int(ownTP) < needed_tp:
             ts3lib.requestSendPrivateTextMsg(
                 schid, self.text, self.servers[schid]["clid"],
                 self.retcode)  # ts3lib.requestIsTalker(schid, True, "")
Пример #15
0
 def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID,
                       visibility, moveMessage):
     if not self.enabled: return
     try:
         (error, _clid) = ts3lib.getClientID(schid)
         if not clientID == _clid and oldChannelID == 0:
             (error, uid) = ts3lib.getClientVariableAsString(
                 schid, clientID,
                 ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
             if uid in self.uids:
                 ts3lib.requestSendPrivateTextMsg(schid, self.msg, clientID)
     except:
         from traceback import format_exc
         ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR,
                           "PyTSon", 0)
Пример #16
0
 def onClientChannelGroupChangedEvent(self, schid, channelGroupID,
                                      channelID, clientID, invokerClientID,
                                      invokerName, invokerUniqueIdentity):
     (err, suid) = ts3lib.getServerVariable(
         schid,
         ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     # if self.debug: ts3lib.printMessageToCurrentTab('suid != self.suid: {}'.format(suid != self.suid))
     if suid != self.suid: return
     (err, ownID) = ts3lib.getClientID(schid)
     # if self.debug: ts3lib.printMessageToCurrentTab('clientID != ownID: {}'.format(clientID != ownID))
     if clientID != ownID: return
     # if self.debug: ts3lib.printMessageToCurrentTab('channelGroupID != self.channelAdminGroupID: {}'.format(channelGroupID != self.channelAdminGroupID))
     if channelGroupID != self.channelAdminGroupID: return
     # if self.debug: ts3lib.printMessageToCurrentTab('invokerClientID != 0: {}'.format(invokerClientID != 0))
     if invokerClientID == 0:
         (err, ntp) = ts3lib.getChannelVariable(
             schid, channelID,
             ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER)
         if not ntp or ntp == 0:
             ts3lib.setChannelVariableAsInt(
                 schid, channelID,
                 ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER,
                 self.settings["tp"])
         # (err, cmc) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS)
         ts3lib.setChannelVariableAsInt(
             schid, channelID, ts3defines.ChannelPropertiesRare.
             CHANNEL_FLAG_MAXCLIENTS_UNLIMITED, 0)
         ts3lib.setChannelVariableAsInt(
             schid, channelID,
             ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS,
             self.settings["maxclients"])
         (err, cnp) = ts3lib.getChannelVariable(
             schid, channelID,
             ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC)
         if not cnp or cnp == "":
             ts3lib.setChannelVariableAsString(
                 schid, channelID,
                 ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC,
                 "Team | Lounge 1")
         ts3lib.flushChannelUpdates(schid, channelID)
     return
     # clid = ts3lib.getClientIDbyNickname(schid, self.gommeBotNick)
     # if not clid: ts3lib.printMessage(schid, 'Gomme-Bot not found.', ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
     # (err, uid) = ts3lib.getClientVariable(schid, self.gommeBotID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     # if uid != "serveradmin": return
     # if self.debug: ts3lib.printMessageToCurrentTab('self.gommeBotID == 0: {}'.format(self.gommeBotID == 0))
     if self.gommeBotID == 0: return
     ts3lib.requestSendPrivateTextMsg(schid, "registriert", self.gommeBotID)
Пример #17
0
 def onClientChannelGroupChangedEvent(self, schid, channelGroupID, channelID, clientID, invokerClientID, invokerName, invokerUniqueIdentity):
     (err, suid) = ts3lib.getServerVariable(schid, ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     if suid != self.suid: return
     (err, ownID) = ts3lib.getClientID(schid)
     if clientID != ownID: return
     if channelGroupID != self.channelAdminGroupID: return
     if invokerClientID == 0:
         (err, ntp) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER)
         if not ntp or ntp == 0: ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NEEDED_TALK_POWER, self.settings["tp"])
         ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_FLAG_MAXCLIENTS_UNLIMITED, 0)
         ts3lib.setChannelVariableAsInt(schid, channelID, ts3defines.ChannelProperties.CHANNEL_MAXCLIENTS, self.settings["maxclients"])
         (err, cnp) = ts3lib.getChannelVariable(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC)
         if not cnp or cnp == "": ts3lib.setChannelVariableAsString(schid, channelID, ts3defines.ChannelPropertiesRare.CHANNEL_NAME_PHONETIC, "Team | Lounge 1")
         ts3lib.flushChannelUpdates(schid, channelID)
     if self.gommeBotID < 1: return
     ts3lib.requestSendPrivateTextMsg(schid, "registriert", self.gommeBotID)
Пример #18
0
 def onClientDisplayNameChanged(self, serverConnectionHandlerID, clientID,
                                displayName, uniqueClientIdentifier):
     name = displayName
     (err_desc, desc) = ts3lib.getClientVariableAsString(
         serverConnectionHandlerID, clientID,
         ts3defines.ClientPropertiesRare.CLIENT_DESCRIPTION)
     if err_desc != ts3defines.ERROR_ok:
         log.error("{} - Error while obtaining client description".format(
             time.ctime(time.time())))
     else:
         log.info(
             "{} - Nickname change detected. New 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 == "":
             message = "Your description is empty. Ask server admin to set it"
             err_msg = ts3lib.requestSendPrivateTextMsg(
                 serverConnectionHandlerID, message, clientID)
             log.warning(
                 "{} - Client without description. Nickname: {}".format(
                     time.ctime(time.time()), name))
         # if name/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))
Пример #19
0
def sendCommand(name, cmd, schid=0, silent=True, reverse=False, mode=1):
    """
    Sends a command through TS3Hook.
    :param mode: See enum: HookMode
    :param reverse:
    :param name:
    :param cmd:
    :param schid:
    :param silent:
    """
    if schid == 0: schid = ts3lib.getCurrentServerConnectionHandlerID()
    if PluginHost.cfg.getboolean("general", "verbose") or not silent:
        ts3lib.printMessage(
            schid,
            '{timestamp} [color=orange]{name}[/color]:[color=white] {prefix}{message}'
            .format(timestamp=timestamp(),
                    name=name,
                    prefix="-" if reverse else "~",
                    message=cmd),
            ts3defines.PluginMessageTarget.PLUGIN_MESSAGE_TARGET_SERVER)
    print("mode:", mode)
    if mode == HookMode.TS3HOOK:
        cmd = "{}cmd{}".format("-" if reverse else "~", cmd.replace(" ", "~s"))
    elif mode == HookMode.TSPATCH:
        cmd = "{}{}".format("-" if reverse else "~", cmd)
    else:
        raise SyntaxError("No HookMode specified!")
    (err, clid) = ts3lib.getClientID(schid)
    retcode = ""  # "TS3Hook:Command:{}".format(ts3lib.createReturnCode(256))
    err = ts3lib.requestSendPrivateTextMsg(schid, cmd, clid, retcode)
    if err != ts3defines.ERROR_ok:
        ts3lib.requestSendChannelTextMsg(schid, cmd, 0, retcode)
    if err != ts3defines.ERROR_ok:
        ts3lib.requestSendServerTextMsg(schid, cmd, retcode)
Пример #20
0
 def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName,
                        fromUniqueIdentifier, message, ffIgnored):
     if fromUniqueIdentifier != "serveradmin": return
     if fromName != self.gommeBotNick: return
     print(message, self.agreeMSG, message == self.agreeMSG)
     self.schid = schid
     self.gommeBotID = fromID
     if message.endswith(self.msg):
         QTimer.singleShot(self.delay, self.sendMessage)
     elif message == self.blockMSG:
         QTimer.singleShot(self.delay, self.sendMessage)
     elif message == self.agreeMSG:
         ts3lib.requestSendPrivateTextMsg(self.schid, "agree",
                                          self.gommeBotID)
         return True
     elif message in self.ignoreMSG:
         return True
    def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName,
                           fromUniqueIdentifier, message, ffIgnored):
        (err, myid) = ts3lib.getClientID(schid)

        if err == ts3defines.ERROR_ok:
            #only in private messages
            if toID == myid:
                f = self.contactStatus(fromUniqueIdentifier)
                if f == 0:
                    err = ts3lib.requestSendPrivateTextMsg(
                        schid, "Hello, my friend!", fromID)
                elif f == 1:
                    err = ts3lib.requestSendPrivateTextMsg(
                        schid, "I don't like you!", fromID)
                else:
                    err = ts3lib.requestSendPrivateTextMsg(
                        schid, "Do I know you?", fromID)
Пример #22
0
 def onNetworkReply(self, reply):
     if reply.error() == QNetworkReply.NoError:
         try:
             message = str(
                 json.loads(reply.readAll().data().decode('utf-8')))
             if self.mode:
                 if self.target == 1:
                     ts3.requestSendPrivateTextMsg(self.schid, message,
                                                   self.fromID)
                 if self.target == 2:
                     (error,
                      mych) = ts3.getChannelOfClient(self.schid, self.myid)
                     ts3.requestSendChannelTextMsg(self.schid, message,
                                                   mych)
             else:
                 ts3.printMessageToCurrentTab(str(message))
         except:
             ts3.printMessageToCurrentTab(format_exc())
Пример #23
0
    def doContactActions(self, schid, clientID):    
        # Own client ID and own channel
        (error, myid) = ts3.getClientID(schid)
        (error, mych) = ts3.getChannelOfClient(schid, myid)
        (error, cch) = ts3.getChannelOfClient(schid, clientID)
        (error, isDefaultChannel) = ts3.getChannelVariableAsInt(schid, mych, ts3defines.ChannelProperties.CHANNEL_FLAG_DEFAULT)

        # Only react if client joins my channel and at least one setting is activated
        if not isDefaultChannel == 1 and cch == mych and not myid == clientID and (self.settings["f_channelgroup"] or self.settings["f_talkpower"] or self.settings["b_channelgroup"] or self.settings["b_kick"]):
            
            # Contact status check
            (error, cuid) = ts3.getClientVariableAsString(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
            status = self.contactStatus(cuid)

            # Only react if friend or blocked joined the channel
            if status == 0 or status == 1:            
                # blocked
                if status == 1: 
                    # Assign blocked channelgroup
                    if self.settings["b_channelgroup"]:
                        channelgroup = self.setClientChannelGroup(schid, 1, clientID, mych)
                    # kick blocked
                    if self.settings["b_kick"]:
                        ts3.requestClientKickFromChannel(schid, clientID, self.settings["b_kick_message"], self.error_kickFromChannel)
                    
                    (error, new_cch) = ts3.getChannelOfClient(schid, clientID)
                    # Send message to blocked user if kick was valid
                    if not new_cch == mych and self.settings["b_message"]:
                        ts3.requestSendPrivateTextMsg(schid, self.settings["b_message_message"], clientID, self.error_sendMessage)

                # freinds
                if status == 0:  
                    # Assign friends channelgroup
                    if self.settings["f_channelgroup"]:
                        self.setClientChannelGroup(schid, 0, clientID, mych)
                    # Grant friends talkpower
                    if self.settings["f_talkpower"]:
                        ts3.requestClientSetIsTalker(schid, clientID, True, self.error_setClientTalkpower)
                    # Send message to friends                 
                    if self.settings["f_message"]:
                        ts3.requestSendPrivateTextMsg(schid, self.settings["f_message_message"], clientID, self.error_sendMessage)
Пример #24
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))
Пример #25
0
 def sendMessage(self, schid, targetMode, toID):
     x = QWidget()
     clipboard = QApplication.clipboard().text();
     _message = QInputDialog.getMultiLineText(x, "Enter long text here", "", clipboard)
     message = [_message[i:i + self.maxsize] for i in range(0, len(_message), self.maxsize)]
     if targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CHANNEL:
         for msg in message:
             error = ts3lib.requestSendChannelTextMsg(schid, "\n"+msg, toID)
             if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return
     elif targetMode == ts3defines.TextMessageTargetMode.TextMessageTarget_CLIENT:
         for msg in message:
             error = ts3lib.requestSendPrivateTextMsg(schid, "\n"+msg, toID)
             if not error == ts3defines.ERROR_ok: _t = QMessageBox(QMessageBox.Critical, "Error #%s"%error,"Unable to send message to #%s!"%toID);_t.show();return
Пример #26
0
def answerMessage(schid: int,
                  targetMode: int,
                  fromID: int,
                  message: str,
                  returnCode: str = "",
                  prefix: bool = True):
    mode = TextMessageTargetMode
    if prefix and targetMode == mode.TextMessageTarget_CHANNEL:
        message = "{}: {}".format(
            clientURL(schid, fromID, quote=False, mention=True), message)
    print(message)
    message = [message[i:i + 900] for i in range(0, len(message), 900)]
    if targetMode == mode.TextMessageTarget_SERVER:
        for msg in message:
            ts3lib.requestSendServerTextMsg(schid, msg, returnCode)
    elif targetMode == mode.TextMessageTarget_CHANNEL:
        for msg in message:
            ts3lib.requestSendChannelTextMsg(schid, msg, 0, returnCode)
    elif targetMode == mode.TextMessageTarget_CLIENT:
        for msg in message:
            ts3lib.requestSendPrivateTextMsg(schid, msg, fromID, returnCode)
    else:
        ts3lib.printMessageToCurrentTab("".join(message))
Пример #27
0
def send(userid, message=None):

    if not userid:
        useid, err = me()
        if err:
            return err

    if type(userid) is tuple:
        if userid[1]:
            return userid[1]

        userid = userid[0]

    if not message:
        return 'no message'

    return ts3lib.requestSendPrivateTextMsg(schid(), message, userid)
Пример #28
0
    def onTextMessageEvent(self, schid, targetMode, toID, fromID, fromName,
                           fromUID, message, ffIgnored):
        (err, myid) = ts3lib.getClientID(schid)
        if err != ERROR_ok or fromID == myid:
            return False

        #only private msgs
        if targetMode != TextMessageTargetMode.TextMessageTarget_CLIENT:
            return False

        #only, if I'm away
        (err, away) = ts3lib.getClientSelfVariableAsInt(
            schid, ClientPropertiesRare.CLIENT_AWAY)
        if err != ERROR_ok or not away:
            return False

        #only to friends? is from friend?
        if self.cfg['general']['onlyfriends'] == "True" and not isFriend(
                fromUID):
            return False

        #only once per conversation? did we already sent him?
        if self.cfg['general']['onlyonce'] == "True" and (
                schid, fromUID) in self.handled:
            return False

        if self.cfg['general']['sendaway'] == "True":
            (err, msg) = ts3lib.getClientSelfVariableAsString(
                schid, ClientPropertiesRare.CLIENT_AWAY_MESSAGE)
        else:
            msg = self.cfg['general']['custommsg']

        if msg == "":
            return False

        err = ts3lib.requestSendPrivateTextMsg(schid, msg, fromID)
        if err == ERROR_ok:
            self.handled.append((schid, fromUID))
Пример #29
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))
Пример #30
0
 def sendBanList(self):
     ts3lib.requestSendPrivateTextMsg(self.cmdevent.schid, "%s" % self.banlist, self.cmdevent.fromID)
     self.answerMessage(self.cmdevent.schid, self.cmdevent.targetMode, self.cmdevent.toID, self.cmdevent.fromID, "%s" % self.banlist)
     self.cmdevent = {"event": "", "returnCode": "", "schid": 0, "targetMode": 4, "toID": 0, "fromID": 0, "params": ""}