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
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"]

View File

@ -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
}

View File

@ -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"],