]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/Spamfilter.php
11 public Connection
$connection;
13 public function __construct(Connection
$conn)
15 $this->connection
= $conn;
21 * @return stdClass|array|bool
23 public function add(string $name, string $match_type, string $spamfilter_targets, string $ban_action, string $ban_duration, string $reason): stdClass
|array|bool
25 $response = $this->connection
->query('spamfilter.add', [
27 'match_type' => $match_type,
28 'spamfilter_targets' => $spamfilter_targets,
29 'ban_action' => $ban_action,
30 'ban_duration' => $ban_duration,
34 if (is_bool($response))
37 if (property_exists($response, 'tkl'))
38 return $response->tkl
;
43 * Delete a spamfilter.
45 * @return stdClass|array|bool
47 public function delete(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass
|array|bool
49 $response = $this->connection
->query('spamfilter.del', [
51 'match_type' => $match_type,
52 'spamfilter_targets' => $spamfilter_targets,
53 'ban_action' => $ban_action,
56 if (is_bool($response))
59 if (property_exists($response, 'tkl'))
60 return $response->tkl
;
65 * Return a list of all spamfilters.
67 * @return stdClass|array|bool
70 public function getAll(): stdClass
|array|bool
72 $response = $this->connection
->query('spamfilter.list');
74 if (!is_bool($response)) {
75 return $response->list;
78 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
82 * Get a specific spamfilter.
84 * @return stdClass|array|bool
86 public function get(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass
|array|bool
88 $response = $this->connection
->query('spamfilter.get', [
90 'match_type' => $match_type,
91 'spamfilter_targets' => $spamfilter_targets,
92 'ban_action' => $ban_action,
95 if (!is_bool($response)) {
96 return $response->tkl
;
99 return false; // not found