Commit 85df563f authored by Trevor Cappallo's avatar Trevor Cappallo
Browse files

had some fun with the win announcements

parent 07c4d224
......@@ -4,9 +4,14 @@ import re
import pprint
import requests
import platform
import random
from discord.ext import tasks, commands
from discord.ext.commands import Bot
winWords = ('annihilated', 'beat', 'won against', 'triumphed over', 'embarrassed', 'painted the court with', 'trounced', 'decisively won against', 'emasculated', 'eked out a win against', 'brushed off', 'destroyed', 'dominated', 'schooled')
reScore = re.compile('(\d)/(\d)')
reGame = re.compile('\s*([0-9.]+)\s+([0-9a-fA-F]+)\s+"(.*?)"'
'\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+"(.*?)"\s+"(.*?)"'
'\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s*',re.MULTILINE)
......@@ -99,8 +104,33 @@ async def status_task():
for ongoing in currentGames.keys():
if ongoing not in [x['name'] for x in games]:
out += [f"The {ongoing} game is finished. Final score: `{currentGames[ongoing]['score']}`"]
nix += [ongoing]
# out += [f"The {ongoing} game is finished. Final score: `{currentGames[ongoing]['score']}`"]
try:
nix += [ongoing]
score = currentGames[ongoing]['score']
sets = [0, 0]
scoreLine = reScore.findall(score)
players = ongoing.split(" vs ")
for setScore in scoreLine:
gamePoints = [int(x) for x in setScore]
if gamePoints == sorted(gamePoints):
sets[1]+=1
else:
sets[0]+=1
if sets[0]<sets[1]:
s = " ".join([x[::-1] for x in score.split(" ")])
(winner, loser) = players[::-1]
elif sets[0]>sets[1]:
s = score
(winner, loser) = players
else:
continue
s = s.replace("/", "-")
out += [f"{winner} {random.choice(winWords)} {loser}. Final score: `{s}`"]
except Exception as exc:
pprint.pprint(exc)
for xin in nix:
del currentGames[xin]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment