Example #1
0
 def commandBanMe(self, schid, targetMode, toID, fromID, params=""):
     if self.cfg.getboolean('general', 'customprefix'):
         prefix = self.cfg.get('general', 'prefix')
     else:
         (error, id) = ts3lib.getClientID(schid);prefix = self.clientURL(schid, id)
     (error, nickname) = ts3lib.getClientVariableAsString(schid, fromID, ts3defines.ClientProperties.CLIENT_NICKNAME)
     if params != "": _params = params.split(' ', 1)
     delay = 1;
     delay = _params[0]
     if len(_params) > 1: ts3lib.banclient(schid, fromID, int(delay), _params[1])
     else: ts3lib.banclient(schid, fromID, int(delay), "Command %sbanme used by %s" % (prefix, nickname))
Example #2
0
 def onMenuItemEvent(self, schid, atype, menuItemID, selectedItemID):
     try:
         if atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_GLOBAL:
             if menuItemID == 1: # Message all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msgs = self.getText(multiline=True,title="Message all %s clients on this server"%len(clients),text="Enter Private Message")
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     for msg in msgs: ts3lib.requestSendPrivateTextMsg(schid, msg, c)
             elif menuItemID == 2: # OffineMessage all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 (error, ownID) = ts3lib.getClientID(schid)
                 uids = []
                 for c in clients:
                     if c == ownID: continue
                     (error, uid) = ts3lib.getClientVariableAsString(schid, c, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
                     uids.append(uid)
                 if not self.dlg: self.dlg = MessageDialog(schid, uids)
                 self.dlg.show();self.dlg.raise_();self.dlg.activateWindow()
             elif menuItemID == 3: # Message all Channels
                 (error, channels) = ts3lib.getChannelList(schid)
                 msgs = self.getText(multiline=True,title="Message all %s channels on this server"%len(channels),text="Enter Channel Message")
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in channels:
                     error = ts3lib.requestClientMove(schid, ownID, c, "123")
                     if not error == ts3defines.ERROR_ok: continue
                     for msg in msgs: ts3lib.requestSendChannelTextMsg(schid, msg, c)
             elif menuItemID == 4: # Poke all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msgs = self.getText(title="Poke all %s clients on this server"%len(clients),text="Enter Poke Message",max=100)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     for msg in msgs: ts3lib.requestClientPoke(schid, c, msg)
             elif menuItemID == 5: # ChannelKick all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msg = self.getText(title="Kick all %s clients on this server from their channel"%len(clients),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.requestClientKickFromChannel(schid, c, msg)
             elif menuItemID == 6: # ChannelBan all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msg = self.getText(title="ChannelBan all %s clients on this server"%len(clients),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     (error, chan) = ts3lib.getChannelOfClient(schid, selectedItemID)
                     (error, dbid) = ts3lib.getClientVariableAsUInt64(schid, c, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
                     ts3lib.requestSetClientChannelGroup(schid, [self.sbgroup], [chan], [dbid])
                     ts3lib.requestClientKickFromChannel(schid, c, msg)
             elif menuItemID == 7: # Kick all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msg = self.getText(title="Kick all %s clients from this server"%len(clients),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.requestClientKickFromServer(schid, c, msg)
             elif menuItemID == 8: # Ban all Clients
                 (error, clients) = ts3lib.getClientList(schid)
                 msg = self.getText(title="Ban all %s clients from this server"%len(clients),text="Enter Ban Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.banclient(schid, c, -1, msg)
             elif menuItemID == 9: # Delete all Channels
                 (error, channels) = ts3lib.getChannelList(schid)
                 confirmation = self.confirm('Delete all Channels', 'Do you really want to delete all {0} channels on this server?'.format(len(channels)))
                 if not confirmation: return
                 for c in channels: ts3lib.requestChannelDelete(schid, c, True)
         elif atype == ts3defines.PluginMenuType.PLUGIN_MENU_TYPE_CHANNEL:
             if menuItemID == 1: # Message all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msgs = self.getText(multiline=True,title="Message to all %s clients in channel \"%s\""%(len(clients),name),text="Enter Private Message")
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     for msg in msgs: ts3lib.requestSendPrivateTextMsg(schid, msg, c)
             if menuItemID == 2: # OfflineMessage all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID)
                 (error, ownID) = ts3lib.getClientID(schid)
                 uids = []
                 for c in clients:
                     if c == ownID: continue
                     (error, uid) = ts3lib.getClientVariableAsString(schid, c, ts3defines.ClientProperties.CLIENT_UNIQUE_IDENTIFIER)
                     uids.append(uid)
                 if not self.dlg: self.dlg = MessageDialog(schid, uids)
                 self.dlg.show();self.dlg.raise_();self.dlg.activateWindow()
             elif menuItemID == 3: # Poke all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid, selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msgs = self.getText(title="Poke all %s clients in channel \"%s\""%(len(clients),name),text="Enter Poke Message",max=100)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     for msg in msgs: ts3lib.requestClientPoke(schid, c, msg)
             elif menuItemID == 4: # ChannelKick all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msg = self.getText(title="Kick all %s clients from channel \"%s\""%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.requestClientKickFromChannel(schid, c, msg)
             elif menuItemID == 5: # ChannelBan all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msg = self.getText(title="ChannelBan all %s clients from channel \"%s\""%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     (error, dbid) = ts3lib.getClientVariableAsUInt64(schid, c, ts3defines.ClientPropertiesRare.CLIENT_DATABASE_ID)
                     ts3lib.requestSetClientChannelGroup(schid, [self.sbgroup], [selectedItemID], [dbid])
                     ts3lib.requestClientKickFromChannel(schid, c, msg)
             elif menuItemID == 6: # Kick all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msg = self.getText(title="Kick all %s clients in channel \"%s\" from this server"%(len(clients),name),text="Enter Kick Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.requestClientKickFromServer(schid, c, msg)
             elif menuItemID == 7: # Ban all Clients
                 (error, clients) = ts3lib.getChannelClientList(schid,selectedItemID)
                 (err, name) = ts3lib.getChannelVariableAsString(schid, selectedItemID, ts3defines.ChannelProperties.CHANNEL_NAME)
                 msg = self.getText(title="Ban all %s clients in channel \"%s\""%(len(clients),name),text="Enter Ban Reason",multimsg=False,max=80)
                 if bool(self.ok) != True:return
                 (error, ownID) = ts3lib.getClientID(schid)
                 for c in clients:
                     if c == ownID: continue
                     ts3lib.banclient(schid, c, -1, msg)
     except: from traceback import format_exc;ts3lib.logMessage(format_exc(), ts3defines.LogLevel.LogLevel_ERROR, "pyTSon", 0)
Example #3
0
 def onFallbackReply(self, reply):
     if reply.error() == QNetworkReply.NoError:
         try:
             isp = reply.readAll().data().decode('utf-8')
             if isp.startswith('AS'): isp = isp.split(" ", 1)[1]
             if not isp or isp == "" or isp == "undefined":
                 ts3.printMessageToCurrentTab(
                     "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the ISP for '%s' (Reason: %s)"
                     % (self.clientURL(self.schid,
                                       self.requested), format_exc()))
                 if self.cfg.getboolean("failover", "enabled"):
                     if self.cfg.getboolean('failover', 'kickonly'):
                         ts3.requestClientKickFromServer(
                             self.schid, self.requested,
                             self.cfg['failover']['reason'].replace(
                                 '{isp}', isp))
                     else:
                         ts3.banclient(
                             self.schid, self.requested,
                             int(self.cfg['failover']['bantime']),
                             self.cfg['failover']['reason'].replace(
                                 '{isp}', isp))
                     self.requested = 0
                     reply.deleteLater()
                     return
             if PluginHost.cfg.getboolean("general", "verbose"):
                 ts3.printMessageToCurrentTab(
                     "%s's ISP: %s" %
                     (self.clientURL(self.schid, self.requested), isp))
             _match = False
             for _isp in self.isps:
                 if isp == _isp: _match = True
             if self.cfg.getboolean('general', 'whitelist') and not _match:
                 if self.cfg.getboolean('main', 'kickonly'):
                     ts3.requestClientKickFromServer(
                         self.schid, self.requested,
                         "%s is not a valid Internet Service Provider!" %
                         isp)
                     self.requested = 0
                 else:
                     ts3.banclient(
                         self.schid, self.requested, 60,
                         "%s is not a valid Internet Service Provider!" %
                         isp)
                     self.requested = 0
             elif not self.cfg.getboolean('general',
                                          'whitelist') and _match:
                 if self.cfg.getboolean('main', 'kickonly'):
                     ts3.requestClientKickFromServer(
                         self.schid, self.requested,
                         "%s is not a valid Internet Service Provider!" %
                         isp)
                     self.requested = 0
                 else:
                     ts3.banclient(
                         self.schid, self.requested, 60,
                         "%s is not a valid Internet Service Provider!" %
                         isp)
                     self.requested = 0
         except:
             ts3.printMessageToCurrentTab(
                 "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the ISP for '%s' (Reason: %s)"
                 %
                 (self.clientURL(self.schid, self.requested), format_exc()))
             if self.cfg.getboolean("failover", "enabled"):
                 if self.cfg.getboolean('failover', 'kickonly'):
                     ts3.requestClientKickFromServer(
                         self.schid, self.requested,
                         self.cfg['failover']['reason'].replace(
                             '{isp}', isp))
                 else:
                     ts3.banclient(
                         self.schid, self.requested,
                         int(self.cfg['failover']['bantime']),
                         self.cfg['failover']['reason'].replace(
                             '{isp}', isp))
     else:
         ts3.printMessageToCurrentTab(
             "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the ISP for '%s' (Reason: %s)"
             % (self.clientURL(self.schid,
                               self.requested), reply.errorString()))
         if self.cfg.getboolean("failover", "enabled"):
             if self.cfg.getboolean('failover', 'kickonly'):
                 ts3.requestClientKickFromServer(
                     self.schid, self.requested,
                     self.cfg['failover']['reason'].replace('{isp}', isp))
             else:
                 ts3.banclient(
                     self.schid, self.requested,
                     int(self.cfg['failover']['bantime']),
                     self.cfg['failover']['reason'].replace('{isp}', isp))
     self.requested = 0
     reply.deleteLater()
Example #4
0
 def ban(self, timeInSeconds, banReason):
     err = ts3lib.banclient(self.schid, self.clientID, timeInSeconds,
                            banReason)
     if err != ts3defines.ERROR_ok:
         raise ts3Error("Error applying ban: (%s, %s)" %
                        (err, ts3lib.getErrorMessage(err)[1]))
Example #5
0
 def onMainReply(self, reply):
     if reply.error() == QNetworkReply.NoError:
         try:
             isp = reply.readAll().data().decode('utf-8')
             if isp.startswith('AS'): isp = isp.split(" ", 1)[1]
             if not isp or isp == "" or isp == "undefined":
                 ts3.printMessageToCurrentTab(
                     "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the ISP for '%s' (Reason: %s) Falling back to %s"
                     % (self.clientURL(self.schid, self.requested),
                        format_exc(), self.cfg['api']['fallback'].replace(
                            "{ip}", self.ip)))
                 if self.cfg.getboolean("general", "debug"):
                     ts3.printMessageToCurrentTab(
                         self.cfg['api']['fallback'].replace(
                             "{ip}", self.ip))
                 self.nwb = QNetworkAccessManager()
                 self.nwb.connect("finished(QNetworkReply*)",
                                  self.onFallbackReply)
                 self.nwb.get(
                     QNetworkRequest(
                         QUrl(self.cfg['api']['fallback'].replace(
                             "{ip}", self.ip))))
                 return
             if self.cfg.getboolean("general", "debug"):
                 ts3.printMessageToCurrentTab(
                     "%s's ISP: %s" %
                     (self.clientURL(self.schid, self.requested), isp))
             _match = False
             for _isp in self.isps:
                 if isp == _isp: _match = True
             if self.cfg.getboolean('general', 'whitelist') and not _match:
                 if self.cfg.getboolean('main', 'kickonly'):
                     ts3.requestClientKickFromServer(
                         self.schid, self.requested,
                         "%s is not a valid Internet Service Provider!" %
                         isp)
                     self.requested = 0
                 else:
                     ts3.banclient(
                         self.schid, self.requested, 60,
                         "%s is not a valid Internet Service Provider!" %
                         isp)
                     self.requested = 0
             elif not self.cfg.getboolean('general',
                                          'whitelist') and _match:
                 if self.cfg.getboolean('main', 'kickonly'):
                     ts3.requestClientKickFromServer(
                         self.schid, self.requested,
                         "%s is not a valid Internet Service Provider!" %
                         isp)
                     self.requested = 0
                 else:
                     ts3.banclient(
                         self.schid, self.requested, 60,
                         "%s is not a valid Internet Service Provider!" %
                         isp)
                     self.requested = 0
         except:
             try:
                 ts3.printMessageToCurrentTab(
                     "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the ISP for '%s' (Reason: %s) Falling back to %s"
                     % (self.clientURL(self.schid, self.requested),
                        format_exc(), self.cfg['api']['fallback'].replace(
                            "{ip}", self.ip)))
                 if self.cfg.getboolean("general", "debug"):
                     ts3.printMessageToCurrentTab(
                         self.cfg['api']['fallback'].replace(
                             "{ip}", self.ip))
                 self.nwb = QNetworkAccessManager()
                 self.nwb.connect("finished(QNetworkReply*)",
                                  self.onFallbackReply)
                 self.nwb.get(
                     QNetworkRequest(
                         QUrl(self.cfg['api']['fallback'].replace(
                             "{ip}", self.ip))))
             except:
                 ts3.printMessageToCurrentTab(format_exc())
     else:
         ts3.printMessageToCurrentTab(
             "[[color=orange]WARNING[/color]] [color=red]ISPValidator could not resolve the ISP for '%s' (Reason: %s) Falling back to %s"
             % (self.clientURL(self.schid, self.requested),
                reply.errorString(), self.cfg['api']['fallback'].replace(
                    "{ip}", self.ip)))
         if self.cfg.getboolean("general", "debug"):
             ts3.printMessageToCurrentTab(
                 self.cfg['api']['fallback'].replace("{ip}", self.ip))
         self.nwb = QNetworkAccessManager()
         self.nwb.connect("finished(QNetworkReply*)", self.onFallbackReply)
         self.nwb.get(
             QNetworkRequest(
                 QUrl(self.cfg['api']['fallback'].replace("{ip}",
                                                          self.ip))))
     reply.deleteLater()