Add a timer to change the topic in #firemc every minute
This commit is contained in:
parent
02f565e522
commit
617be6f79f
3 changed files with 11 additions and 4 deletions
2
bot.py
2
bot.py
|
@ -270,7 +270,7 @@ class bot(bare.bot):
|
||||||
tdict = {}
|
tdict = {}
|
||||||
for thread in self.threads:
|
for thread in self.threads:
|
||||||
tdict[thread] = timers.data[thread]
|
tdict[thread] = timers.data[thread]
|
||||||
if thread in ["radio"]:
|
if tdict[thread]["passInstance"]:
|
||||||
tdict[thread]["args"] = [self]
|
tdict[thread]["args"] = [self]
|
||||||
tMgr = Thread(target=timers.threadManager, args=(tdict,))
|
tMgr = Thread(target=timers.threadManager, args=(tdict,))
|
||||||
tMgr.daemon = True
|
tMgr.daemon = True
|
||||||
|
|
|
@ -6,7 +6,7 @@ from typing import Optional, Any
|
||||||
import bare, pylast
|
import bare, pylast
|
||||||
|
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
__version__ = "v3.0.6"
|
__version__ = "v3.0.7"
|
||||||
npbase: str = (
|
npbase: str = (
|
||||||
"\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
|
"\[\x0303last\.fm\x03\] [A-Za-z0-9_[\]{}\\|\-^]{1,$MAX} (is listening|last listened) to: \x02.+ - .*\x02( \([0-9]+ plays\)( \[.*\])?)?" # pyright: ignore [reportInvalidStringEscapeSequence]
|
||||||
)
|
)
|
||||||
|
|
11
timers.py
11
timers.py
|
@ -112,11 +112,18 @@ def radio(instance: bare.bot) -> NoReturn:
|
||||||
instance.log("Thread while loop broken", "FATAL")
|
instance.log("Thread while loop broken", "FATAL")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
def mcDown(instance: bare.bot) -> None:
|
def mcDown(instance: bare.bot) -> None:
|
||||||
instance.sendraw("TOPIC #firemc :FireMC Relay channel (offline)")
|
instance.sendraw("TOPIC #firemc :FireMC Relay channel (offline)")
|
||||||
|
|
||||||
|
|
||||||
data: dict[str, dict[str, Any]] = {
|
data: dict[str, dict[str, Any]] = {
|
||||||
"radio": {"noWrap": True, "func": radio, "args": []},
|
"radio": {"noWrap": True, "func": radio, "passInstance": True},
|
||||||
"mc-down": {"noWrap": False, "func": mcDown, "args": [], "interval": 60, "ignoreErrors": True}
|
"mc-down": {
|
||||||
|
"noWrap": False,
|
||||||
|
"func": mcDown,
|
||||||
|
"passInstance": True,
|
||||||
|
"interval": 60,
|
||||||
|
"ignoreErrors": True,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue