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
f8f29424
Commit
f8f29424
authored
Oct 30, 2021
by
Trevor Cappallo
Browse files
fixed duplication bug; first crack at win reports
parent
43efd410
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
5 deletions
+29
-5
te4.py
te4.py
+29
-5
No files found.
te4.py
View file @
f8f29424
...
...
@@ -16,6 +16,8 @@ reSummary = re.compile('^\s*(.*)\*\s+([0-9a-fA-F]+)\s+([0-9a-fA-F]+)\s+([0-9a-fA
oldGames
=
[]
newGames
=
[]
currentGames
=
{}
cnt
=
0
def
parse_server_poll
(
data
):
print
(
data
)
...
...
@@ -80,16 +82,33 @@ async def on_ready():
@
tasks
.
loop
(
seconds
=
15.0
)
async
def
status_task
():
global
oldGames
,
newGames
global
oldGames
,
newGames
,
cnt
,
currentGames
data
=
requests
.
get
(
"https://www.managames.com/tennis/online/TE4_ServerList.php?Poll=1"
)
# if cnt==0:
# info = parse_server_poll('0 10E1 "POLAND vs TennisStar" B180D41 12C 6AC 96 "" "6/3 4/6 7/6" 510 2 46 617DAC94 * 1 0 0 34 1ED48 0 MG-on'.replace('\n',' '))
# else:
info
=
parse_server_poll
(
data
.
text
.
replace
(
'
\n
'
,
' '
))
newGames
=
[{
k
:
v
for
(
k
,
v
)
in
x
.
items
()
if
k
!=
'score'
}
for
x
in
info
[
'games'
]]
newGames
=
[
x
for
x
in
newGames
if
x
not
in
oldGames
]
newGames
=
[
x
for
x
in
newGames
if
sorted
([
str
(
y
)
for
y
in
x
.
values
()])
not
in
oldGames
]
out
=
[]
nix
=
[]
for
ongoing
in
currentGames
.
keys
():
if
ongoing
not
in
[
x
[
'name'
]
for
x
in
info
[
'games'
]]:
out
+=
[
f
"The
{
ongoing
}
game is finished. Final score:
{
currentGames
[
ongoing
][
'score'
]
}
"
]
nix
+=
[
ongoing
]
for
xin
in
nix
:
del
currentGames
[
xin
]
if
len
(
newGames
)
>
0
:
out
=
[]
for
game
in
newGames
:
if
game
[
'ip'
]
==
'0'
:
s
=
f
"
{
game
[
'name'
]
}
started their match."
if
' vs '
not
in
game
[
'name'
]:
continue
else
:
s
=
f
"The
{
game
[
'name'
]
}
match has begun."
filt
=
tuple
(
filter
(
lambda
x
:
x
[
'name'
]
==
game
[
'name'
],
info
[
'games'
]))[
0
]
# currentGames[game['name']] = [v for (k,v) if k==game['name'] in x.items() for x in info['games'] ][0]
currentGames
[
game
[
'name'
]]
=
filt
else
:
s
=
f
"
{
game
[
'name'
]
}
(elo:
{
game
[
'elo'
]
}
, rep:
{
game
[
'reputation'
]
}
%) wants to play a
{
game
[
'game_info'
][
'nb_set'
]
}
-set match."
if
len
(
game
[
'tagline'
])
>
0
:
...
...
@@ -98,7 +117,12 @@ async def status_task():
pprint
.
pprint
(
out
)
await
ch
.
send
(
"
\n
"
.
join
(
out
))
oldGames
=
newGames
oldGames
=
[
sorted
([
str
(
y
)
for
y
in
x
.
values
()])
for
x
in
newGames
]
# oldGames += newGames
# oldGames =
# if (len(oldGames)>10):
# oldGames=oldGames[-10:]
cnt
+=
1
bot
.
run
(
TOKEN
)
...
...
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