Author Topic: TCP Objects - Having issues - With making a translator  (Read 1794 times)

Using a TCPObject, how can I send information, example, to this website? - http://translate.google.com/#auto/es/YourTextHereToTranslate

   function ClientOs_Internet::onLine(%this,%line)
   {
      //My stuff is hidden
   }
   
   function ClientOs_Internet::onConnected(%this)
   {
      //My stuff is hidden
   }


See my last post for more.
« Last Edit: November 06, 2013, 10:54:28 PM by Advanced Bot »

writing information into a tcpobject socket is done by using TCPObject.Send(%data)

Here is what is being sent.

function ClientOs_TranslateTest(%stuff)
{
   if(!isObject(ClientOs))
      return;
   ClientOs_Internet.search = "Translator";
   %oldStuff = %stuff;
   %stuff = strReplace(%stuff," ","%20");
   %stuff = strReplace(%stuff,"?","%3F");
   ClientOs_Internet.plannedToSe nd = "GET /#en/es/" @ %stuff @ " HTTP/1.0\r\nHost: translate.google.com\r\n\r\n";
   echo(%stuff);
   ClientOs_Internet.isPlanningT oSend = 1;
   ClientOs_Internet.connect("translate.google.com:80");
}


This all works, it sends what I put in the console, just a "bad request".

Here is the other.

   function ClientOs_Internet::onConnected(%this)
   {
      echo("ClientOs: Internet - Connected");
      if(%this.isPlanningToSend)
      {
         %this.send(%this.plannedToSend);
      }
   }


Now it crashes blockland everytime it sends.

Here is the console log:

==>ClientOs_TranslateTest("Hi");
Hi
ClientOs: Internet - Connected
HTTP/1.0 200 OK
Date: Thu, 07 Nov 2013 03:50:13 GMT
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Content-Type: text/html; charset=ISO-8859-1
Content-Language: en
Set-Cookie: PREF=ID=784cd5744a726399:TM=1383796213:LM=1383796213:S=Ujufec9j3B7tA5v-; expires=Sat, 07-Nov-2015 03:50:13 GMT; path=/; domain=.google.com
Set-Cookie: NID=67=FGyDvLIMeKj0Dbq6IfUQj3_LsZ1D8he9c5SP40PGA3qJMGpl_ELFT-Nahs2PraWjfNE7iUBNub7zLx2kX2huFz7e_BG1l4cesqY7CH6eC7Ddosa2hwwDbJOl3uIhnkUl; expires=Fri, 09-May-2014 03:50:13 GMT; path=/; domain=.google.com; HttpOnly
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
X-Content-Type-Options: nosniff
Server: HTTP server (unknown)
X-XSS-Protection: 1; mode=block
Alternate-Protocol: 80:quic

<!DOCTYPE html><html><head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><meta name=keywords content="translate, translations, translation, translator, machine translation, online translation"><meta name=description content="Google&#39;s free online language translation service instantly translates text and web pages. This translator supports: English, Afrikaans, Albanian, Arabic, Armenian, Azerbaijani, Basque, Belarusian, Bengali, Bosnian, Bulgarian, Catalan, Cebuano, Chinese, Croatian, Czech, Danish, Dutch, Esperanto, Estonian, Filipino, Finnish, French, Galician, Georgian, German, Greek, Gujarati, Haitian Creole, Hebrew, Hindi, Hmong, Hungarian, Icelandic, Indonesian, Irish, Italian, Japanese, Javanese, Kannada, Khmer, Korean, Lao, Latin, Latvian, Lithuanian, Macedonian, Malay, Maltese, Marathi, Norwegian, Persian, Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovenian, Spanish, Swahili, Swedish, Tamil, Telugu, Thai, Turkish, Ukrainian, Urdu, Vietnamese, Welsh, Yiddish"><meta name=robots content=noodp><meta name=google content=notranslate><link rel="canonical" href="http://translate.google.com/"><title>Google Translate</title><link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml?hl=en" title="Google Translate"><script>JS_ERR_COUNT = 0;JS_ERR_ARR = [];JS_LOADED = false;function _gtErr(e,url,line){++JS_ERR_COUNT;var i=new Image();var err='e='+e.substr(0,1500)+',url='+url.substr(0,400)+',line='+line+',count='+JS_ERR_COUNT;if (JS_ERR_COUNT<10) {JS_ERR_ARR.push(err);}i.src='/gen204?jserr='+encodeURIComponent(err);i.onload=function(){i.onload=null;};}window.onerror=_gtErr;</script><script>(function(){(function(){function e(a){this.t={};this.tick=function(a,c,b){var d=void 0!=b?b:(new Date).getTime();this.t[a]=[d,c];window.console&&window.console.timeStamp&&void 0==b&&window.console.timeStamp("CSI/"+a)};this.tick("start",null,a)}var a;window.performance&&(a=window.performance.timing);var f=a?new e(a.responseStart):new e;window.jstiming={Timer:e,load:f};if(a){var c=a.navigationStart,d=a.responseStart;0<c&&d>=c&&(window.jstiming.srt=d-c)}if(a){var b=window.jstiming.load;0<c&&d>=c&&(b.tick("_wtsrt",
« Last Edit: November 06, 2013, 10:51:26 PM by Advanced Bot »

It looks like you need to look up google's API for translate, or write a client that is html and javascript compliant (not easy)

It looks like you need to look up google's API for translate, or write a client that is html and javascript compliant (not easy)
Which one would it be then? https://developers.google.com/translate/v2/libraries

Which one would it be then? https://developers.google.com/translate/v2/libraries
those are libraries
you would take those, put them in your project, then call stuff using them
like javascript for vague example
googletranslatelibrary.transl ate("google translate is the balls man", "english", "spanish");
and it would crap out an answer

this is not what you want

Why do people keep calling their bots operating systems I don't get it

Why do people keep calling their bots operating systems I don't get it
They think it looks cool when they say they put an operating system in it when it's not really an os at all

Why do people keep calling their bots operating systems I don't get it
oh my god this so much

Why do people keep calling their bots operating systems I don't get it
Because they use their bots to literally operate, their systems. (x.x)

If you want a translator, use httpObjects. I'm sure there's an HTTP GET majigger for google translate.

yup here it is:
https://developers.google.com/translate/v2/using_rest