Merge commit 'origin'

This commit is contained in:
psyc://psyced.org/~lynX 2009-04-27 16:52:13 +02:00
commit 1541bb7ca3
3 changed files with 32 additions and 14 deletions

View File

@ -414,7 +414,7 @@ w(string mc, string data, mapping vars, mixed source) {
# ifdef ALIASES # ifdef ALIASES
if (raliases[source]) { if (raliases[source]) {
nick2 = raliases[source]; nick2 = raliases[source];
# if 0 # if 0 // no longer works for fippo, silvy etc.
vars["_INTERNAL_source_IRC"] = nick2 +"!"+ vars["_INTERNAL_source_IRC"] = nick2 +"!"+
u[UNick]? u[UNick] +"@"+ u[UHost] u[UNick]? u[UNick] +"@"+ u[UHost]
: (vars["_nick_long"] : (vars["_nick_long"]

View File

@ -10,21 +10,22 @@ volatile object fetcha;
volatile mixed wurst; volatile mixed wurst;
parse(string body) { parse(string body) {
#ifndef _flag_disable_fetch_twitter_friends
if (!body || body == "") { if (!body || body == "") {
P1(("%O failed to get its listing.\n", ME)) P1(("%O failed to get its listing.\n", ME))
return; return;
} }
//#if DEBUG > 0
rm(DATA_PATH "twitter/friends.json"); rm(DATA_PATH "twitter/friends.json");
write_file(DATA_PATH "twitter/friends.json", body); write_file(DATA_PATH "twitter/friends.json", body);
P4((body)) P4((body))
//#endif #endif
unless (pointerp(wurst = parse_json(body))) { unless (pointerp(wurst = parse_json(body))) {
P1(("%O failed to parse its listing.\n", ME)) P1(("%O failed to parse its listing.\n", ME))
return; return;
} }
#ifdef DEVELOPMENT #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 #endif
P1(("%O sorting %O subscription names ", ME, sizeof(wurst))) P1(("%O sorting %O subscription names ", ME, sizeof(wurst)))
wurst = sort_array(wurst, (: wurst = sort_array(wurst, (:
@ -47,7 +48,7 @@ htget(prot, query, headers, qs, data, noprocess) {
localize(query["lang"], "html"); localize(query["lang"], "html");
unless (pointerp(wurst)) { unless (pointerp(wurst)) {
hterror(R_TEMPOVERL, hterror(prot, R_TEMPOVERL,
"Haven't successfully retrieved data yet."); "Haven't successfully retrieved data yet.");
return; return;
} }
@ -98,12 +99,20 @@ htget(prot, query, headers, qs, data, noprocess) {
return 1; return 1;
} }
#ifndef _flag_disable_fetch_twitter_friends
fetch() { fetch() {
fetcha -> content( #'parse, 0, 1 ); fetcha -> content( #'parse, 0, 1 );
fetcha -> fetch("http://twitter.com/statuses/friends.json?count=200"); fetcha -> fetch("http://twitter.com/statuses/friends.json?count=200");
} }
#endif
create() { 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; mapping config;
object o = find_object(CONFIG_PATH "config"); object o = find_object(CONFIG_PATH "config");
@ -113,14 +122,11 @@ create() {
//destruct(ME); //destruct(ME);
return 1; return 1;
} }
string body = read_file(DATA_PATH "twitter/friends.json");
if (body) return parse(body);
// we could even choose to inherit this instead... // we could even choose to inherit this instead...
fetcha = clone_object(NET_PATH "http/fetch"); fetcha = clone_object(NET_PATH "http/fetch");
//fetcha -> sAgent(SERVER_VERSION " builtin Twitter to PSYC gateway"); //fetcha -> sAgent(SERVER_VERSION " builtin Twitter to PSYC gateway");
fetcha -> sAuth(config["nickname"], config["password"]); fetcha -> sAuth(config["nickname"], config["password"]);
call_out( #'fetch, 14 ); call_out( #'fetch, 14 );
#endif
} }

View File

@ -23,8 +23,8 @@ parse(string body, mapping headers) {
return; return;
} }
//#if DEBUG > 0 //#if DEBUG > 0
rm(DATA_PATH "timeline.json"); rm(DATA_PATH "twitter/timeline.json");
write_file(DATA_PATH "timeline.json", body); write_file(DATA_PATH "twitter/timeline.json", body);
P4((body)) P4((body))
//#endif //#endif
unless (pointerp(wurst = parse_json(body))) { unless (pointerp(wurst = parse_json(body))) {
@ -59,9 +59,21 @@ parse(string body, mapping headers) {
P4((" %O", nick)) P4((" %O", nick))
o = find_place(nick); o = find_place(nick);
// _notice_update_twitter ? // _message_twitter ? not so convincing.. a lot of the
sendmsg(o, "_message_twitter", d["text"], ([ // things are converted rss newsfeeds, and when private
// should i send text as _action? // 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, "_nick": nick,
// _count seems to be the better word for this // _count seems to be the better word for this
"_amount_updates": p["statuses_count"], "_amount_updates": p["statuses_count"],