58
57
URL_PREFIX = "https://twitter.com"
59
58
API_PREFIX = "https://api.twitter.com/1"
62
return re.sub('&(%s);' % '|'.join(name2codepoint),
63
lambda m: unichr(name2codepoint[m.group(1)]), s)
66
61
def __init__(self, acct):
67
62
self.service = util.getbus("Service")
84
79
m["account"] = self.account["id"]
85
80
if data.has_key("created_at"):
86
81
m["time"] = util.parsetime(data["created_at"])
87
m["text"] = unescape(data["text"])
82
m["text"] = util.unescape(data["text"])
88
83
m["to_me"] = ("@%s" % self.account["username"]) in data["text"]
90
m["html"] = util.linkify(data["text"],
85
m["html"] = util.linkify(m["text"],
91
86
((util.PARSE_HASH, '#<a class="hash" href="%s#search?q=\\1">\\1</a>' % URL_PREFIX),
92
(util.PARSE_NICK, '@<a class="nick" href="%s/\\1">\\1</a>' % URL_PREFIX)), escape=True)
87
(util.PARSE_NICK, '@<a class="nick" href="%s/\\1">\\1</a>' % URL_PREFIX)), escape=False)
94
m["content"] = util.linkify(data["text"],
95
((util.PARSE_HASH, '#<a class="hash" href="gwibber:/tag?acct=%s&query=\\1">\\1</a>' % m["account"]),
96
(util.PARSE_NICK, '@<a class="nick" href="gwibber:/user?acct=%s&name=\\1">\\1</a>' % m["account"])), escape=True)
89
m["content"] = util.linkify(m["text"],
90
((util.PARSE_HASH, '#<a href="gwibber:/tag?acct=%s&query=\\1">\\1</a>' % m["account"]),
91
(util.PARSE_NICK, '@<a href="gwibber:/user?acct=%s&name=\\1">\\1</a>' % m["account"])), escape=True)
98
93
m["favorited"] = data.get("favorited", False)
128
123
def _message(self, data):
129
if type(data) == type(None):
124
if type(data) != dict:
125
log.logger.error("Cannot parse message data: %s", str(data))
133
129
if data.has_key("retweeted_status"):
300
296
data = network.Download("http://search.twitter.com/search.json", util.compact(args))
301
297
data = data.get_json()["results"]
299
if type(data) != list:
300
log.logger.error("Cannot parse search data: %s", str(data))
303
303
return [self._result(m) for m in data]
305
305
def __call__(self, opname, **args):