capture: release thing on the next ping

This commit is contained in:
dece 2021-06-29 17:09:53 +02:00
parent b7b6ca71be
commit 47e24eebaa

View file

@ -15,6 +15,7 @@ class CapturePlugin(Plugin):
def __init__(self, bot): def __init__(self, bot):
super().__init__(bot) super().__init__(bot)
self.priority = -8 self.priority = -8
self.release_in_channel = ""
self.current_thing = None self.current_thing = None
def on_pubmsg(self, event): def on_pubmsg(self, event):
@ -26,10 +27,14 @@ class CapturePlugin(Plugin):
return False return False
if proc(self.config["rate"]): if proc(self.config["rate"]):
self.release_thing(event.target) self.release_in_channel = event.target
return True
return False return False
def on_ping(self, event):
if self.release_in_channel:
self.release_thing(self.release_in_channel)
self.release_in_channel = ""
def release_thing(self, target): def release_thing(self, target):
self.current_thing = random.choice(self.config["things"]) self.current_thing = random.choice(self.config["things"])
self.bot.say(target, f"(>O_O)> ~~{self.current_thing}") self.bot.say(target, f"(>O_O)> ~~{self.current_thing}")