3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-27 21:19:31 +01:00

ServiceBot: allow sending service parts with reasons

This commit is contained in:
James Lu 2018-05-05 13:19:43 -07:00
parent 61d7bf18d3
commit c7da7f0025

View File

@ -230,7 +230,7 @@ class ServiceBot():
else: else:
log.warning('(%s/%s) Ignoring invalid channel %r', irc.name, self.name, channel) log.warning('(%s/%s) Ignoring invalid channel %r', irc.name, self.name, channel)
def part(self, irc, channels): def part(self, irc, channels, reason=''):
""" """
Parts the given service bot from the given channel(s) if no plugins Parts the given service bot from the given channel(s) if no plugins
still register it as a persistent dynamic channel. still register it as a persistent dynamic channel.
@ -268,12 +268,12 @@ class ServiceBot():
persistent_channels) persistent_channels)
continue continue
to_part.append(channel) to_part.append(channel)
irc.part(uid, channel, '') # TODO: configurable part message? irc.part(uid, channel, reason)
else: else:
log.debug('(%s/%s) Ignoring part to %r, we are not there', irc.name, self.name, channel) log.debug('(%s/%s) Ignoring part to %r, we are not there', irc.name, self.name, channel)
continue continue
irc.call_hooks([uid, 'PYLINK_SERVICE_PART', {'channels': to_part, 'text': ''}]) irc.call_hooks([uid, 'PYLINK_SERVICE_PART', {'channels': to_part, 'text': reason}])
def reply(self, irc, text, notice=None, private=None): def reply(self, irc, text, notice=None, private=None):
"""Replies to a message as the service in question.""" """Replies to a message as the service in question."""
@ -439,14 +439,14 @@ class ServiceBot():
if try_join: if try_join:
self.join(irc, [channel]) self.join(irc, [channel])
def remove_persistent_channel(self, irc, namespace, channel, try_part=True): def remove_persistent_channel(self, irc, namespace, channel, try_part=True, part_reason=''):
""" """
Removes a persistent channel from the service bot on the given network and namespace. Removes a persistent channel from the service bot on the given network and namespace.
""" """
chanlist = self.dynamic_channels[namespace][irc.name].remove(channel) chanlist = self.dynamic_channels[namespace][irc.name].remove(channel)
if try_part and irc.connected.is_set(): if try_part and irc.connected.is_set():
self.part(irc, [channel]) self.part(irc, [channel], reason=part_reason)
def get_persistent_channels(self, irc, namespace=None): def get_persistent_channels(self, irc, namespace=None):
""" """