3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-24 03:29:28 +01:00

Irc: allow defaulting to private command replies (Closes #409)

Squashed commit of the following:

commit c168500235b65f833b1d7fe49ebde674159683ee
Author: James Lu <GLolol@overdrivenetworks.com>
Date:   Thu Feb 16 17:33:36 2017 -0800

    ServiceBot: default notice and private to None

    This is so that it respects the changes from the last commit.

commit f685f3ef522f7f0ee356082c3c1b8b5a4e34b211
Author: James Lu <GLolol@overdrivenetworks.com>
Date:   Thu Feb 16 15:10:33 2017 -0800

    Irc: implement a prefer_private_replies option (#409)
This commit is contained in:
James Lu 2017-02-16 17:41:07 -08:00
parent ad873cfd7b
commit 2f968aca80
3 changed files with 10 additions and 2 deletions

View File

@ -524,6 +524,10 @@ class Irc():
loopback=True): loopback=True):
"""Replies to the last caller in the right context (channel or PM).""" """Replies to the last caller in the right context (channel or PM)."""
if private is None:
# Allow using private replies as the default, if no explicit setting was given.
private = conf.conf['bot'].get("prefer_private_replies")
# Private reply is enabled, or the caller was originally a PM # Private reply is enabled, or the caller was originally a PM
if private or (self.called_in in self.users): if private or (self.called_in in self.users):
if not force_privmsg_in_private: if not force_privmsg_in_private:

View File

@ -45,6 +45,10 @@ bot:
# of all database-enabled plugins to take effect. # of all database-enabled plugins to take effect.
save_delay: 300 save_delay: 300
# Determines whether services should default to sending command responses as private notices,
# even if the command was called in a channel. This defaults to False.
#prefer_private_replies: false
login: login:
# NOTE: for users migrating from PyLink < 1.1, the old login:user/login:password settings # NOTE: for users migrating from PyLink < 1.1, the old login:user/login:password settings
# have been deprecated. We strongly recommend migrating to the new "accounts:" block below, as # have been deprecated. We strongly recommend migrating to the new "accounts:" block below, as

View File

@ -284,7 +284,7 @@ class ServiceBot():
else: else:
log.warning('(%s) Ignoring invalid autojoin channel %r.', irc.name, chan) log.warning('(%s) Ignoring invalid autojoin channel %r.', irc.name, chan)
def reply(self, irc, text, notice=False, private=False): 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."""
servuid = self.uids.get(irc.name) servuid = self.uids.get(irc.name)
if not servuid: if not servuid:
@ -293,7 +293,7 @@ class ServiceBot():
irc.reply(text, notice=notice, source=servuid, private=private) irc.reply(text, notice=notice, source=servuid, private=private)
def error(self, irc, text, notice=False, private=False): def error(self, irc, text, notice=None, private=None):
"""Replies with an error, as the service in question.""" """Replies with an error, as the service in question."""
servuid = self.uids.get(irc.name) servuid = self.uids.get(irc.name)
if not servuid: if not servuid: