Changeset 575
- Timestamp:
- 06/01/09 12:41:12 (3 years ago)
- Files:
-
- 1 modified
-
confluence/feedfilters/twitterfilter.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
confluence/feedfilters/twitterfilter.py
r569 r575 20 20 linknames = re.compile(r"@([a-zA-Z0-9_]+)") 21 21 hashtags = re.compile(r"#([a-zA-Z0-9_]+)") 22 statusidpattern = re.compile(r"http://twitter.com/.*/statuses/([0-9]*)") 22 23 23 24 xml = xml.dom.minidom.parseString(sys.stdin.read()) … … 33 34 continue 34 35 36 title = item.getElementsByTagName("title")[0].firstChild 37 title.data = titlepattern.sub(r"\1", title.data) 38 username = title.data.strip(":") 39 40 guid = item.getElementsByTagName("guid")[0].firstChild 41 statusid = statusidpattern.match(guid.data).group(1) 42 35 43 text = linkurls.sub(r"<a href='\1'>\1</a>", text) 36 44 text = linknames.sub(r"<a href='http://twitter.com/\1'>@\1</a>", text) 37 45 text = hashtags.sub(r"<a href='http://search.twitter.com/search?q=%23\1'>#\1</a>", text) 46 text += " <a href='http://twitter.com/home?status=@%s%%20&in_reply_to_status_id=%s&in_reply_to=%s'>Reply</a>" % (username, statusid, username) 38 47 description.data = text 39 48 40 title = item.getElementsByTagName("title")[0].firstChild41 title.data = titlepattern.sub(r"\1", title.data)42 43 49 print xml.toxml(encoding="UTF-8")
