Пример #1
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)
Пример #2
0
 def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID,
                       visibility, moveMessage):
     if self.debug:
         ts3lib.printMessageToCurrentTab(
             "oldChannelID: {0}".format(oldChannelID))
     if not oldChannelID == 0: return
     (error, _clid) = ts3lib.getClientID(schid)
     if self.debug:
         ts3lib.printMessageToCurrentTab(
             "_clid: {0} | clientID: {1}".format(_clid, clientID))
     if clientID == _clid: return
     if self.debug:
         ts3lib.printMessageToCurrentTab(
             "newChannelID: {0} | self.default: {1}".format(
                 newChannelID, self.default))
     if not newChannelID == self.default: return
     #(error, uid) = ts3lib.getClientVariableAsString(schid, clientID, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
     #if self.debug: ts3lib.printMessageToCurrentTab("uid: {0} | self.tmp: {1}".format(uid,self.tmp))
     #if uid in self.tmp: return
     (error, suid) = ts3lib.getServerVariableAsString(
         schid,
         ts3defines.VirtualServerProperties.VIRTUALSERVER_UNIQUE_IDENTIFIER)
     if self.debug:
         ts3lib.printMessageToCurrentTab(
             "suid: {0} | self.cfg.sections(): {1} | self.cfg.has_section(suid): {2}"
             .format(suid, self.cfg.sections(), self.cfg.has_section(suid)))
     if not self.cfg.has_section(suid): return
     self.update = clientID
     ts3lib.requestClientVariables(schid, clientID)
Пример #3
0
 def onClientMoveEvent(self, schid, clientID, oldChannelID, newChannelID,
                       visibility, moveMessage):
     if not self.toggle: return
     (error, _clid) = ts3.getClientID(schid)
     if clientID != _clid and oldChannelID == 0:
         self.requested = True
         ts3.requestClientVariables(schid, clientID)
Пример #4
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)
Пример #5
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")
Пример #6
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if menuItemID == 0:
         ts3.requestClientVariables(schid, selectedItemID, "")
         shit = "[COLOR=red]"
         shit += ts3.getClientDisplayName(
             schid, selectedItemID)[1] + " (" + str(selectedItemID) + "):\n"
         shit += "Unique ID: " + ts3.getClientVariableAsString(
             schid, selectedItemID,
             ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)[1] + "\n"
         shit += "MetaData: " + ts3.getClientVariableAsString(
             schid, selectedItemID,
             ts3defines.ClientProperties.CLIENT_META_DATA)[1] + "\n"
         shit += "IsTalking: " + ts3.getClientVariableAsString(
             schid, selectedItemID,
             ts3defines.ClientProperties.CLIENT_FLAG_TALKING)[1] + "\n"
         shit += "[/COLOR]"
         ts3.printMessageToCurrentTab(shit)
Пример #7
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
Пример #8
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     if atype != ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CLIENT or menuItemID != 0:
         return
     self.waiting_for = (schid, selectedItemID)
     ts3lib.requestClientVariables(schid, selectedItemID)
Пример #9
0
 def processCommand(self, schid, keyword):
     args = keyword.split()
     cmd = args.pop(0).lower()
     if cmd == "com":
         command = " ".join(args)
         self.retcode = ts3lib.createReturnCode(); self.schid = schid
         err = ts3lib.requestSendClientQueryCommand(schid, command, self.retcode)
         if err != ts3defines.ERROR_ok:
             (_err, msg) = ts3lib.getErrorMessage(err)
             ts3lib.printMessageToCurrentTab("(%s) %s: %s"%(schid, command, msg))
     elif cmd == "req":
         clid = int(args.pop(0))
         self.req = clid
         ts3lib.requestClientVariables(schid, clid)
     elif cmd == "reqcon":
         clid = int(args.pop(0))
         self.req = clid
         ts3lib.requestConnectionInfo(schid, clid)
     elif cmd == "self":
         err, clid = ts3lib.getClientID(schid)
         ts3lib.printMessageToCurrentTab("[b]{}'s Self Variables:".format(clientURL(schid, clid)))
         open(self.filepath, 'w').close()
         min=0;max=64
         if len(args):
             min = int(args.pop(0))
             if len(args): max = int(args.pop(0))
         for i in range(min, max):
             msg = "%s"%i
             values = set(item.value for item in ts3enums.ClientProperties)
             if i in values: msg += " ({})".format(ts3enums.ClientProperties(i))
             msg += ": "
             (err, var) = ts3lib.getClientSelfVariableAsString(schid, i)
             if err != ts3defines.ERROR_ok:
                 (_err, var) = ts3lib.getErrorMessage(err)
             msg += var
             with open(self.filepath, "a", encoding="utf-8") as myfile:
                 myfile.write(msg+"\n")
             ts3lib.printMessageToCurrentTab(msg)
     elif cmd == "client":
         clid = int(args.pop(0))
         ts3lib.printMessageToCurrentTab("[b]{}'s Client Variables:".format(clientURL(schid, clid)))
         open(self.filepath, 'w').close()
         min=0;max=64
         if len(args):
             min = int(args.pop(0))
             if len(args): max = int(args.pop(0))
         for i in range(min, max):
             msg = "%s"%i
             values = set(item.value for item in ts3enums.ClientProperties)
             if i in values: msg += " ({})".format(ts3enums.ClientProperties(i))
             msg += ": "
             (err, var) = ts3lib.getClientVariableAsString(schid, clid, i)
             if err != ts3defines.ERROR_ok:
                 (_err, var) = ts3lib.getErrorMessage(err)
             msg += var
             with open(self.filepath, "a", encoding="utf-8") as myfile:
                 myfile.write(msg+"\n")
             ts3lib.printMessageToCurrentTab(msg)
     elif cmd == "con":
         clid = int(args.pop(0))
         ts3lib.printMessageToCurrentTab("[b]{}'s Connection Variables:".format(clientURL(schid, clid)))
         open(self.filepath, 'w').close()
         min=0;max=65
         if len(args):
             min = int(args.pop(0))
             if len(args): max = int(args.pop(0))
         for i in range(min, max):
             msg = "%s"%i
             values = set(item.value for item in ts3enums.ConnectionProperties)
             if i in values: msg += " ({})".format(ts3enums.ConnectionProperties(i))
             msg += ": "
             (err, var) = ts3lib.getConnectionVariableAsString(schid, clid, i)
             if err != ts3defines.ERROR_ok:
                 (_err, var) = ts3lib.getErrorMessage(err)
             msg += var
             with open(self.filepath, "a", encoding="utf-8") as myfile:
                 myfile.write(msg+"\n")
             ts3lib.printMessageToCurrentTab(msg)
     else: return False
     return True