Fix trailing colon in hearts name; add !bottom5
This commit is contained in:
parent
324a0b2f70
commit
7f4e88520a
1 changed files with 21 additions and 0 deletions
|
@ -28,6 +28,11 @@ def process_message(data):
|
||||||
outputs.append([data['channel'], scores])
|
outputs.append([data['channel'], scores])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if text == '!bottom5':
|
||||||
|
scores = bottom5()
|
||||||
|
outputs.append([data['channel'], scores])
|
||||||
|
return
|
||||||
|
|
||||||
if text.startswith('!erase'):
|
if text.startswith('!erase'):
|
||||||
name = text[len('!erase'):].strip()
|
name = text[len('!erase'):].strip()
|
||||||
success = erase_score(name)
|
success = erase_score(name)
|
||||||
|
@ -68,6 +73,9 @@ def calculate_score_and_find_operators(text):
|
||||||
if not found:
|
if not found:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
if text.endswith(':'):
|
||||||
|
text = text[:-1]
|
||||||
|
|
||||||
did_change = original_text != text
|
did_change = original_text != text
|
||||||
if did_change:
|
if did_change:
|
||||||
return score, text
|
return score, text
|
||||||
|
@ -102,6 +110,19 @@ def top5():
|
||||||
break
|
break
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
def bottom5():
|
||||||
|
data = read_data()
|
||||||
|
items = [(score, name) for name, score in data.items()]
|
||||||
|
items.sort(key=lambda item: item[0])
|
||||||
|
out = ''
|
||||||
|
for idx in range(4, -1, -1):
|
||||||
|
try:
|
||||||
|
item = items[idx]
|
||||||
|
out += '{}. _{}_ : {}\n'.format(len(items)-idx, item[1], item[0])
|
||||||
|
except IndexError:
|
||||||
|
break
|
||||||
|
return out
|
||||||
|
|
||||||
#
|
#
|
||||||
# Persistence
|
# Persistence
|
||||||
#
|
#
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue