Don't reset the counter when the song changes

This commit is contained in:
Firepup Sixfifty 2024-05-06 09:45:02 -05:00
parent eaa1f14bf9
commit 7989715c1d
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA
2 changed files with 11 additions and 9 deletions

View file

@ -6,7 +6,7 @@ from typing import Optional, Any
import bare, pylast
load_dotenv()
__version__ = "v3.0.10"
__version__ = "v3.0.11-dev"
npbase: str = (
"\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
)
@ -38,6 +38,7 @@ servers: dict[str, dict[str, Any]] = {
"#sshchat": 0,
"#firemc": 0,
"#fp-radio": 0,
"#hardfork": 0,
},
"ignores": ["#fp-radio"],
"admins": ["h-tl"],

View file

@ -87,21 +87,22 @@ def radio(instance: bare.bot) -> NoReturn:
try:
newTrack = instance.lastfmLink.get_user("Firepup650").get_now_playing()
if newTrack:
if complained:
complained = False
thisTrack = newTrack.__str__()
if thisTrack != lastTrack:
misses = 0
missChunk = 0
lastTrack = thisTrack
instance.msg("f.sp " + thisTrack, "#fp-radio")
instance.sendraw(
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
thisTrack = newTrack.__str__()
if thisTrack != lastTrack:
lastTrack = thisTrack
instance.msg("f.sp " + thisTrack, "#fp-radio")
instance.sendraw(
f"TOPIC #fp-radio :Firepup radio ({thisTrack}) - https://open.spotify.com/playlist/4ctNy3O0rOwhhXIKyLvUZM"
)
elif not complained:
if misses < 0:
misses += 1