From 8f4a11e8359e0bdca1c5818226e8f39aa2778a13 Mon Sep 17 00:00:00 2001 From: Shauna Date: Sat, 18 Oct 2014 01:13:46 -0400 Subject: [PATCH] Check if actor is empty before cleaning nicks --- bot.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bot.py b/bot.py index cccf15b..0d8d5ea 100644 --- a/bot.py +++ b/bot.py @@ -123,11 +123,12 @@ def parse_messages(ircmsg): # Cleans a nickname of decorators/identifiers def clean_nick(actor): - actor = actor.replace("_", "") # Strip out trailing _ characters - while(actor[-1]) in "1234567890": # Remove trailing numbers - actor = actor[:-1] - if ('|' in actor): # Remove location specifiers, etc. - actor = actor.split('|')[0] + if actor: # In case an empty string gets passed + actor = actor.replace("_", "") # Strip out trailing _ characters + while(actor[-1]) in "1234567890": # Remove trailing numbers + actor = actor[:-1] + if ('|' in actor): # Remove location specifiers, etc. + actor = actor.split('|')[0] return actor # Parses messages and responds to them appropriately.