DEV: Various changes to last.fm functionality, also change the efnet server.

This commit is contained in:
Firepup Sixfifty 2024-04-11 21:43:04 -05:00
parent 277d001f52
commit a5e1c1c96b
Signed by: Firepup650
GPG key ID: 7C92E2ABBBFAB9BA
3 changed files with 19 additions and 8 deletions

View file

@ -176,16 +176,21 @@ def nowplaying(bot: bare.bot, chan: str, name: str, message: str) -> None:
def fmpull(bot: bare.bot, chan: str, name: str, message: str) -> None:
song = None
try:
bot.msg(
"Firepup is currently listening to: "
+ bot.lastfmLink.get_user("Firepup650").get_now_playing().__str__(),
chan,
)
song = bot.lastfmLink.get_user("Firepup650").get_now_playing()
except:
bot.msg(
"Sorry, the music api isn't cooperating, please try again in a minute", chan
)
if song:
bot.msg(
"Firepup is currently listening to: "
+ song.__str__(),
chan,
)
else:
bot.msg("Firepup currently has his music stopped :/", chan)
def whoami(bot: bare.bot, chan: str, name: str, message: str) -> None:
@ -200,7 +205,7 @@ data: dict[str, dict[str, Any]] = {
"bugs bugs bugs": {"prefix": False, "aliases": []},
"hi $BOTNICK": {"prefix": False, "aliases": ["hello $BOTNICK"]},
# [npbase, su]
"restart": {"prefix": True, "aliases": ["reboot", "stop", "hardreload"], "check": checks.admin},
"restart": {"prefix": True, "aliases": ["reboot", "stop", "hardreload", "hr"], "check": checks.admin},
"uptime": {"prefix": True, "aliases": []},
"raw ": {"prefix": True, "aliases": ["cmd "], "check": checks.admin},
"debug": {"prefix": True, "aliases": ["dbg", "d"], "check": checks.admin},

View file

@ -6,7 +6,7 @@ from typing import Optional, Any
import bare, pylast
load_dotenv()
__version__ = "v3.0.3"
__version__ = "v3.0.4"
npbase: str = (
"\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
)
@ -22,7 +22,7 @@ servers: dict[str, dict[str, Any]] = {
"hosts": ["9pfs.repl.co"],
},
"efnet": {
"address": "irc.mzima.net",
"address": "irc.underworld.no",
"channels": {"#random": 0, "#dice": 0},
"hosts": ["154.sub-174-251-241.myvzw.com"],
},

View file

@ -78,11 +78,13 @@ def threadManager(
def radio(instance: bare.bot) -> NoReturn:
lastTrack = ""
complained = False
firstMiss = False
while 1:
try:
newTrack = instance.lastfmLink.get_user("Firepup650").get_now_playing()
if newTrack:
complained = False
firstMiss = False
thisTrack = newTrack.__str__()
if thisTrack != lastTrack:
lastTrack = thisTrack
@ -91,9 +93,13 @@ def radio(instance: bare.bot) -> NoReturn:
f"TOPIC #fp-radio :Firepup radio ({thisTrack}) - https://open.spotify.com/playlist/4ctNy3O0rOwhhXIKyLvUZM"
)
elif not complained:
if not firstMiss:
firstMiss = True
continue
instance.msg("Firepup seems to have stopped the music by mistake :/", "#fp-radio")
instance.sendraw("TOPIC #fp-radio :Firepup radio (Offline) - https://open.spotify.com/playlist/4ctNy3O0rOwhhXIKyLvUZM")
complained = True
lastTrack = "null"
except Exception:
Err = format_exc()
for line in Err.split("\n"):