]>
jfr.im git - irc/unrealircd/unrealircd-rpc-php.git/blob - lib/User.php
90deaeded05df90985f73a8d3ff078de6c925480
11 public Connection
$connection;
13 public function __construct(Connection
$conn)
15 $this->connection
= $conn;
19 * Return a list of all users.
23 public function getAll(): stdClass
|array|bool
25 $response = $this->connection
->query('user.list');
27 if(!is_bool($response)) {
28 return $response->list;
31 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
35 * Return a user object
37 * @return stdClass|array|bool
40 public function get(string $nick): stdClass
|array|bool
42 $response = $this->connection
->query('user.get', ['nick' => $nick]);
44 if (!is_bool($response)) {
45 return $response->client
;
48 throw new Exception('Invalid JSON Response from UnrealIRCd RPC.');
52 * Set the nickname of a user (changes the nick)
54 * @return stdClass|array|bool
57 public function set_nick(string $nick, string $newnick): stdClass
|array|bool
59 return $this->connection
->query('user.set_nick', [
61 'newnick' => $newnick,
66 * Set the username/ident of a user
68 * @return stdClass|array|bool
71 public function set_username(string $nick, string $username): stdClass
|array|bool
73 return $this->connection
->query('user.set_username', [
75 'username' => $username,
80 * Set the realname/gecos of a user
82 * @return stdClass|array|bool
85 public function set_realname(string $nick, string $realname): stdClass
|array|bool
87 return $this->connection
->query('user.set_realname', [
89 'realname' => $realname,
94 * Set a virtual host (vhost) on the user
96 * @return stdClass|array|bool
99 public function set_vhost(string $nick, string $vhost): stdClass
|array|bool
101 return $this->connection
->query('user.set_vhost', [
108 * Change the user modes of a user.
110 * @return stdClass|array|bool
113 public function set_mode(string $nick, string $mode, bool $hidden = false): stdClass
|array|bool
115 return $this->connection
->query('user.set_mode', [
123 * Change the snomask of a user (oper).
125 * @return stdClass|array|bool
128 public function set_snomask(string $nick, string $snomask, bool $hidden = false): stdClass
|array|bool
130 return $this->connection
->query('user.set_snomask', [
132 'snomask' => $snomask,
138 * Make user an IRC Operator (oper).
140 * @return stdClass|array|bool
143 public function set_oper(string $nick, string $oper_account, string $oper_class,
144 string $class = null, string $modes = null,
145 string $snomask = null, string $vhost = null): stdClass
|array|bool
147 return $this->connection
->query('user.set_oper', [
149 'oper_account' => $oper_account,
150 'oper_class' => $oper_class,
153 'snomask' => $snomask,
159 * Join a user to a channel.
161 * @return stdClass|array|bool
164 public function join(string $nick, string $channel,
165 string $key = null, bool $force = false): stdClass
|array|bool
167 return $this->connection
->query('user.join', [
169 'channel' => $channel,
176 * Part a user from a channel.
178 * @return stdClass|array|bool
181 public function part(string $nick, string $channel, bool $force = false): stdClass
|array|bool
183 return $this->connection
->query('user.part', [
185 'channel' => $channel,
191 * Quit a user from IRC. Pretend it is a normal QUIT.
193 * @return stdClass|array|bool
196 public function quit(string $nick, string $reason): stdClass
|array|bool
198 return $this->connection
->query('user.quit', [
205 * Kill a user from IRC. Show that the user is forcefully removed.
207 * @return stdClass|array|bool
210 public function kill(string $nick, string $reason): stdClass
|array|bool
212 return $this->connection
->query('user.kill', [