Author Topic: Horoscope.c with daily Yahoo astrology update  (Read 5993 times)

Offline amylase

  • Friend
  • **
  • Posts: 75
    • View Profile
    • gpLand
Horoscope.c with daily Yahoo astrology update
« on: December 29, 2006, 03:20:17 PM »
Mudlib: DeadSouls 2.1 on Windows XP
Driver: MudOS v22.2b14
Filename: /secure/cmds/creators/horoscope.c

Hi guys. I've been trying to learn a bit of basics about sockets as well as string manipulation (hopefully in the future be able to come up with a chatterbot that is able to reside in MUD and also access internet resources). Anway, to start off Cratylus and Tricky suggested looking into dsversion.c which was subsequently torn apart and converted to horoscope.c by me. Cut a long story short: horoscope.c will try to extract date (in words or numbers) out of any given sentence, using that as birthday connect to Yahoo astrology, and print out whatever ridiculous advice is out there for the corresponding starsign.

Thanks everyone for answering my questions on ds channel and this forum. Feel free to do anything you please with my code. Please note socket part remains largely unchanged from the original dsversion.c

Code: [Select]
/* /secure/cmds/creators/horoscope.c
*  modified by Amylase 2006 from original dsversion.c
*  of DS2 Mudlib 2.1
*
*   Horoscope.c connects to http://HTTP_HOST/HTTP_PATH+starsign:HTTP_PORT
*   Currently it is set up to connect to port 80 of
*   http://astrology.yahoo.com/astrology/general/dailyextended/starsign where HTTP_HOST, HTTP_PATH and
*   HTTP_PORT have been pre#defined. String starsign is substituted by one of twelve starsigns
*   based on the argument supplied by initiator of this command.
*
*   A few ifs, loops and search functions in cmd() serve to extract numeric day and month out of given argument and
*   translate to appropriate string starsign for lookup.
*   Connection is negotiated by openHTTPConnection().
*   Http content is then retrieved by sendHTTPGet() and stored in the giant global string 'results'.
*   ProcessHTTPResult() explodes results into individual lines (NOTES_DELIM) and stores them in string array 'parts'.
*   ADVANCE_FROM_CAPTUREth line after first occurence of CAPTURE_STRING is printed.
*   For example in the case of Yahoo astrology, advice is 8th line after 'Provided by Astrology.com' (where
*   'Provided by Astrology.com' is zero-th line).
*
*   Syntax: horoscope [starsign | birthdate]
*   For example: 'horoscope gemini' or 'horoscope 20/6/1970' will both bring up today's advice for gemini.
*   Dates in words are also accepted. For example 'horoscope twentieth of June' yields the same result.
*   In fact you may even follow 'horoscope' with any sentence as long as it contains some sort of date to be digested.
*   For example: 'horoscope My date of birth is twentieth of June and I expect a present from you' will be accepted.
*   When conventional numeric date is supplied, dd/mm/yyyy is preferred over mm/dd/yyyy.
*   Minimal error correction mechanism has been implanted to recognise and correctly handle just over half the cases of mm/dd/yyyy.
*   When no argument is supplied, ie. simply typing 'horoscope' and enter, a random starsign will be used.
*  
* Necessary inputs/definitions:
* HTTP_HOST, HTTP_PATH, HTTP_PORT
* CAPTURE_STRING
* ADVANCE_FROM_CAPTURE
*
* Useful outputs:
* int day - day of birthdate
* int month - month of birthdate
* string starsign - corresponding starsign based on birthdate
* string results - entire html code for requested webpage
* string *words - individual words (all in small case) of the sentence after 'horoscope'
* string advice - contains the output advice
*/

#include <lib.h>
#include <network.h>
#include <socket_err.h>
#include <message_class.h>

inherit LIB_DAEMON;

#define HTTP_ADDRESS "216.109.127.241"
#define HTTP_HOST "astrology.yahoo.com"
#define HTTP_PORT 80
#define HTTP_PATH "/astrology/general/dailyextended/"
#define NOTES_DELIM "\n"
#define CAPTURE_STRING "Provided by Astrology.com"
#define ADVANCE_FROM_CAPTURE 8

#define SOCK_FIND 0
#define SOCK_CONNECTING 1
#define SOCK_CONNECTED 2
#define SOCK_DISCONNECTED 3
#define SOC_ERROR 4

int socket;
int status;
object player;
string starsign="";
string results;
string advice="";
void sendHTTPGet();
int http_file_found;

void ProcessHTTPResult()
{
    int i = 0, advance=0;
    string * parts;

    parts = explode( results, NOTES_DELIM );

    foreach(string line in parts){
if(advance>0 && advance<ADVANCE_FROM_CAPTURE+2) {advance++;}
if(advance==ADVANCE_FROM_CAPTURE+1) {player->eventPrint( ""+line); advice=line;} //This is where our final target is printed 
if(strsrch(line, CAPTURE_STRING) > -1) advance=1;
}
}

void read_callback( int fd, mixed message )
{
    if( !http_file_found ){
if( message[9..11] != "200" ){
    player->eventPrint( "Error, unable to locate page requested." );

    http_file_found = 3;
}
else
{
//     player->eventPrint( message ); Uncomment this to see http header debug
    http_file_found = 1;
}
    }
    else if( http_file_found == 1 ){
//player->eventPrint( message );
results += message;
    }
    else{

    }
}

void write_callback( int fd )
{
#ifdef _DEBUG
    player->eventPrint("Connected!");
#endif
    status = SOCK_CONNECTED;
    http_file_found = 0;
    sendHTTPGet();
}

void close_callback( int fd )
{
    if( status == SOCK_CONNECTED )
    {
// Process HTML here
#ifdef _DEBUG
player->eventPrint("Connection closed by host.");
#endif
ProcessHTTPResult();
    }
    if( status == SOCK_CONNECTING )
    {       
player->eventPrint("Connection attempt failed.");
    }
    socket_close( fd ) ;
    status = SOCK_DISCONNECTED;
}

void sendHTTPGet()
{
    string str ="GET "+HTTP_PATH+starsign+" HTTP/1.0\r\n"+
    "Host: "+HTTP_HOST+"\r\n" +
    "User-Agent: "+ player->GetName() + "@" + mud_name() + " " +
    mudlib()+ "/" + mudlib_version() +" ("+ query_os_type()+";) "+
    version() + "\r\n\r\n";
    int result = 0;
    results = "";
#ifdef _DEBUG
    player->eventPrint("Sending HTTP get request..." );
#endif
    if( status == SOCK_CONNECTED )
    {
result = socket_write( socket, (string)str );
#ifdef _DEBUG
player->eventPrint( "HTTP request sent to " + socket + " result = "+result );
#endif
    }
}

int openHTTPConnection()
{

    int sock, sc_result;
    string error;
    status = SOCK_FIND;


    status = SOCK_CONNECTING;
    sock = socket_create( STREAM, "read_callback", "close_callback" ) ;
    if (sock < 0) {
switch( sock )
{
case EEMODENOTSUPP :
    error = "Socket mode not supported.\n" ;
    break ;
case EESOCKET :
    error = "Problem creating socket.\n" ;
    break ;
case EESETSOCKOPT :
    error = "Problem with setsockopt.\n" ;
    break ;
case EENONBLOCK :
    error = "Problem with setting non-blocking mode.\n" ;
    break ;
case EENOSOCKS :
    error = "No more available efun sockets.\n" ;
    break ;
case EESECURITY :
    error = "Security violation attempted.\n" ;
    break ;
default :
    error = "Unknown error code: " + sock + ".\n" ;
    break ;
}
notify_fail( "Unable to connect, problem with socket_create.\n"
  "Reason: " + error ) ;
return 0 ;
    }
#ifdef _DEBUG
    write("Attempting to connect to "+HTTP_HOST+ " on port "+ HTTP_PORT + "\n");
#endif
    sc_result = socket_connect( sock, HTTP_ADDRESS + " " + HTTP_PORT,
      "read_callback", "write_callback" ) ;
    if( sc_result != EESUCCESS )
    {
status = SOCK_DISCONNECTED;
notify_fail( "Failed to connect.\n" ) ;
return 0 ;
    }
    else{
#ifdef _DEBUG
player->eventPrint( "Socket connecting..." );
#endif
    }

    socket = sock;
    return 1;
}

void hostResolved( string address, string resolved, int key )
{
    if( !resolved ){
#ifdef _DEBUG
player->eventPrint( "Unable to resolve "+address );
#endif
return;
    }
#ifdef _DEBUG
    player->eventPrint( "Resolved "+address+" to "+ resolved );
#endif
    player->eventPrint( "Retrieving updated release notes from: http://www.dead-souls.net\n" );
    openHTTPConnection();
}

void resolveHost()
{
    resolve( HTTP_HOST, "hostResolved" );
}

mixed cmd(string args) {
string arg1="",s1="",s2="";
int j=0, k=1, day=0, month=0;
string *months = ({ "","january", "february","march","april","may","june","july","august","september","october", "november","december"});
string *days = ({"","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelvethe","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth","twentieth","twenty-first","twenty-second","twenty-third","twenty-fourth","twenty-fifth","twenty-sixth","twenty-seventh","twenty-eighth","twenty-nineth","thirtieth", "thirty-first"});
string *signsarr = ({ "","aries", "taurus","gemini","cancer","leo","virgo","libra","scorpio","sagittarius","capricorn","aquarius","pisces" });
string * words;
string * subdate;

    player = previous_object();
    if(args) {
arg1 = lower_case(args);
// player->eventPrint( "Complete argument = "+arg1);
words = explode(arg1," ");

//player->eventPrint("Word "+j+" = "+words[j]);

// Extracts day and month out of a birthday that may have been given in words
for(k=1;k<13;k++){  if( member_array(months[k], words) > -1 ) month=k;
if( member_array(signsarr[k], words) > -1 ) starsign=signsarr[k];
}
for(k=1;k<32;k++) if( member_array(days[k], words) > -1 || member_array(replace_string(days[k],"-",""), words) > -1) day=k;

// Extracts numeric day and month out of a birthday given in the format of dd/mm or mm/dd
for(j=0;j<sizeof(words);j++) {
if(sscanf(words[j],"%s/%s",s1,s2)>0){
subdate=explode(words[j],"/");
day=atoi(s1);
month=atoi(subdate[1]);
if(month>12) {day=month; month=atoi(s1);} //Here's my half-hearted effort at correcting some cases of mm-dd-yy
}//end sscanfif
}//endfor

/* if(month>0 && day>0) player->eventPrint("DAY ="+day+"       MONTH="+month);
>0 makes sure both month and day are both valid numbers and not other incidental strings or nothing  */

// Determine starsign from date of birth
if( (month==3 && day>=21) || (month==4 && day<=19)) {starsign="aries";} //Aries 21/3 - 19/4
if( (month==4 && day>=20) || (month==5 && day<=20)) {starsign="taurus";} //Taurus 20/4 - 20/5
if( (month==5 && day>=21) || (month==6 && day<=21)) {starsign="gemini";} //Gemini 21/5 - 21/6
if( (month==6 && day>=22) || (month==7 && day<=22)) {starsign="cancer";} //Cancer 22/6 - 22/7
if( (month==7 && day>=23) || (month==8 && day<=22)) {starsign="leo";} //Leo 23/7 - 22/8
if( (month==8 && day>=23) || (month==9 && day<=22)) {starsign="virgo";} //Virgo 23/8 - 22/9
if( (month==9 && day>=23) || (month==10 && day<=22)) {starsign="libra";} //Libra 23/9 - 22/10
if( (month==10 && day>=23) || (month==11 && day<=21)) {starsign="scorpio";} //Scorpio 23/10 - 21/11
if( (month==11 && day>=22) || (month==12 && day<=21)) {starsign="sagittarius";} //Sagittarius 22/11 -21/12
if( (month==12 && day>=22) || (month==1 && day<=19)) {starsign="capricorn";} //Capricorn 22/12 - 19/1
if( (month==1 && day>=20) || (month==2 && day<=18)) {starsign="aquarius";} //Aquarius 20/1 - 18/2
if( (month==2 && day>=19) || (month==3 && day<=20)) {starsign="pisces";} //Pisces 19/2 - 20/3

// player->eventPrint("Starsign = "+starsign);

} //endifargs
    else {starsign = signsarr[random(12)];} //Assign random starsign for nil argument

    //resolveHost();
    openHTTPConnection();
    return 1;
}

string GetErorMessage() {
    return "There was a problem";
}

string GetHelp() {
    return (
  "/secure/cmds/creators/horoscope.c \n\n"+
  "Shows today's advice from Yahoo astrology\n"+
  "Syntax: horoscope [starsign | birthdate (in words or dd/mm/yyyy) | any sentence that contains either starsign or birthdate]\n"+
  "Nil paramater for random advice.");
}
« Last Edit: January 08, 2007, 07:31:46 PM by amylase »

Offline amylase

  • Friend
  • **
  • Posts: 75
    • View Profile
    • gpLand
Re: Horoscope.c with daily Yahoo astrology update
« Reply #1 on: February 12, 2009, 02:31:16 AM »
Updated code to work with Yahoo's new astrology website http://astrology.shine.yahoo.com/astrology
Same old story - save the following code as /secure/cmds/creators/horoscope.c
Issue command "horoscope" or "horoscope <starsign>" or "horoscope <date of birth>" as wizard to view today's suggestions.

Code: [Select]
/*
*  Mudlib: DeadSouls 2.8 on Windows Vista
*  Driver: FluffOS v2.12-d
*  Filename: /secure/cmds/creators/horoscope.c
*  Modified by Amylase 2009 from original dsversion.c
*  of DS2 Mudlib 2.1

*  Horoscope.c will try to extract date (in words or numbers) out of any given
*  sentence, using that as birthday connect to Yahoo astrology, and print out whatever ridiculous advice is out there for
*  the corresponding starsign.

*  Thanks everyone for answering my questions on ds channel and this forum.
*  Please note socket part remains largely unchanged from the original dsversion.c
*
*   Horoscope.c connects to http://HTTP_HOST/HTTP_PATH+starsign+"/daily-extended/":HTTP_PORT
*   Currently it is set up to connect to port 80 of
*   http://astrology.shine.yahoo.com/astrology/starsign/daily-extended  where HTTP_HOST, HTTP_PATH and
*   HTTP_PORT have been pre#defined. String starsign is substituted by one of twelve starsigns
*   based on the argument supplied by initiator of this command. To spell thigns out:
* HTTP_HOST = astrology.shine.yahoo.com
* HTTP_PATH = /astrology/
* HTTP_PORT = 80
* The bit on "/daily-extended/" is like second part of http_path. Whatever starsign you are after, the starsign is wedged
* between "/astrology/" and "/daily-extended/" in this case. For example this exact
* address "http://astrology.shine.yahoo.com/astrology/gemini/daily-extended" would open up the page with something on
* gemini for the day.
*
*   A few ifs, loops and search functions in cmd() serve to extract numeric day and month out of given argument and
*   translate to appropriate string starsign for lookup.
*   Connection is negotiated by openHTTPConnection().
*   Http content is then retrieved by sendHTTPGet() and stored in the giant global string 'results'.
*   ProcessHTTPResult() explodes results into individual lines (NOTES_DELIM) and stores them in string array 'parts'.
*   ADVANCE_FROM_CAPTUREth line after first occurence of CAPTURE_STRING is printed.
*   For example in the case of Yahoo astrology, advice is 8th line after 'Provided by Astrology.com' (where
*   'Provided by Astrology.com' is zero-th line).
*   Just a side caution. Be careful with the HTTP/1.0\r\n in sendHTTPGet() , there is a space just before HTTP/1.0\r\n. I accidentally
*   left it out before and took me a long time to discover.
*
*   Syntax: horoscope [starsign | birthdate]
*   For example: 'horoscope gemini' or 'horoscope 20/6/1970' will both bring up today's advice for gemini.
*   Dates in words are also accepted. For example 'horoscope twentieth of June' yields the same result.
*   In fact you may even follow 'horoscope' with any sentence as long as it contains some sort of date to be digested.
*   For example: 'horoscope My date of birth is twentieth of June and I expect a present from you' will be accepted.
*   When conventional numeric date is supplied, dd/mm/yyyy is preferred over mm/dd/yyyy.
*   Minimal error correction mechanism has been implanted to recognise and correctly handle just over half the cases of mm/dd/yyyy.
*   When no argument is supplied, ie. simply typing 'horoscope' and enter, a random starsign will be used.
*  
* Necessary inputs/definitions:
* HTTP_HOST, HTTP_PATH, HTTP_PORT
* CAPTURE_STRING
* ADVANCE_FROM_CAPTURE
*
* Useful outputs:
* int day - day of birthdate
* int month - month of birthdate
* string starsign - corresponding starsign based on birthdate
* string results - entire html code for requested webpage
* string *words - individual words (all in small case) of the sentence after 'horoscope'
* string advice - contains the output advice
*/

#include <lib.h>
#include <network.h>
#include <socket_err.h>
#include <message_class.h>

inherit LIB_DAEMON;

#define HTTP_ADDRESS "66.196.85.39"
#define HTTP_HOST "astrology.shine.yahoo.com"
#define HTTP_PORT 80
#define HTTP_PATH "/astrology/"

#define NOTES_DELIM "\n"
#define CAPTURE_STRING "Provided by <a href="
#define FINAL_SLICE "<h3>Overview</h3><p>"
#define ADVANCE_FROM_CAPTURE 24

#define SOCK_FIND 0
#define SOCK_CONNECTING 1
#define SOCK_CONNECTED 2
#define SOCK_DISCONNECTED 3
#define SOC_ERROR 4

int socket;
int status;
object player;
string starsign="";
string results;
string advice="";
void sendHTTPGet();
int http_file_found;

void ProcessHTTPResult()
{
    int i = 0, advance=0;
    string * parts;
string * final;

    parts = explode( results, NOTES_DELIM );

    foreach(string line in parts){
if(advance>0 && advance<ADVANCE_FROM_CAPTURE+2) {advance++;}
if(advance==ADVANCE_FROM_CAPTURE+1) {
final = explode( line, FINAL_SLICE);
line = final[1];
player->eventPrint( ""+line); advice=line;
} //This is where our final target is printed 
if(strsrch(line, CAPTURE_STRING) > -1) advance=1;
}
}

void read_callback( int fd, mixed message )
{
    if( !http_file_found ){
if( message[9..11] != "200" ){
    player->eventPrint( "Error, unable to locate page requested." );

    http_file_found = 3;
}
else
{
//     player->eventPrint( message ); Uncomment this to see http header debug
    http_file_found = 1;
}
    }
    else if( http_file_found == 1 ){
//player->eventPrint( message );
results += message;
    }
    else{

    }
}

void write_callback( int fd )
{
#ifdef _DEBUG
    player->eventPrint("Connected!");
#endif
    status = SOCK_CONNECTED;
    http_file_found = 0;
    sendHTTPGet();
}

void close_callback( int fd )
{
    if( status == SOCK_CONNECTED )
    {
// Process HTML here
#ifdef _DEBUG
player->eventPrint("Connection closed by host.");
#endif
ProcessHTTPResult();
    }
    if( status == SOCK_CONNECTING )
    {       
player->eventPrint("Connection attempt failed.");
    }
    socket_close( fd ) ;
    status = SOCK_DISCONNECTED;
}

void sendHTTPGet()
{
    string str ="GET "+HTTP_PATH+starsign+"/daily-extended/ HTTP/1.0\r\n"+
    "Host: "+HTTP_HOST+"\r\n" +
    "User-Agent: "+ player->GetName() + "@" + mud_name() + " " +
    mudlib()+ "/" + mudlib_version() +" ("+ query_os_type()+";) "+
    version() + "\r\n\r\n";
    int result = 0;
    results = "";
#ifdef _DEBUG
    player->eventPrint("Sending HTTP get request..." );
#endif
    if( status == SOCK_CONNECTED )
    {
result = socket_write( socket, (string)str );
#ifdef _DEBUG
player->eventPrint( "HTTP request sent to " + socket + " result = "+result );
#endif
    }
}

int openHTTPConnection()
{
    int sock, sc_result;
    string error;
    status = SOCK_FIND;

    status = SOCK_CONNECTING;
    sock = socket_create( STREAM, "read_callback", "close_callback" ) ;
    if (sock < 0) {
switch( sock )
{
case EEMODENOTSUPP :
    error = "Socket mode not supported.\n" ;
    break ;
case EESOCKET :
    error = "Problem creating socket.\n" ;
    break ;
case EESETSOCKOPT :
    error = "Problem with setsockopt.\n" ;
    break ;
case EENONBLOCK :
    error = "Problem with setting non-blocking mode.\n" ;
    break ;
case EENOSOCKS :
    error = "No more available efun sockets.\n" ;
    break ;
case EESECURITY :
    error = "Security violation attempted.\n" ;
    break ;
default :
    error = "Unknown error code: " + sock + ".\n" ;
    break ;
}
notify_fail( "Unable to connect, problem with socket_create.\n"
  "Reason: " + error ) ;
return 0 ;
    }
#ifdef _DEBUG
    write("Attempting to connect to "+HTTP_HOST+ " on port "+ HTTP_PORT + "\n");
#endif
    sc_result = socket_connect( sock, HTTP_ADDRESS + " " + HTTP_PORT,
      "read_callback", "write_callback" ) ;
    if( sc_result != EESUCCESS )
    {
status = SOCK_DISCONNECTED;
notify_fail( "Failed to connect.\n" ) ;
return 0 ;
    }
    else{
#ifdef _DEBUG
player->eventPrint( "Socket connecting..." );
#endif
    }

    socket = sock;
    return 1;
}

void hostResolved( string address, string resolved, int key )
{
    if( !resolved ){
#ifdef _DEBUG
player->eventPrint( "Unable to resolve "+address );
#endif
return;
    }
#ifdef _DEBUG
    player->eventPrint( "Resolved "+address+" to "+ resolved );
#endif
    player->eventPrint( "Retrieving updated release notes from: http://www.dead-souls.net\n" );
    openHTTPConnection();
}

void resolveHost()
{
    resolve( HTTP_HOST, "hostResolved" );
}

mixed cmd(string args) {
string arg1="",s1="",s2="";
int j=0, k=1, day=0, month=0;
string *months = ({ "","january", "february","march","april","may","june","july","august","september","october", "november","december"});
string *days = ({"","first","second","third","fourth","fifth","sixth","seventh","eighth","ninth","tenth","eleventh","twelvethe","thirteenth","fourteenth","fifteenth","sixteenth","seventeenth","eighteenth","nineteenth","twentieth","twenty-first","twenty-second","twenty-third","twenty-fourth","twenty-fifth","twenty-sixth","twenty-seventh","twenty-eighth","twenty-nineth","thirtieth", "thirty-first"});
string *signsarr = ({ "","aries", "taurus","gemini","cancer","leo","virgo","libra","scorpio","sagittarius","capricorn","aquarius","pisces" });
string * words;
string * subdate;

    player = previous_object();
    if(args) {
arg1 = lower_case(args);
// player->eventPrint( "Complete argument = "+arg1);
words = explode(arg1," ");

//player->eventPrint("Word "+j+" = "+words[j]);

// Extracts day and month out of a birthday that may have been given in words
for(k=1;k<13;k++){  if( member_array(months[k], words) > -1 ) month=k;
if( member_array(signsarr[k], words) > -1 ) starsign=signsarr[k];
}
for(k=1;k<32;k++) if( member_array(days[k], words) > -1 || member_array(replace_string(days[k],"-",""), words) > -1) day=k;

// Extracts numeric day and month out of a birthday given in the format of dd/mm or mm/dd
for(j=0;j<sizeof(words);j++) {
if(sscanf(words[j],"%s/%s",s1,s2)>0){
subdate=explode(words[j],"/");
day=atoi(s1);
month=atoi(subdate[1]);
if(month>12) {day=month; month=atoi(s1);} //Here's my half-hearted effort at correcting some cases of mm-dd-yy
}//end sscanfif
}//endfor

/* if(month>0 && day>0) player->eventPrint("DAY ="+day+"       MONTH="+month);
>0 makes sure both month and day are both valid numbers and not other incidental strings or nothing  */

// Determine starsign from date of birth
if( (month==3 && day>=21) || (month==4 && day<=19)) {starsign="aries";} //Aries 21/3 - 19/4
if( (month==4 && day>=20) || (month==5 && day<=20)) {starsign="taurus";} //Taurus 20/4 - 20/5
if( (month==5 && day>=21) || (month==6 && day<=21)) {starsign="gemini";} //Gemini 21/5 - 21/6
if( (month==6 && day>=22) || (month==7 && day<=22)) {starsign="cancer";} //Cancer 22/6 - 22/7
if( (month==7 && day>=23) || (month==8 && day<=22)) {starsign="leo";} //Leo 23/7 - 22/8
if( (month==8 && day>=23) || (month==9 && day<=22)) {starsign="virgo";} //Virgo 23/8 - 22/9
if( (month==9 && day>=23) || (month==10 && day<=22)) {starsign="libra";} //Libra 23/9 - 22/10
if( (month==10 && day>=23) || (month==11 && day<=21)) {starsign="scorpio";} //Scorpio 23/10 - 21/11
if( (month==11 && day>=22) || (month==12 && day<=21)) {starsign="sagittarius";} //Sagittarius 22/11 -21/12
if( (month==12 && day>=22) || (month==1 && day<=19)) {starsign="capricorn";} //Capricorn 22/12 - 19/1
if( (month==1 && day>=20) || (month==2 && day<=18)) {starsign="aquarius";} //Aquarius 20/1 - 18/2
if( (month==2 && day>=19) || (month==3 && day<=20)) {starsign="pisces";} //Pisces 19/2 - 20/3

// player->eventPrint("Starsign = "+starsign);

} //endifargs
    else {starsign = signsarr[random(12)];} //Assign random starsign for nil argument

    //resolveHost();
    openHTTPConnection();
    return 1;
}

string GetErorMessage() {
    return "There was a problem";
}

string GetHelp() {
    return (
  "/secure/cmds/creators/horoscope.c \n\n"+
  "Shows today's advice from Yahoo astrology\n"+
  "Syntax: horoscope [starsign | birthdate (in words or dd/mm/yyyy) | any sentence that contains either starsign or birthdate]\n"+
  "Nil paramater for random advice.");
}

Offline z993126

  • BFF
  • ***
  • Posts: 128
    • View Profile
Re: Horoscope.c with daily Yahoo astrology update
« Reply #2 on: September 17, 2011, 09:08:24 PM »
The current settings for this to work:

#define HTTP_ADDRESS "98.139.63.61"
#define HTTP_HOST "shine.yahoo.com"

Offline amylase

  • Friend
  • **
  • Posts: 75
    • View Profile
    • gpLand
Re: Horoscope.c with daily Yahoo astrology update
« Reply #3 on: October 27, 2011, 05:01:12 AM »
Thanks z993126. Glad somebody is keeping it up to date :D