from lxml import etree
from distbot.bot.worker import Worker
-from distbot.common.action import Action
+from distbot.common.action import Action, send_action
from distbot.common.config import conf_get, conf_set
from distbot.common.message import get_words
return Action(time=crawl_at, command="nick.dsa-watcher.run", mutex="dsa-watcher")
+ def init_queue(self):
+ # some semantic misuse here to get the thing started after connecting
+ super().init_queue()
+ send_action(self.actionqueue, self.start_crawling())
+
def parse_body(self, msg):
words = get_words(msg)[1:]
cmd = None
logger.debug("dsa-crawler: active {}, cmd {}, last_crawl at {}".format(active, str(cmd), format(last_dsa_date)))
if cmd == "start":
- msg = self.crawl()
- event = self.get_next_schedule()
- conf_set("plugins.dsa-watcher.active", True)
- return Action(event=event, msg=msg)
+ return self.start_crawling()
if cmd == "run":
msg = self.crawl()
event = self.get_next_schedule()
return Action(msg=msg)
+ def start_crawling(self):
+ msg = self.crawl()
+ event = self.get_next_schedule()
+ conf_set("plugins.dsa-watcher.active", True)
+ return Action(event=event, msg=msg)
+
ALL = [DSAWatcher]