Skip to content

Commit 9739256

Browse files
committed
Kick-method.
1 parent e2b1f36 commit 9739256

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

fredirc/client.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ def send_private_message(self, user, message):
250250
self._send_message(
251251
messages.privmsg(user, message, self._state.nick))
252252

253+
def kick(self, user, channel, reason=None):
254+
""" Forcefully remove a user from 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:`handle_error()<fredirc.IRCHandler.handle_error>`.
259+
260+
Args:
261+
user (str): the affected user
262+
channel (str): the channel
263+
reason (str): optional message with the reason
264+
"""
265+
self._send_message(messages.kick((channel,), (user,), reason))
266+
253267
def pong(self):
254268
""" Send a pong message to the server. """
255269
self._send_message(messages.pong(self._state.server))

fredirc/messages.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ def part(channels, message):
234234
return '{part_cmd} {channels} :{message}'.format(
235235
part_cmd=Cmd.PART, channels=','.join(channels), message=message)
236236

237+
def kick(channels, users, message=None):
238+
if not message:
239+
message = ''
240+
return '{kick_cmd} {channels} {users} :{message}'.format(
241+
kick_cmd=Cmd.KICK, channels=','.join(channels), users=','.join(users),
242+
message=message)
237243

238244
def channel_mode(channel, mode_change):
239245
"""

0 commit comments

Comments
 (0)