From 2d39c60db1bbcb30551da478eaa45144b808b20f Mon Sep 17 00:00:00 2001
From: j-crit <joshua.c.guam@gmail.com>
Date: Sun, 24 Apr 2016 15:31:48 +1000
Subject: [PATCH 1/6] Made it so Sopel doesn't automatically message the sender
 of someone who's triggered an error. Also added core config settings for
 toggling whether to message the logging channel (if it is set) or to use the
 original behavior of messaging the sender.

---
 sopel/config/core_section.py |  6 ++++++
 sopel/irc.py                 | 16 +++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/sopel/config/core_section.py b/sopel/config/core_section.py
index 0dfbdb16da..0dfd78d0d4 100644
--- a/sopel/config/core_section.py
+++ b/sopel/config/core_section.py
@@ -131,6 +131,12 @@ def homedir(self):
                                      'DEBUG'],
                                     'WARNING')
     """The lowest severity of logs to display."""
+    
+    message_logs = ValidatedAttribute('log_to_channel',bool,default=True)
+    """Whether to message the logging channel with thrown exceptions."""
+    
+    message_logs_sender = ValidatedAttribute('message_logs_sender',bool,default=False)
+    """Whether to message the sender of a message that triggered an error with the exception."""
 
     modes = ValidatedAttribute('modes', default='B')
     """User modes to be set on connection."""
diff --git a/sopel/irc.py b/sopel/irc.py
index 4b0a81c82d..3bbe40d57b 100644
--- a/sopel/irc.py
+++ b/sopel/irc.py
@@ -367,12 +367,18 @@ def error(self, trigger=None):
             except Exception as e:
                 stderr("Could not save full traceback!")
                 LOGGER.error("Could not save traceback from %s to file: %s", trigger.sender, str(e))
-
-            if trigger and trigger.sender is not None:
-                self.msg(trigger.sender, signature)
+            
+            # Errors will pass silently otherwise, not sure how to handle this
+            if trigger and self.config.core.message_logs and self.config.core.logging_channel is not None:
+                self.msg(self.config.logging_channel, signature)
+                if self.config.core.message_logs_sender:
+                    self.msg(trigger.sender,signature)
         except Exception as e:
-            if trigger and trigger.sender is not None:
-                self.msg(trigger.sender, "Got an error.")
+            if trigger:
+                if self.config.core.message_logs and self.config.core.logging_channel is not None:
+                    self.msg(self.config.core.logging_channel,"Got an error.")
+                    if self.config.core.message_logs_sender:
+                        self.msg(trigger.sender,"Got an error.")
                 LOGGER.error("Exception from %s: %s", trigger.sender, str(e))
 
     def handle_error(self):

From 0134b32306fbbf578afc1e9c113355ec90505000 Mon Sep 17 00:00:00 2001
From: j-crit <joshua.c.guam@gmail.com>
Date: Tue, 26 Apr 2016 15:11:47 +1000
Subject: [PATCH 2/6] Removed redundant lines.

---
 sopel/config/core_section.py |  9 +++------
 sopel/irc.py                 | 10 ++--------
 2 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/sopel/config/core_section.py b/sopel/config/core_section.py
index 0dfd78d0d4..d6c2eea23d 100644
--- a/sopel/config/core_section.py
+++ b/sopel/config/core_section.py
@@ -131,12 +131,6 @@ def homedir(self):
                                      'DEBUG'],
                                     'WARNING')
     """The lowest severity of logs to display."""
-    
-    message_logs = ValidatedAttribute('log_to_channel',bool,default=True)
-    """Whether to message the logging channel with thrown exceptions."""
-    
-    message_logs_sender = ValidatedAttribute('message_logs_sender',bool,default=False)
-    """Whether to message the sender of a message that triggered an error with the exception."""
 
     modes = ValidatedAttribute('modes', default='B')
     """User modes to be set on connection."""
@@ -184,6 +178,9 @@ def homedir(self):
     It is a regular expression (so the default, ``\.``, means commands start
     with a period), though using capturing groups will create problems."""
 
+    reply_errors = ValidatedAttribute('message_logs_sender',bool,default=False)
+    """Whether to message the sender of a message that triggered an error with the exception."""
+
     throttle_join = ValidatedAttribute('throttle_join', int)
     """Slow down the initial join of channels to prevent getting kicked.
 
diff --git a/sopel/irc.py b/sopel/irc.py
index 3bbe40d57b..fcbcd57c7f 100644
--- a/sopel/irc.py
+++ b/sopel/irc.py
@@ -368,16 +368,10 @@ def error(self, trigger=None):
                 stderr("Could not save full traceback!")
                 LOGGER.error("Could not save traceback from %s to file: %s", trigger.sender, str(e))
             
-            # Errors will pass silently otherwise, not sure how to handle this
-            if trigger and self.config.core.message_logs and self.config.core.logging_channel is not None:
-                self.msg(self.config.logging_channel, signature)
-                if self.config.core.message_logs_sender:
+            if trigger and self.config.core.reply_errors and trigger.sender is not None:
                     self.msg(trigger.sender,signature)
         except Exception as e:
-            if trigger:
-                if self.config.core.message_logs and self.config.core.logging_channel is not None:
-                    self.msg(self.config.core.logging_channel,"Got an error.")
-                    if self.config.core.message_logs_sender:
+            if trigger and self.config.core.reply_errors and trigger.sender is not None:
                         self.msg(trigger.sender,"Got an error.")
                 LOGGER.error("Exception from %s: %s", trigger.sender, str(e))
 

From 3375305dd53afe2f99dcd8b8c4e77d1b6f870d02 Mon Sep 17 00:00:00 2001
From: Joshua <joshua.c.guam@gmail.com>
Date: Wed, 27 Apr 2016 08:34:00 +1000
Subject: [PATCH 3/6] Corrected small error

---
 sopel/config/core_section.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sopel/config/core_section.py b/sopel/config/core_section.py
index d6c2eea23d..ffc8d269b7 100644
--- a/sopel/config/core_section.py
+++ b/sopel/config/core_section.py
@@ -178,7 +178,7 @@ def homedir(self):
     It is a regular expression (so the default, ``\.``, means commands start
     with a period), though using capturing groups will create problems."""
 
-    reply_errors = ValidatedAttribute('message_logs_sender',bool,default=False)
+    reply_errors = ValidatedAttribute('reply_errors',bool,default=False)
     """Whether to message the sender of a message that triggered an error with the exception."""
 
     throttle_join = ValidatedAttribute('throttle_join', int)

From 4ab09b51f9f16ba3bf758b22755bc5021a61bef2 Mon Sep 17 00:00:00 2001
From: Joshua <joshua.c.guam@gmail.com>
Date: Wed, 27 Apr 2016 12:15:56 +1000
Subject: [PATCH 4/6] Fixed spacing

I *think* this should be it.
---
 sopel/irc.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sopel/irc.py b/sopel/irc.py
index fcbcd57c7f..320e4336e3 100644
--- a/sopel/irc.py
+++ b/sopel/irc.py
@@ -367,12 +367,12 @@ def error(self, trigger=None):
             except Exception as e:
                 stderr("Could not save full traceback!")
                 LOGGER.error("Could not save traceback from %s to file: %s", trigger.sender, str(e))
-            
+
             if trigger and self.config.core.reply_errors and trigger.sender is not None:
-                    self.msg(trigger.sender,signature)
+                self.msg(trigger.sender,signature)
         except Exception as e:
             if trigger and self.config.core.reply_errors and trigger.sender is not None:
-                        self.msg(trigger.sender,"Got an error.")
+                self.msg(trigger.sender,"Got an error.")
                 LOGGER.error("Exception from %s: %s", trigger.sender, str(e))
 
     def handle_error(self):

From a5d8a754c3f5eea72cd31bc6a2497440aab01310 Mon Sep 17 00:00:00 2001
From: Joshua <joshua.c.guam@gmail.com>
Date: Wed, 27 Apr 2016 12:19:32 +1000
Subject: [PATCH 5/6] Fixed the other spacing issue.

---
 sopel/irc.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sopel/irc.py b/sopel/irc.py
index 320e4336e3..ec1838bedb 100644
--- a/sopel/irc.py
+++ b/sopel/irc.py
@@ -369,10 +369,10 @@ def error(self, trigger=None):
                 LOGGER.error("Could not save traceback from %s to file: %s", trigger.sender, str(e))
 
             if trigger and self.config.core.reply_errors and trigger.sender is not None:
-                self.msg(trigger.sender,signature)
+                self.msg(trigger.sender, signature)
         except Exception as e:
             if trigger and self.config.core.reply_errors and trigger.sender is not None:
-                self.msg(trigger.sender,"Got an error.")
+                self.msg(trigger.sender, "Got an error.")
                 LOGGER.error("Exception from %s: %s", trigger.sender, str(e))
 
     def handle_error(self):

From c1d4a1a3089659a3b29b045c2e9d6fb8f3eec831 Mon Sep 17 00:00:00 2001
From: Joshua <joshua.c.guam@gmail.com>
Date: Thu, 28 Apr 2016 20:09:26 +1000
Subject: [PATCH 6/6] Made setting consistent with previous versions

Also made minor spacing change
---
 sopel/config/core_section.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sopel/config/core_section.py b/sopel/config/core_section.py
index ffc8d269b7..723b69ef77 100644
--- a/sopel/config/core_section.py
+++ b/sopel/config/core_section.py
@@ -178,7 +178,7 @@ def homedir(self):
     It is a regular expression (so the default, ``\.``, means commands start
     with a period), though using capturing groups will create problems."""
 
-    reply_errors = ValidatedAttribute('reply_errors',bool,default=False)
+    reply_errors = ValidatedAttribute('reply_errors', bool, default=True)
     """Whether to message the sender of a message that triggered an error with the exception."""
 
     throttle_join = ValidatedAttribute('throttle_join', int)