This commit is contained in:
Ben Harris committed 2018-10-09 02:50:10 -04:00
1 parent a8a5de36f2
commit 58753c7234
38 files changed
+4549 -2523

No files matched your search

+15 -13
View File
@@ -8,20 +8,22 @@ import operator
MAX_NODES = 5
logfile = "/home/jumblesale/Code/irc/log"
timeCutoff = calendar.timegm(time.gmtime()) - (3 * 7 * 24 * 60 * 60) #3 weeks
timeCutoff = calendar.timegm(time.gmtime()) - (3 * 7 * 24 * 60 * 60) # 3 weeks
nameFix = {
'jumblesal': 'jumblesale',
'hardmath1': 'kc',
'hardmath123': 'kc',
'bendorphan': 'endorphant',
'endorphan': 'endorphant',
'synergian': 'synergiance'
}
"jumblesal": "jumblesale",
"hardmath1": "kc",
"hardmath123": "kc",
"bendorphan": "endorphant",
"endorphan": "endorphant",
"synergian": "synergiance",
}
def whoSaid(word):
word = word.lower()
userData = {} #hash keyed by "user" that contains a hash of mentioned other users with count
#Get a list of all user names by checking the logs for people who have said things
userData = {} # hash keyed by "user" that contains a hash of mentioned other users with count
# Get a list of all user names by checking the logs for people who have said things
with open(logfile, "r") as log:
for line in log:
try:
@@ -32,12 +34,12 @@ def whoSaid(word):
else:
user = user.lower()
except ValueError:
continue #There are some bad lines in the log file that we'll ignore if we can't parse
continue # There are some bad lines in the log file that we'll ignore if we can't parse
if time > timeCutoff and message[0] is not '!' and word in message.lower():
if time > timeCutoff and message[0] is not "!" and word in message.lower():
if user in userData:
userData[user] += 1
else:
userData[user] = 1
userData = sorted(userData.items(), key=operator.itemgetter(1), reverse=True)
return {'timecutoff': timeCutoff, 'data': userData}
return {"timecutoff": timeCutoff, "data": userData}