Beispiel #1
0
  def _common(self, data):
    m = {}; 
    m["mid"] = str(data["id"])
    m["service"] = "qaiku"
    m["account"] = self.account["id"]
    m["time"] = util.parsetime(data["created_at"])
    m["text"] = data["text"]
    m["to_me"] = ("@%s" % self.account["username"]) in data["text"]

    m["html"] = data["html"]

    # TODO: Change Qaiku's @-links to people to Gwibber-internal ones
    m["content"] = data["html"]

    if (data["external_url"]):
      # Qaiku posts can have external links in them, display that under the message
      m["content"] += "<p><a href=\"" + data["external_url"] + "\">" + data["external_url"] + "</a></p>"

    # TODO: Display picture Qaikus

    if "channel" in data and data["channel"]:
      # Put message's Qaiku channel as "source" so it will be displayed in the UI
      m["source"] = "<a href=\"http://www.qaiku.com/channels/show/" + data["channel"] + "/\">#" + data["channel"] + "</a>"

    if "in_reply_to_status_id" in data and data["in_reply_to_status_id"]:
      m["reply"] = {}
      m["reply"]["id"] = data["in_reply_to_status_id"]
      m["reply"]["nick"] = data["in_reply_to_screen_name"]
      m["reply"]["url"] = data["in_reply_to_status_url"]

    return m
Beispiel #2
0
	def _common(self, data):
		m = {}
		try:
			m["mid"] = str(data["id"])
			m["service"] = "fanfou"
			m["account"] = self.account["id"]
			m["time"] = util.parsetime(data["created_at"])
			m["to_me"] = self.to_me in data["text"]
			content = data["text"]
			content = search_tags.sub(
				r'#<a class="hash" href="%s#search?q=\1">\2</a>#' % URL_PREFIX, content)
			content = user_tags.sub(
				r'@<a class="nick" href="%s/\1">\2</a>' % URL_PREFIX, content)
			m["html"] = content
			content = data["text"]
			content = search_tags.sub(
				r'#<a class="hash" href="gwibber:/tag?acct=%s&query=\1">\2</a>#' % m["account"], content)
			content = user_tags.sub(
					r'@<a class="nick" href="gwibber:/user?acct=%s&name=\1">\2</a>' % m["account"], content)
			m["content"] = content
			content = data["text"]
			content = search_tags.sub(r'#\2#', content)
			content = user_tags.sub(r'@\2', content)
			m["text"] = unescape(content)
			images = util.imagepreview(m["text"])
			if images:
				m["images"] = images
		except:
			log.logger.error("%s failure -'%s'", PROTOCOL_INFO["name"], data)
		return m
Beispiel #3
0
  def _common(self, data):
    m = {}
    try:
      m["mid"] = str(data["id"])
      m["service"] = "statusnet"
      m["account"] = self.account["id"]
      m["time"] = util.parsetime(data["created_at"])
      m["source"] = data.get("source", False)
      m["text"] = data["text"]
      m["to_me"] = ("@%s" % self.account["username"]) in data["text"]

      m["html"] = util.linkify(m["text"],
        ((util.PARSE_HASH, '#<a class="hash" href="%s#search?q=\\1">\\1</a>' % self.url_prefix),
        (util.PARSE_NICK, '@<a class="nick" href="%s/\\1">\\1</a>' % self.url_prefix)))

      m["content"] = util.linkify(m["text"],
        ((util.PARSE_HASH, '#<a class="hash" href="gwibber:/tag?acct=%s&query=\\1">\\1</a>' % m["account"]),
        (util.PARSE_NICK, '@<a class="nick" href="gwibber:/user?acct=%s&name=\\1">\\1</a>' % m["account"])))

      images = []
      if data.get("attachments", 0):
        for a in data["attachments"]:
          mime = a.get("mimetype", "")
          if mime and mime.startswith("image") and a.get("url", 0):
            images.append({"src": a["url"], "url": a["url"]})

      images.extend(util.imgpreview(m["text"]))
  
      if images:
        m["images"] = images
    except:
      log.logger.error("%s failure - %s", PROTOCOL_INFO["name"], data)

    return m
Beispiel #4
0
    def _common(self, data):
        m = {}
        m["mid"] = str(data["id"])
        m["service"] = "qaiku"
        m["account"] = self.account["id"]
        m["time"] = util.parsetime(data["created_at"])
        m["text"] = data["text"]
        m["to_me"] = ("@%s" % self.account["username"]) in data["text"]

        m["html"] = data["html"]

        # TODO: Change Qaiku's @-links to people to Gwibber-internal ones
        m["content"] = data["html"]

        if (data["external_url"]):
            # Qaiku posts can have external links in them, display that under the message
            m["content"] += "<p><a href=\"" + data[
                "external_url"] + "\">" + data["external_url"] + "</a></p>"

        # TODO: Display picture Qaikus

        if "channel" in data and data["channel"]:
            # Put message's Qaiku channel as "source" so it will be displayed in the UI
            m["source"] = "<a href=\"http://www.qaiku.com/channels/show/" + data[
                "channel"] + "/\">#" + data["channel"] + "</a>"

        if "in_reply_to_status_id" in data and data["in_reply_to_status_id"]:
            m["reply"] = {}
            m["reply"]["id"] = data["in_reply_to_status_id"]
            m["reply"]["nick"] = data["in_reply_to_screen_name"]
            m["reply"]["url"] = data["in_reply_to_status_url"]

        return m
Beispiel #5
0
    def _common(self, data):
        m = {}
        try:
            m["mid"] = str(data["id"])
            m["service"] = "twitter"
            m["account"] = self.account["id"]
            m["time"] = util.parsetime(data["created_at"])
            m["text"] = unescape(data["text"])
            m["to_me"] = ("@%s" % self.account["username"]) in data["text"]

            m["html"] = util.linkify(
                data["text"],
                ((util.PARSE_HASH,
                  '#<a class="hash" href="%s#search?q=\\1">\\1</a>' %
                  URL_PREFIX),
                 (util.PARSE_NICK,
                  '@<a class="nick" href="%s/\\1">\\1</a>' % URL_PREFIX)),
                escape=False)

            m["content"] = util.linkify(data["text"], ((
                util.PARSE_HASH,
                '#<a class="hash" href="gwibber:/tag?acct=%s&query=\\1">\\1</a>'
                % m["account"]
            ), (util.PARSE_NICK,
                '@<a class="nick" href="gwibber:/user?acct=%s&name=\\1">\\1</a>'
                % m["account"])),
                                        escape=False)

            images = util.imgpreview(m["text"])
            if images:
                m["images"] = images
        except:
            log.logger.error("%s failure - %s", PROTOCOL_INFO["name"], data)

        return m
Beispiel #6
0
  def _common(self, data):
    m = {}; 
    try:
      m["mid"] = str(data["id"])
      m["service"] = "twitter"
      m["account"] = self.account["id"]
      m["time"] = util.parsetime(data["created_at"])
      m["text"] = unescape(data["text"])
      m["to_me"] = ("@%s" % self.account["username"]) in data["text"]

      m["html"] = util.linkify(data["text"],
        ((util.PARSE_HASH, '#<a class="hash" href="%s#search?q=\\1">\\1</a>' % URL_PREFIX),
        (util.PARSE_NICK, '@<a class="nick" href="%s/\\1">\\1</a>' % URL_PREFIX)), escape=False)

      m["content"] = util.linkify(data["text"],
        ((util.PARSE_HASH, '#<a class="hash" href="gwibber:/tag?acct=%s&query=\\1">\\1</a>' % m["account"]),
        (util.PARSE_NICK, '@<a class="nick" href="gwibber:/user?acct=%s&name=\\1">\\1</a>' % m["account"])), escape=False)

      images = util.imgpreview(m["text"])
      if images:
        m["images"] = images
    except: 
      log.logger.error("%s failure - %s", PROTOCOL_INFO["name"], data)
 
    return m
Beispiel #7
0
  def _message(self, data):
    m = {
      "mid": data["id"],
      "service": "friendfeed",
      "account": self.account["id"],
      "time": util.parsetime(data["published"]),
      "source": data.get("via", {}).get("name", None),
      "text": data["title"],
      "html": util.linkify(data["title"]),
      "content": util.linkify(data["title"]),
      "url": data["link"],
      "sender": self._sender(data["user"]),
    }
    
    if data.get("service", 0):
      m["origin"] = {
        "id": data["service"]["id"],
        "name": data["service"]["name"],
        "icon": data["service"]["iconUrl"],
        "url": data["service"]["profileUrl"],
      }

    if data.get("likes", 0):
      m["likes"] = {"count": len(data["likes"])}

    if data.get("comments", 0):
      m["comments"] = []
      for item in data["comments"][-3:]:
        m["comments"].append({
          "text": item["body"],
          "time": util.parsetime(item["date"]),
          "sender": self._sender(item["user"]),
        })

    for i in data["media"]:
      if i.get("thumbnails", 0):
        m["images"] = []
        for t in i["thumbnails"]:
          m["images"].append({"src": t["url"], "url": i["link"]})

    if data.get("geo", 0):
      m["location"] = data["geo"]

    return m
Beispiel #8
0
  def _message(self, data):
    m = {
        "mid": data["id"],
        "service": "buzz",
        "account": self.account["id"],
        "time": util.parsetime(data["published"]),
        "url": data.get("links", {})["alternate"][0].get("href", ""),
        "source": data.get("source", {}).get("title", None),
        "sender": self._actor(data["actor"]),
    }

    m["text"] = data["object"]["content"]

    if data.get("source", {}).get("title", 0) == "Twitter":
      m["text"] = m["text"].split(">:", 1)[1].strip()
    
    m["html"] = m["text"]
    m["content"] = m["text"]

    if data.get("geocode", 0):
      m["location"] = {
          "lat": data["geocode"].split()[0],
          "lon": data["geocode"].split()[1],
      }

      if data.get("address", 0):
        m["location"]["address"] = data["address"]

    m["images"] = []
    for a in data["object"].get("attachments", []):
      if a["type"] == "photo":
        m["images"].append({
          "src": a["links"]["preview"][0]["href"],
          "url": a["links"]["enclosure"][0]["href"]
        })

      if a["type"] == "video":
        m["images"].append({
          "src": a["links"]["preview"][0]["href"],
          "url": a["links"]["alternate"][0]["href"],
        })

      if a["type"] == "article":
        m["content"] += "<p><b><a href=\"%s\">%s</a></b></p>" % (a["links"]["alternate"][0]["href"], a["title"])

    return m
Beispiel #9
0
  def _message(self, data):
    log.logger.info('socialtext._message: ' + str(data))
    m = {}
    m['mid'] = str(data['signal_id'])
    m['service'] = 'socialtext'
    m['account'] = self.account['id']
    m['time'] = util.parsetime(data['at'])

    m['sender'] = {}
    m['sender']['nick'] = data['best_full_name']
    m['sender']['image'] = "%sdata/people/%d/photo" % (RESTFUL_URL, int(data['user_id']))
    m['sender']['url'] = "%s/st/profile/%d" % (RESTFUL_URL, int(data['user_id']))

    m['url'] = "%s/st/profile/%d" % (RESTFUL_URL, int(data['user_id']))

    m['content'] = data['body']
    m['text'] = data['body']

    return m
Beispiel #10
0
    def _common(self, data):
        m = {}
        try:
            m["mid"] = str(data["id"])
            m["service"] = "identica"
            m["account"] = self.account["id"]
            m["time"] = util.parsetime(data["created_at"])
            m["source"] = data.get("source", False)
            m["text"] = data["text"]
            m["to_me"] = ("@%s" % self.account["username"]) in data["text"]

            m["html"] = util.linkify(
                m["text"],
                ((util.PARSE_HASH,
                  '#<a class="hash" href="%s#search?q=\\1">\\1</a>' %
                  URL_PREFIX),
                 (util.PARSE_NICK,
                  '@<a class="nick" href="%s/\\1">\\1</a>' % URL_PREFIX)))

            m["content"] = util.linkify(m["text"], ((
                util.PARSE_HASH,
                '#<a class="hash" href="gwibber:/tag?acct=%s&query=\\1">\\1</a>'
                % m["account"]
            ), (util.PARSE_NICK,
                '@<a class="nick" href="gwibber:/user?acct=%s&name=\\1">\\1</a>'
                % m["account"])))

            images = []
            if data.get("attachments", 0):
                for a in data["attachments"]:
                    mime = a.get("mimetype", "")
                    if mime and mime.startswith("image") and a.get("url", 0):
                        images.append({"src": a["url"], "url": a["url"]})

            images.extend(util.imgpreview(m["text"]))

            if images:
                m["images"] = images
        except:
            log.logger.error("%s failure - %s", PROTOCOL_INFO["name"], data)

        return m
Beispiel #11
0
  def _reply(self, data):
    log.logger.info('socialtext._reply: ' + str(data))
    c = {}
    c['mid'] = str(data['signal_id'])
    c['service'] = 'socialtext'
    c['account'] = self.account['id']
    c['time'] = util.parsetime(data['at'])

    c['reply'] = {}
    c['reply']['id'] = data['in_reply_to']['signal_id']
    c['reply']['url'] = "%s%s" % (RESTFUL_URL, data['in_reply_to']['uri'])

    c['sender'] = {}
    c['sender']['nick'] = data['best_full_name']
    c['sender']['name'] = data['best_full_name']
    c['sender']['image'] = "%sdata/people/%d/photo" % (RESTFUL_URL, int(data['user_id']))
    c['sender']['url'] = "%s/st/profile/%d" % (RESTFUL_URL, int(data['user_id']))

    c['url'] = "%s%s" % (RESTFUL_URL, data['uri'])

    c['content'] = data['body']
    c['text'] = data['body']

    return c