From 4b3c9162b99a7ffba8e87e1866f9e135a6586440 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 20 Apr 2003 01:40:55 +0000 Subject: [PATCH] Added something to stop assertion errors in case of ChanServ stuff. --- plugins/ChannelStats.py | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/plugins/ChannelStats.py b/plugins/ChannelStats.py index accb3933f..f4a51f926 100644 --- a/plugins/ChannelStats.py +++ b/plugins/ChannelStats.py @@ -154,7 +154,10 @@ class ChannelStats(callbacks.Privmsg, ChannelDBHandler): cursor = db.cursor() cursor.execute("""UPDATE channel_stats SET joins=joins+1""") try: - name = ircdb.users.getUserName(msg.prefix) + if ircutils.isUserHostmask(msg.prefix): + name = ircdb.users.getUserName(msg.prefix) + else: + name = msg.prefix cursor.execute("""UPDATE user_stats SET joins=joins+1 WHERE name=%s""", name) @@ -168,7 +171,10 @@ class ChannelStats(callbacks.Privmsg, ChannelDBHandler): cursor = db.cursor() cursor.execute("""UPDATE channel_stats SET parts=parts+1""") try: - name = ircdb.users.getUserName(msg.prefix) + if ircutils.isUserHostmask(msg.prefix): + name = ircdb.users.getUserName(msg.prefix) + else: + name = msg.prefix cursor.execute("UPDATE user_stats SET parts=parts+1 WHERE name=%s", name) except KeyError: @@ -181,7 +187,10 @@ class ChannelStats(callbacks.Privmsg, ChannelDBHandler): cursor = db.cursor() cursor.execute("""UPDATE channel_stats SET topics=topics+1""") try: - name = ircdb.users.getUserName(msg.prefix) + if ircutils.isUserHostmask(msg.prefix): + name = ircdb.users.getUserName(msg.prefix) + else: + name = msg.prefix cursor.execute("""UPDATE user_stats SET topics=topics+1 WHERE name=%s""", name) @@ -195,7 +204,10 @@ class ChannelStats(callbacks.Privmsg, ChannelDBHandler): cursor = db.cursor() cursor.execute("""UPDATE channel_stats SET modes=modes+1""") try: - name = ircdb.users.getUserName(msg.prefix) + if ircutils.isUserHostmask(msg.prefix): + name = ircdb.users.getUserName(msg.prefix) + else: + name = msg.prefix cursor.execute("""UPDATE user_stats SET modes=modes+1 WHERE name=%s""", name) @@ -209,7 +221,10 @@ class ChannelStats(callbacks.Privmsg, ChannelDBHandler): cursor = db.cursor() cursor.execute("""UPDATE channel_stats SET kicks=kicks+1""") try: - name = ircdb.users.getUserName(msg.prefix) + if ircutils.isUserHostmask(msg.prefix): + name = ircdb.users.getUserName(msg.prefix) + else: + name = msg.prefix cursor.execute("""UPDATE user_stats SET kicks=kicks+1 WHERE name=%s""", name)