|
14 | 14 |
|
15 | 15 | from fredirc import messages
|
16 | 16 | from fredirc.errors import ConnectionTimeoutError
|
| 17 | +from fredirc.messages import ChannelMode |
| 18 | +from fredirc.parsing import ChannelModeChange |
17 | 19 | from fredirc.processor import MessageProcessor
|
18 | 20 |
|
19 | 21 |
|
@@ -206,6 +208,62 @@ def pong(self):
|
206 | 208 | """ Send a pong message to the server. """
|
207 | 209 | self._send_message(messages.pong(self._state.server))
|
208 | 210 |
|
| 211 | + def give_op(self, channel, user): |
| 212 | + """ Grant operator rights to a user on a channel. |
| 213 | +
|
| 214 | + If the client is no operator, the server will respond with an |
| 215 | + error message that can be handled via |
| 216 | + :py:meth:`fredirc.handler.handle_error`. |
| 217 | +
|
| 218 | + Args: |
| 219 | + channel (str): the channel |
| 220 | + user (str): the affected user |
| 221 | + """ |
| 222 | + mode_change = ChannelModeChange(True, ChannelMode.OPERATOR, (user,)) |
| 223 | + self._send_message(messages.channel_mode(channel, mode_change)) |
| 224 | + |
| 225 | + def revoke_op(self, channel, user): |
| 226 | + """ Revoke operator rights from user on a channel. |
| 227 | +
|
| 228 | + If the client is no operator, the server will respond with an |
| 229 | + error message that can be handled via |
| 230 | + :py:meth:`fredirc.handler.handle_error`. |
| 231 | +
|
| 232 | + Args: |
| 233 | + channel (str): the channel |
| 234 | + user (str): the affected user |
| 235 | + """ |
| 236 | + mode_change = ChannelModeChange(False, ChannelMode.OPERATOR, (user,)) |
| 237 | + self._send_message(messages.channel_mode(channel, mode_change)) |
| 238 | + |
| 239 | + def give_voice(self, channel, user): |
| 240 | + """ Grant voice rights to a user on a channel. |
| 241 | +
|
| 242 | + If the client is no operator, the server will respond with an |
| 243 | + error message that can be handled via |
| 244 | + :py:meth:`fredirc.handler.handle_error`. |
| 245 | +
|
| 246 | + Args: |
| 247 | + channel (str): the channel |
| 248 | + user (str): the affected user |
| 249 | + """ |
| 250 | + mode_change = ChannelModeChange(True, ChannelMode.VOICE, (user,)) |
| 251 | + self._send_message(messages.channel_mode(channel, mode_change)) |
| 252 | + |
| 253 | + def revoke_voice(self, channel, user): |
| 254 | + """ Revoke voice rights from user on a channel. |
| 255 | +
|
| 256 | + If the client is no operator, the server will respond with an |
| 257 | + error message that can be handled via |
| 258 | + :py:meth:`fredirc.handler.handle_error`. |
| 259 | +
|
| 260 | + Args: |
| 261 | + channel (str): the channel |
| 262 | + user (str): the affected user |
| 263 | + """ |
| 264 | + mode_change = ChannelModeChange(False, ChannelMode.VOICE, (user,)) |
| 265 | + self._send_message(messages.channel_mode(channel, mode_change)) |
| 266 | + |
209 | 267 | def is_op_in(self, channel):
|
210 | 268 | """
|
211 | 269 | Check if this client has operator rights in the given channel.
|
|
0 commit comments