def run(self, message, **kwargs): urls = urlwrangler.get_urls(message.content) resp = [] for u in urls: meta = connection.chibot.links_meta.find_and_modify({}, {"$inc": {"counter": 1}}, new=True) link = connection.chibot.Link() link["id"] = int(meta["counter"]) link["timestamp"] = datetime.datetime.now() link["nickname"] = message.nickname link["username"] = message.user link["host"] = message.host link["url"] = u link.save() resp.append("%s: %s" % (link["id"], link["url"])) return resp
def _message_filter(self, message): urls = urlwrangler.get_urls(message.content) return bool(urls)