mirror of
https://github.com/ChronosX88/psyced.git
synced 2024-11-09 12:01:00 +00:00
babeldos updated to new API
This commit is contained in:
parent
72542a92d1
commit
dbee641b88
@ -10,13 +10,14 @@
|
||||
|
||||
#include <input_to.h>
|
||||
#include <ht/http.h>
|
||||
#include <net.h>
|
||||
#define INHERIT_CONNECT
|
||||
|
||||
start();
|
||||
babel();
|
||||
|
||||
#define CRESET start();
|
||||
inherit "net/connect";
|
||||
inherit NET_PATH "connect";
|
||||
#include <place.gen>
|
||||
|
||||
#define emit binary_message
|
||||
@ -29,7 +30,7 @@ start() {
|
||||
qInit(ME, 1000, 100);
|
||||
unless (has_con || is_con) {
|
||||
is_con = 1;
|
||||
call_out(#'connect, 0, "babelfish.altavista.com", 80);
|
||||
call_out(#'connect, 0, "babelfish.yahoo.com", 80);
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,21 +38,24 @@ escape(data) {
|
||||
return regreplace(data, "[^a-zA-Z0-9]", (: return sprintf("%%%x", $1[0]); :), 1);
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
disconnected() {
|
||||
string k;
|
||||
|
||||
//efine FMT "%~s<td bgcolor=white class=s><div style=padding:10px;>%s</div></td>%~s"
|
||||
#define FMT "%~s<input type=\"hidden\" name=\"p\" value=\"%s\">%~s"
|
||||
|
||||
has_con = 0;
|
||||
P0(("%O received %O bytes of buffer for %O\n", ME, sizeof(buffer), current))
|
||||
switch (pointerp(current) ? current[0] : "") {
|
||||
string k;
|
||||
case TRANSLATION:
|
||||
if (sscanf(buffer, "%~s<td bgcolor=white class=s><div style=padding:10px;>%s</div></td>%~s", k)) {
|
||||
krank = k;
|
||||
}
|
||||
if (sscanf(buffer, FMT, k)) krank = k;
|
||||
else krank = "und es geschah ihr als sei es von der ferne";
|
||||
#ifdef TRANSLATION2
|
||||
babel(TRANSLATION2, current[1], current[2], krank, current[4]);
|
||||
break;
|
||||
case TRANSLATION2:
|
||||
if (sscanf(buffer, "%~s<td bgcolor=white class=s><div style=padding:10px;>%s</div></td>%~s", k)) {
|
||||
krank = k;
|
||||
}
|
||||
if (sscanf(buffer, FMT, k)) krank = k;
|
||||
else krank = "und sie sah fern als sei es ein geschehen";
|
||||
#endif
|
||||
::msg(current[1], current[2], replace(krank, """, "\""), current[4]);
|
||||
default:
|
||||
@ -103,8 +107,13 @@ babel(mode, source, mc, data, mapping vars) {
|
||||
buffer = "";
|
||||
krank = 0;
|
||||
current = ({ mode, source, mc, data, vars });
|
||||
emit("GET /tr?lp=" + mode + "&urltext=" + escape(data) + " HTTP/1.1\r\n"
|
||||
"Host: babelfish.altavista.com\r\n\r\n");
|
||||
// old API
|
||||
// emit("GET /tr?lp=" + mode + "&urltext=" + escape(data) + " HTTP/1.1\r\n"
|
||||
// "Host: babelfish.altavista.com\r\n\r\n");
|
||||
// new API
|
||||
emit("GET /translate_txt?ei=UTF-8&doit=done&fr=bf-res&intl=1&lp="+
|
||||
mode +"&tt=urltext&trtext="+
|
||||
escape(data) +" HTTP/1.1\r\nHost: babelfish.yahoo.com\r\n\r\n");
|
||||
}
|
||||
|
||||
msg(source, mc, data, mapping vars) {
|
||||
|
@ -794,7 +794,12 @@ varargs mixed sendmsg(mixed target, string mc, mixed data, vamapping vars,
|
||||
showingLog, source, u);
|
||||
#endif
|
||||
case 0:
|
||||
#ifdef DEVELOPMENT
|
||||
#if 0 //def DEVELOPMENT
|
||||
// we get here when doing remote messaging
|
||||
// in xmpp.. and in fact, in net/jabber we
|
||||
// don't *know* which scheme needs to be
|
||||
// used.
|
||||
//
|
||||
raise_error("scheme 0 is a bug\n");
|
||||
//
|
||||
// TODO: we had this error, and maybe it's
|
||||
|
@ -24,11 +24,11 @@ volatile mapping share = ([
|
||||
#ifdef JABBER_PATH
|
||||
# ifndef _flag_disable_module_presence
|
||||
"jabber2avail": ([
|
||||
0 : AVAILABILITY_HERE,
|
||||
"chat" : AVAILABILITY_TALKATIVE,
|
||||
"dnd" : AVAILABILITY_BUSY,
|
||||
"away" : AVAILABILITY_DO_NOT_DISTURB,
|
||||
"xa" : AVAILABILITY_AWAY
|
||||
0 : AVAILABILITY_HERE,
|
||||
"dnd" : AVAILABILITY_BUSY, // dnd?
|
||||
"away" : AVAILABILITY_DO_NOT_DISTURB, // nearby?
|
||||
"xa" : AVAILABILITY_AWAY // "not available"
|
||||
]),
|
||||
// map to http://www.jabber.org/jeps/jep-0107.html although that
|
||||
// is more like good ole mud feelings
|
||||
|
Loading…
Reference in New Issue
Block a user