X-Git-Url: https://jfr.im/git/irc/unrealircd/unrealircd-rpc-php.git/blobdiff_plain/93f8a3ee8d1ab65e34e8f551d0018db8961955f8..101a298c6b6bed0ef6191cccbbad9358fb641746:/lib/Spamfilter.php diff --git a/lib/Spamfilter.php b/lib/Spamfilter.php index a7a0b39..fbb889a 100644 --- a/lib/Spamfilter.php +++ b/lib/Spamfilter.php @@ -19,11 +19,10 @@ class Spamfilter * Add a spamfilter. * * @return stdClass|array|bool - * @throws Exception */ public function add(string $name, string $match_type, string $spamfilter_targets, string $ban_action, string $ban_duration, string $reason): stdClass|array|bool { - return $this->connection->query('spamfilter.add', [ + $response = $this->connection->query('spamfilter.add', [ 'name' => $name, 'match_type' => $match_type, 'spamfilter_targets' => $spamfilter_targets, @@ -31,22 +30,35 @@ class Spamfilter 'ban_duration' => $ban_duration, 'reason' => $reason, ]); + + if (is_bool($response)) + return false; + + if (property_exists($response, 'tkl')) + return $response->tkl; + return FALSE; } /** * Delete a spamfilter. * * @return stdClass|array|bool - * @throws Exception */ public function delete(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass|array|bool { - return $this->connection->query('spamfilter.del', [ + $response = $this->connection->query('spamfilter.del', [ 'name' => $name, 'match_type' => $match_type, 'spamfilter_targets' => $spamfilter_targets, 'ban_action' => $ban_action, ]); + + if (is_bool($response)) + return false; + + if (property_exists($response, 'tkl')) + return $response->tkl; + return FALSE; } /** @@ -70,7 +82,6 @@ class Spamfilter * Get a specific spamfilter. * * @return stdClass|array|bool - * @throws Exception */ public function get(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass|array|bool { @@ -82,9 +93,9 @@ class Spamfilter ]); if (!is_bool($response)) { - return $response; + return $response->tkl; } - throw new Exception('Invalid JSON Response from UnrealIRCd RPC.'); + return false; // not found } }