Marc-Alexandre Chan committed a8df299

Started to add logging messages to events

Comments (0)

Files changed (1)


 "DailyPromptBot? It's open-source! Here's [the DailyPromptBot "
+_evlog = logging.getLog('')
 class CommandError(MinibotError):
     """ Abstract base class for Command errors. """
-    def run(self): # TODO: handle exceptions from _parse_message, _parse_field, _make_command, and reddit (?)
+    def run(self):
         for msg in self.reddit.user.get_unread(limit=self.msg_chunk):
             msg_command = None
             # if a PM (no subreddit) and directly to the bot (not modmail)
                 msg_data = self._parse_message(msg)
                 msg_command = self._make_command(msg, msg_data)
             else: # bad message, ignore it
+                # if bad PM, log; don't care about replies/comments though
+                if msg.subreddit is None:
+                        ("CheckMessageEvent: Ignoring bad PM from "
+                        "{user} ({id_:d})").ormat(,
             if msg_command is not None:
         No validation of the data is performed.
+        _evlog.debug('CheckMessageEvent:Parsing message {id_:d} from {user}.'.
+            format(,
         msg_data = {}
         text_data = []
         data. If the command name is invalid, raises a CommandNameError. If the
         command parameters are invalid or incomplete, raises a
         CommandParametersError (from the command constructor). """
+'CheckMessageEvent: PM {id_:d}: building command: {info}'.
+                    format(, info='; '.join(data)))
         if data['action'] in self.cmd_actions.keys():
             CommandClass = self.cmd_actions[data.pop('action')]
             cmd_obj = CommandClass(msg, **data)