#include #include #include #include #include #include "bot.h" bot::bot() { strcpy(nick,"NyX"); strcpy(server,"irc.dawnchat.org"); strcpy(canal,"#magic"); port = 6667; } bot::~bot() { } int bot::conecta() { struct hostent *he; he = gethostbyname(server); if (!he) { perror("gethostbyname"); getchar(); return 1; } struct sockaddr_in alvo; fd = socket(AF_INET,SOCK_STREAM,0); if (fd != 0) { perror("socket"); getchar(); return 1; } alvo.sin_family = AF_INET; alvo.sin_port = htons(port); alvo.sin_addr.s_addr = (struct in_addr *)he->h_addr; bzero(&(alvo.sin_zero),8); int conexao; conexao = connect(fd,(struct sockaddr *) &alvo,sizeof(alvo)); if (conexao != 0) { perror("connect"); getchar(); return 1; } }