From 2f968aca8087b3395116c55dcfb0535fab9ec7e7 Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 16 Feb 2017 17:41:07 -0800 Subject: [PATCH] Irc: allow defaulting to private command replies (Closes #409) Squashed commit of the following: commit c168500235b65f833b1d7fe49ebde674159683ee Author: James Lu 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 Date: Thu Feb 16 15:10:33 2017 -0800 Irc: implement a prefer_private_replies option (#409) --- classes.py | 4 ++++ example-conf.yml | 4 ++++ utils.py | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/classes.py b/classes.py index df8f4e5..89fe552 100644 --- a/classes.py +++ b/classes.py @@ -524,6 +524,10 @@ class Irc(): loopback=True): """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 if private or (self.called_in in self.users): if not force_privmsg_in_private: diff --git a/example-conf.yml b/example-conf.yml index 17fcbb1..c59cf51 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -45,6 +45,10 @@ bot: # of all database-enabled plugins to take effect. 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: # 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 diff --git a/utils.py b/utils.py index 7fc64d1..35e7be7 100644 --- a/utils.py +++ b/utils.py @@ -284,7 +284,7 @@ class ServiceBot(): else: 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.""" servuid = self.uids.get(irc.name) if not servuid: @@ -293,7 +293,7 @@ class ServiceBot(): 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.""" servuid = self.uids.get(irc.name) if not servuid: