forked from Firepup650/FireBot
Try to have the radio dynamically adjust miss rates, based on success rates.
This commit is contained in:
parent
20a2c7bf1b
commit
e5e64bd7c1
1 changed files with 13 additions and 3 deletions
16
threads.py
16
threads.py
|
@ -79,22 +79,32 @@ def radio(instance: bare.bot) -> NoReturn:
|
||||||
lastTrack = ""
|
lastTrack = ""
|
||||||
complained = False
|
complained = False
|
||||||
firstMiss = False
|
firstMiss = False
|
||||||
|
misses = 0
|
||||||
|
missChunk = 0
|
||||||
|
missCap = -5
|
||||||
|
perChunk = 10
|
||||||
while 1:
|
while 1:
|
||||||
try:
|
try:
|
||||||
newTrack = instance.lastfmLink.get_user("Firepup650").get_now_playing()
|
newTrack = instance.lastfmLink.get_user("Firepup650").get_now_playing()
|
||||||
if newTrack:
|
if newTrack:
|
||||||
complained = False
|
complained = False
|
||||||
firstMiss = False
|
|
||||||
thisTrack = newTrack.__str__()
|
thisTrack = newTrack.__str__()
|
||||||
if thisTrack != lastTrack:
|
if thisTrack != lastTrack:
|
||||||
|
misses = 0
|
||||||
|
missChunk = 0
|
||||||
lastTrack = thisTrack
|
lastTrack = thisTrack
|
||||||
instance.msg("f.sp " + thisTrack, "#fp-radio")
|
instance.msg("f.sp " + thisTrack, "#fp-radio")
|
||||||
instance.sendraw(
|
instance.sendraw(
|
||||||
f"TOPIC #fp-radio :Firepup radio ({thisTrack}) - https://open.spotify.com/playlist/4ctNy3O0rOwhhXIKyLvUZM"
|
f"TOPIC #fp-radio :Firepup radio ({thisTrack}) - https://open.spotify.com/playlist/4ctNy3O0rOwhhXIKyLvUZM"
|
||||||
)
|
)
|
||||||
|
elif misses > missCap:
|
||||||
|
missChunk +=1
|
||||||
|
if missChunk >= perChunk:
|
||||||
|
misses -= 1
|
||||||
|
missChunk = 0
|
||||||
elif not complained:
|
elif not complained:
|
||||||
if not firstMiss:
|
if misses < 0:
|
||||||
firstMiss = True
|
misses += 1
|
||||||
continue
|
continue
|
||||||
instance.msg(
|
instance.msg(
|
||||||
"Firepup seems to have stopped the music by mistake :/", "#fp-radio"
|
"Firepup seems to have stopped the music by mistake :/", "#fp-radio"
|
||||||
|
|
Loading…
Reference in a new issue