IRC-Bot problem



  • Hi,
    also ich bin grade dabei einen ircbot zu programmieren.
    Er kann zu allen netzwerken connecten, auch zum euirc(irc.euirc.net), doch da nur zu einem bestimmten server(irc.lanlos.org), da ich sonts folgenden fehler bekomme:

    NOTICE ZeroBot17 :*** If you are having problems connecting due to ping timeouts
    , please type /notice 307BC74E nospoof now.
    
    PING :307BC74E
    7 :*** If you are having problems connecting due to ping timeouts, please type /
    notice 307BC74E nospoof now.
    
    :irc.ber.de.euirc.net 451 * :You have not registered
    
    :irc.ber.de.euirc.net 451 * :You have not registered
    

    Wiso geht es nur bei diesem einen bestimmten irc-server ?
    hier mal mein source:

    #pragma warning(disable: 4786)
    #pragma comment(lib, "Ws2_32.lib") // Library
    
    #include <iostream> 
    #include <string> 
    #include <winsock2.h> 
    #include <fstream>   
    
    using namespace std; // std::
    
    void auswerten(std::string received, SOCKET sock);
    string getConfig(string suchwort);
    
    int main()
    {
    
        WSADATA		wsaData;
    	SOCKET		sock;
    	sockaddr_in servaddr; // Hier Informationen über Server angeben, zu dem connected werden soll
        string SendData; // Das wollen wir später mal senden
     	if (WSAStartup (MAKEWORD(1, 1), &wsaData) != 0)
         return -1; // Fehler
     	sock = socket(AF_INET, SOCK_STREAM, 0);
     	servaddr.sin_family		 = AF_INET;
     	servaddr.sin_port		 = htons(6667);
     	servaddr.sin_addr.s_addr = inet_addr("80.190.103.254");
     	connect(sock, (sockaddr*) &servaddr, sizeof(sockaddr));
    
    	SendData = "USER test localhost localhost ZeroMan\r\n";     
     	send(sock, SendData.c_str(), SendData.length(), 0);        
        SendData = "NICK ZeroBot17\r\n";                           
     	send(sock, SendData.c_str(), SendData.length(), 0);          
    
    	char buf[2048];
        ZeroMemory(buf, sizeof(buf));
     	recv(sock, buf, sizeof(buf), 0);
     	cout << buf << endl;
     	SendData = "JOIN #it-security\r\n";                          	send(sock, SendData.c_str(), SendData.length(), 0);
     	recv(sock, buf, sizeof(buf), 0);
     	cout << buf << endl;
     	SendData = "PRIVMSG #it-security :Hi @ all\r\n";            message
     	send(sock, SendData.c_str(), SendData.length(),  0);
    
    	string angekommen;
    	while(1) {
        int lenght=recv(sock, buf, sizeof(buf) -1, 0);
          buf[lenght] = '\0';
    	  if(strncmp(buf, "PING", 4) == 0) { buf[1] = 'O'; send(sock, buf, strlen(buf), 0);cout << "PING?.....PONG!\n";}
          auswerten(buf, sock);
    	}
    
    	cin.peek();
     	cin.ignore(2, '\n'); // Usereingabe zum Beenden abwarten
     	closesocket(sock); // und gut ist
    
     	return 1; // alles klatt gelaufen.. hoffentlich :)
    }
    
    void auswerten(std::string received, SOCKET sock)
    {
        cout << received << endl;
    }
    
    string getConfig(std::string suchwort)
    {
            ifstream configFile("c:\\itbot.conf");
            if (!configFile.is_open()) {
                    cerr << "Error !";
                    return suchwort;
            }
    		string word;
            while(configFile) {
                    configFile >> word;
    
                    if (word == suchwort) {
                            string ergebnis;
                            configFile >> ergebnis;
                            return ergebnis;
                    }                
    
            }
    	string error = "error!";
    	return error;
    }
    


  • Eventuall daran ? :

    You have not registered



  • Du musst erst den PING beantworten. Ich seh aber beim besten Willen nicht, was das mit C++ zu tun hat.



  • Dieser Thread wurde von Moderator/in HumeSikkins aus dem Forum C++ in das Forum Rund um die Programmierung verschoben.

    Im Zweifelsfall bitte auch folgende Hinweise beachten:
    C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?

    Dieses Posting wurde automatisch erzeugt.



  • OT: fuer java gibts ne komplett fertige API: pircbot. hab ich auch hergenommen. echt super :>


Anmelden zum Antworten