From a1f5e5a248c7efb7811f8fbc5d637538e940ee66 Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Sun, 26 Apr 2009 13:53:18 +0200 Subject: [PATCH] _flag_disable_fetch_twitter_friends --- world/net/irc/user.c | 2 +- world/net/twitter/listing.c | 22 ++++++++++++++-------- world/net/twitter/polly.c | 22 +++++++++++++++++----- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/world/net/irc/user.c b/world/net/irc/user.c index edbd371..f88e28c 100644 --- a/world/net/irc/user.c +++ b/world/net/irc/user.c @@ -414,7 +414,7 @@ w(string mc, string data, mapping vars, mixed source) { # ifdef ALIASES if (raliases[source]) { nick2 = raliases[source]; -# if 0 +# if 0 // no longer works for fippo, silvy etc. vars["_INTERNAL_source_IRC"] = nick2 +"!"+ u[UNick]? u[UNick] +"@"+ u[UHost] : (vars["_nick_long"] diff --git a/world/net/twitter/listing.c b/world/net/twitter/listing.c index af90246..dae7788 100644 --- a/world/net/twitter/listing.c +++ b/world/net/twitter/listing.c @@ -10,21 +10,22 @@ volatile object fetcha; volatile mixed wurst; parse(string body) { +#ifndef _flag_disable_fetch_twitter_friends if (!body || body == "") { P1(("%O failed to get its listing.\n", ME)) return; } -//#if DEBUG > 0 rm(DATA_PATH "twitter/friends.json"); write_file(DATA_PATH "twitter/friends.json", body); P4((body)) -//#endif +#endif unless (pointerp(wurst = parse_json(body))) { P1(("%O failed to parse its listing.\n", ME)) return; } #ifdef DEVELOPMENT - write_file(DATA_PATH "twitter/friends.parsed", sprintf("%O\n", wurst)); + // haha.. (s)printf(): BUFF_SIZE overflowed... + //ite_file(DATA_PATH "twitter/friends.parsed", sprintf("%O\n", wurst)); #endif P1(("%O sorting %O subscription names ", ME, sizeof(wurst))) wurst = sort_array(wurst, (: @@ -47,7 +48,7 @@ htget(prot, query, headers, qs, data, noprocess) { localize(query["lang"], "html"); unless (pointerp(wurst)) { - hterror(R_TEMPOVERL, + hterror(prot, R_TEMPOVERL, "Haven't successfully retrieved data yet."); return; } @@ -98,12 +99,20 @@ htget(prot, query, headers, qs, data, noprocess) { return 1; } +#ifndef _flag_disable_fetch_twitter_friends fetch() { fetcha -> content( #'parse, 0, 1 ); fetcha -> fetch("http://twitter.com/statuses/friends.json?count=200"); } +#endif create() { +#ifdef _flag_disable_fetch_twitter_friends + string body = read_file(DATA_PATH "twitter/friends.json"); + if (body) return parse(body); + P1(("\nNo twitter/friends.json found. %O disabled.\n", ME)) + destruct(ME); +#else mapping config; object o = find_object(CONFIG_PATH "config"); @@ -113,14 +122,11 @@ create() { //destruct(ME); return 1; } - - string body = read_file(DATA_PATH "twitter/friends.json"); - if (body) return parse(body); - // we could even choose to inherit this instead... fetcha = clone_object(NET_PATH "http/fetch"); //fetcha -> sAgent(SERVER_VERSION " builtin Twitter to PSYC gateway"); fetcha -> sAuth(config["nickname"], config["password"]); call_out( #'fetch, 14 ); +#endif } diff --git a/world/net/twitter/polly.c b/world/net/twitter/polly.c index 4d4b6e6..49260ae 100644 --- a/world/net/twitter/polly.c +++ b/world/net/twitter/polly.c @@ -23,8 +23,8 @@ parse(string body, mapping headers) { return; } //#if DEBUG > 0 - rm(DATA_PATH "timeline.json"); - write_file(DATA_PATH "timeline.json", body); + rm(DATA_PATH "twitter/timeline.json"); + write_file(DATA_PATH "twitter/timeline.json", body); P4((body)) //#endif unless (pointerp(wurst = parse_json(body))) { @@ -59,9 +59,21 @@ parse(string body, mapping headers) { P4((" %O", nick)) o = find_place(nick); - // _notice_update_twitter ? - sendmsg(o, "_message_twitter", d["text"], ([ - // should i send text as _action? + // _message_twitter ? not so convincing.. a lot of the + // things are converted rss newsfeeds, and when private + // people are "chatting" over twitter, they are still + // "broadcasting" each message to a random conjunction + // of friends and strangers (we don't follow private + // twitters with this gateway!) ... thus it is quite + // appropriate that twitters are not given the same + // relevance as a _message. still you can /highlight + // particular senders in your client... + // + sendmsg(o, + // "_notice_headline_twitter", "([_nick]) [_headline]", + "_message_twitter", d["text"], + ([ + "_headline": d["text"], // should i send text as _action? "_nick": nick, // _count seems to be the better word for this "_amount_updates": p["statuses_count"],