]> jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blobdiff - lib/ServerBan.php
Channel: add optional $object_detail_level argument to getAll() and get().
[irc/unrealircd/unrealircd-rpc-php.git] / lib / ServerBan.php
index 126692ad5e3fb341dcd7f7a80611834a6dab4288..5764d542d8ef93d100df09af51bd452cde90a8ef 100644 (file)
@@ -20,16 +20,22 @@ class ServerBan
      *
      * @param  string  $user
      * @return stdClass|array|bool
-     * @throws Exception
      */
     public function add(string $name, string $type, string $duration, string $reason): stdClass|array|bool
     {
-        return $this->connection->query('server_ban.add', [
+        $response = $this->connection->query('server_ban.add', [
             'name' => $name,
             'type' => $type,
             'reason' => $reason,
             'duration_string' => $duration ?? '1d',
         ]);
+
+        if (is_bool($response))
+            return false;
+
+        if (property_exists($response, 'tkl'))
+            return $response->tkl;
+        return FALSE;
     }
 
     /**
@@ -37,14 +43,20 @@ class ServerBan
      *
      * @param  string  $name
      * @return stdClass|array|bool
-     * @throws Exception
      */
     public function delete(string $name, string $type): stdClass|array|bool
     {
-        return $this->connection->query('server_ban.del', [
+        $response = $this->connection->query('server_ban.del', [
             'name' => $name,
             'type' => $type,
         ]);
+
+        if (is_bool($response))
+            return false;
+            
+        if (property_exists($response, 'tkl'))
+            return $response->tkl;
+        return FALSE;
     }
 
     /**
@@ -78,9 +90,9 @@ class ServerBan
         ]);
 
         if (!is_bool($response)) {
-            return $response;
+            return $response->tkl;
         }
 
-        throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
+        return false; // didn't exist
     }
 }