Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Trevor Cappallo
TE4bot
Commits
85df563f
Commit
85df563f
authored
Nov 06, 2021
by
Trevor Cappallo
Browse files
had some fun with the win announcements
parent
07c4d224
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
te4.py
te4.py
+32
-2
No files found.
te4.py
View file @
85df563f
...
...
@@ -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
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment