Mercurial > pidgin-twitter
changeset 297:e07f28bed8a8
experimental support for search tags in twitter.
author | Yoshiki Yazawa <yaz@honeyplanet.jp> |
---|---|
date | Thu, 16 Apr 2009 17:12:53 +0900 |
parents | c82877ba148a |
children | fd0948c7078e |
files | main.c pidgin-twitter.h |
diffstat | 2 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/main.c Thu Apr 09 13:12:45 2009 +0900 +++ b/main.c Thu Apr 16 17:12:53 2009 +0900 @@ -216,6 +216,13 @@ g_free(match1); g_free(match2); } + else if(which == TAG_TWITTER && service == twitter_service) { + gchar *match = g_match_info_fetch(match_info, 1); + gchar *link = g_ascii_strdown(match, -1); + g_snprintf(sub, SUBST_BUF_SIZE, TAG_FORMAT_TWITTER, link, match); + g_free(match); + g_free(link); + } else if(which == TAG_IDENTICA && service == identica_service) { gchar *match = g_match_info_fetch(match_info, 1); gchar *link = g_ascii_strdown(match, -1); @@ -379,6 +386,10 @@ purple_prefs_get_bool(OPT_TRANSLATE_CHANNEL)) { translate(buffer, TAG_IDENTICA, service); } + if(service == twitter_service && + purple_prefs_get_bool(OPT_TRANSLATE_CHANNEL)) { + translate(buffer, TAG_TWITTER, service); + } if(service == identica_service && purple_prefs_get_bool(OPT_TRANSLATE_CHANNEL)) { translate(buffer, GROUP_IDENTICA, service); @@ -1115,6 +1126,7 @@ regp[PSEUDO] = g_regex_new(P_PSEUDO, G_REGEX_RAW, 0, NULL); regp[USER] = g_regex_new(P_USER, 0, 0, NULL); regp[CHANNEL_WASSR] = g_regex_new(P_CHANNEL, 0, 0, NULL); + regp[TAG_TWITTER] = g_regex_new(P_TAG_TWITTER, 0, 0, NULL); regp[TAG_IDENTICA] = g_regex_new(P_TAG_IDENTICA, 0, 0, NULL); regp[GROUP_IDENTICA] = g_regex_new(P_GROUP_IDENTICA, 0, 0, NULL); regp[IMAGE_TWITTER] = g_regex_new(P_IMAGE_TWITTER, 0, 0, NULL);
--- a/pidgin-twitter.h Thu Apr 09 13:12:45 2009 +0900 +++ b/pidgin-twitter.h Thu Apr 16 17:12:53 2009 +0900 @@ -38,6 +38,7 @@ PSEUDO, USER, CHANNEL_WASSR, + TAG_TWITTER, TAG_IDENTICA, GROUP_IDENTICA, IMAGE_TWITTER, @@ -159,6 +160,7 @@ #define SENDER_FORMAT_JISKO "%s<a href='http://jisko.net/%s'>%s</a>: " #define CHANNEL_FORMAT_WASSR "%s<a href='http://wassr.jp/channel/%s'>%s</a> " #define CHANNEL_FORMAT_IDENTICA "%s<a href='http://identi.ca/tag/%s'>%s</a> " +#define TAG_FORMAT_TWITTER "<a href='http://twitter.com/search?q=%%23%s'>#%s</a>" #define TAG_FORMAT_IDENTICA "#<a href='http://identi.ca/tag/%s'>%s</a>" #define GROUP_FORMAT_IDENTICA "!<a href='http://identi.ca/group/%s'>%s</a>" @@ -173,6 +175,7 @@ #define P_PSEUDO "^\\s*(?:[\"#$%&'()*+,\\-./:;<=>?\\[\\\\\\]_`{|}~]|[^\\s\\x21-\\x7E])*([dDfFgGlLmMnNtTwW]{1})(?:\\Z|\\s+|[^\\x21-\\x7E]+\\Z)" #define P_USER "^.*?(?:<a .+?>)?([-A-Za-z0-9_]+)(?:</a>)?:" #define P_CHANNEL "^(.*?(?:<a .+?>)?[-A-Za-z0-9_]+(?:</a>)?: \\r?\\n?#)([A-Za-z0-9_]+) " +#define P_TAG_TWITTER "#([-A-Za-z0-9_]+)" #define P_TAG_IDENTICA "#([-A-Za-z0-9_]+)" #define P_GROUP_IDENTICA "!([-A-Za-z0-9_]+)" #define P_IMAGE_TWITTER "<img .*=\"profile-(?:image|img)\".*src=\"(https?://.+?)\".*/>"