Beispiel #1
0
 def isuuidbanned(self, uuid):  # Check if the UUID of the user is banned
     banlist = getjsonfile("banned-players", self.serverpath)
     if banlist:  # make sure banlist exists
         banrecord = find_in_json(banlist, "uuid", str(uuid))
         if banrecord:
             # if ban has expired
             if read_timestr(banrecord["expires"]) < int(time.time()):
                 pardoning = self.pardonuuid(str(uuid))
                 if pardoning[:8] == "pardoned":
                     self.log.info("UUID: %s was pardoned "
                                   "(expired ban)", str(uuid))
                     return False  # player is "NOT" banned (anymore)
                 else:
                     self.log.warning(
                         "isuuidbanned attempted a pardon of"
                         " uuid: %s (expired ban), "
                         "but it failed:\n %s", uuid, pardoning)
             return True  # player is still banned
     return False  # banlist empty or record not found
 def isuuidbanned(self, uuid):  # Check if the UUID of the user is banned
     banlist = getjsonfile("banned-players", self.srv_data.serverpath)
     if banlist:  # make sure banlist exists
         banrecord = find_in_json(banlist, "uuid", str(uuid))
         if banrecord:
             # if ban has expired
             if read_timestr(banrecord["expires"]) < int(time.time()):
                 pardoning = self.pardonuuid(str(uuid))
                 if pardoning[:8] == "pardoned":
                     self.log.info("UUID: %s was pardoned "
                                   "(expired ban)", str(uuid))
                     return False  # player is "NOT" banned (anymore)
                 else:
                     self.log.warning("isuuidbanned attempted a pardon of"
                                      " uuid: %s (expired ban), "
                                      "but it failed:\n %s",
                                      uuid, pardoning)
             return True  # player is still banned
     return False  # banlist empty or record not found
 def isipbanned(self, ipaddress):  # Check if the IP address is banned
     banlist = getjsonfile("banned-ips", self.srv_data.serverpath)
     if banlist:  # make sure banlist exists
         for record in banlist:
             _ip = record["ip"]
             if _ip in ipaddress:
                 _expires = read_timestr(record["expires"])
                 if _expires < int(time.time()):  # if ban has expired
                     pardoning = self.pardonip(ipaddress)
                     if pardoning[:8] == "pardoned":
                         self.log.info("IP: %s was pardoned "
                                       "(expired ban)", ipaddress)
                         return False  # IP is "NOT" banned (anymore)
                     else:
                         self.log.warning("isipbanned attempted a pardon "
                                          "of IP: %s (expired ban),  but"
                                          " it failed:\n %s",
                                          ipaddress, pardoning)
                 return True  # IP is still banned
     return False  # banlist empty or record not found
 def isipbanned(self, ipaddress):  # Check if the IP address is banned
     banlist = getjsonfile("banned-ips", self.javaserver.serverpath)
     if banlist:  # make sure banlist exists
         for record in banlist:
             _ip = record["ip"]
             if _ip in ipaddress:
                 _expires = read_timestr(record["expires"])
                 if _expires < int(time.time()):  # if ban has expired
                     pardoning = self.pardonip(ipaddress)
                     if pardoning[:8] == "pardoned":
                         self.log.info("IP: %s was pardoned "
                                       "(expired ban)", ipaddress)
                         return False  # IP is "NOT" banned (anymore)
                     else:
                         self.log.warning("isipbanned attempted a pardon "
                                          "of IP: %s (expired ban),  but"
                                          " it failed:\n %s",
                                          ipaddress, pardoning)
                 return True  # IP is still banned
     return False  # banlist empty or record not found