]>
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
24 public function add(string $name, string $match_type, string $spamfilter_targets, string $ban_action, string $ban_duration, string $reason): stdClass
|array|bool
26 $response = $this->connection
->query('spamfilter.add', [
28 'match_type' => $match_type,
29 'spamfilter_targets' => $spamfilter_targets,
30 'ban_action' => $ban_action,
31 'ban_duration' => $ban_duration,
35 if (is_bool($response))
38 if (property_exists($response, 'tkl'))
39 return $response->tkl
;
44 * Delete a spamfilter.
46 * @return stdClass|array|bool
49 public function delete(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass
|array|bool
51 $response = $this->connection
->query('spamfilter.del', [
53 'match_type' => $match_type,
54 'spamfilter_targets' => $spamfilter_targets,
55 'ban_action' => $ban_action,
58 if (is_bool($response))
61 if (property_exists($response, 'tkl'))
62 return $response->tkl
;
67 * Return a list of all spamfilters.
69 * @return stdClass|array|bool
72 public function getAll(): stdClass
|array|bool
74 $response = $this->connection
->query('spamfilter.list');
76 if (!is_bool($response)) {
77 return $response->list;
80 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
84 * Get a specific spamfilter.
86 * @return stdClass|array|bool
89 public function get(string $name, string $match_type, string $spamfilter_targets, string $ban_action): stdClass
|array|bool
91 $response = $this->connection
->query('spamfilter.get', [
93 'match_type' => $match_type,
94 'spamfilter_targets' => $spamfilter_targets,
95 'ban_action' => $ban_action,
98 if (!is_bool($response)) {
99 return $response->tkl
;
102 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');