mode, scanline, ignore

This commit is contained in:
dsc 2022-07-21 23:36:37 +02:00
parent d457a25c88
commit 27c95e3cc5
2 changed files with 16 additions and 8 deletions

16
main.py
View file

@ -16,7 +16,7 @@ import aiohttp
from settings import *
IGNORE_NICKS = ["monerobux", "denise"]
IGNORE_NICKS = ["monerobux", "denise", "quotez"]
TASK_QUEUE = asyncio.Queue()
TASK_AUTHORS = {}
FONT = ImageFont.truetype('font-bold.ttf', 22)
@ -188,8 +188,12 @@ async def handle_msg(nick, msg, target, now: float):
if "!dall " not in msg:
return
if not SCANLINE:
if not msg.strip().startswith("!dall "):
return
msg = msg[msg.find("!dall "):]
msg = msg[5:].strip()
msg = msg[6:].strip()
if len(msg) <= 8:
return _err(target, f"longer query required.")
@ -197,13 +201,13 @@ async def handle_msg(nick, msg, target, now: float):
TASK_AUTHORS.setdefault(nick, 0)
if TASK_AUTHORS[nick] >= 4:
err = f"{nick}: you already queued 4 thingies, patient!!11"
bot.send("NOTICE", target=target, message=err)
bot.send("PRIVMSG", target=target, message=err)
return
TASK_AUTHORS[nick] += 1
task = Task(channel=target, author=nick, term=msg, dt=int(now))
await TASK_QUEUE.put(task)
bot.send("NOTICE", target=target, message=f"generating...")
bot.send("PRIVMSG", target=target, message=f"generating...")
async def main():
@ -252,7 +256,9 @@ async def main():
_lower_author_task_count(task.author)
completed_secs = int((datetime.now() - now).total_seconds())
bot.send("NOTICE", target=task.channel, message=f"{url} \"{task.term_short}\" (total: {completed_secs}s, {task.author}) ")
bot.send("NOTICE" if NOTICES else "PRIVMSG",
target=task.channel,
message=f"{url} \"{task.term_short}\" (total: {completed_secs}s, {task.author}) ")
await asyncio.sleep(10)
loop = asyncio.get_event_loop()

View file

@ -4,3 +4,5 @@ IRC_PORT = 6667
IRC_TLS = False
IRC_CHANNELS = ["#lol"]
MODE = 'monero'
SCANLINE = False
NOTICES = True