示例#1
0
文件: links.py 项目: glesica/chibot
    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
示例#2
0
文件: links.py 项目: glesica/chibot
 def _message_filter(self, message):
     urls = urlwrangler.get_urls(message.content)
     return bool(urls)