Compare commits

...

3 Commits

1 changed files with 10 additions and 7 deletions

View File

@ -14,7 +14,7 @@ import feedparser
LOGGER = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO,
format="%(asctime)s %(levelname)s %(threadName)s %(name)s %(message)s")
format="%(levelname)s %(threadName)s %(name)s %(message)s")
# Help configuration.
HELP_LIST = ["help", "faq", "aide"]
@ -94,11 +94,11 @@ def parse_irc_messages(irc_msg: str) -> Tuple[str, str, str]:
try:
target = irc_msg.split(":")[1].split(" ")[2]
except Exception:
LOGGER.exception("Exception raised to irc message parsing")
LOGGER.warning("Failed to parse target for actor='{}' in the following incoming irc message: {}".format(actor, irc_msg))
target = None
return " ".join(irc_msg.split()), actor, target
except Exception:
LOGGER.exception("Exception raised to irc message parsing")
LOGGER.exception("Failed to parse the following incoming irc message: {}".format(irc_msg))
return None, None, None
@ -156,6 +156,13 @@ class Bot:
if ready_to_read:
last_read = datetime.utcnow()
irc_msg = self.msg_handler()
# If the server pings us then we've got to respond!
if irc_msg.find("PING :") != -1:
self.pong(irc_msg)
LOGGER.info("Responding to ping message: {}".format(irc_msg))
continue
irc_msg, actor, channel = parse_irc_messages(irc_msg)
if irc_msg is not None:
@ -208,10 +215,6 @@ class Bot:
self._check_project_updates(channel)
self.send_privmsg(channel, "Fait !")
# If the server pings us then we've got to respond!
if irc_msg.find("PING :") != -1:
self.pong(irc_msg)
# Responds to a user that inputs "Hello Mybot".
def bot_hello(self, channel: str, greeting: str) -> None:
self.send_privmsg(channel, greeting)