A simple bot I made in C++ to connect to an IRC server and act as a Channel Operator.

Code:
#include <winsock2.h>
#include <stdio.h>
#include <time.h>

#define server "irc.mibbit.com"
#define port 6667
#define nick "Meh"

char chan[100] = "#Chatdom"; // YOU CAN'T DEFINE THIS, AS YOU COPY INTO IT, IT WILL CRASH...

char buff[4096]; 
char buff2[4096]; 
char tmp[4096];
char tmp2[4096];  

char *pointer;
char *message;
char *join;
char *skip;

char name[]="Defkult";
char password[]="lolbot";

int main()
{
    time_t rawtime;
    struct tm * timeinfo;

    time ( &rawtime );
    timeinfo = localtime ( &rawtime );

    
    
    WSADATA WSAData;
     if(WSAStartup(MAKEWORD(2,2),&WSAData) != NO_ERROR)
       return 0;

    SOCKET sock;
    SOCKADDR_IN sin;
    if((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET)  {
     WSACleanup();
     return 0;
   }

   LPHOSTENT host;

   if(!(host = gethostbyname(server))) {
     WSACleanup();
     return 1;
   }

    memset (&sin, 0, sizeof(sin));

    sin.sin_family = AF_INET;
    sin.sin_addr   = *((LPIN_ADDR)*host->h_addr_list);
    sin.sin_port   = htons(port);

    if(connect(sock,(LPSOCKADDR)&sin, sizeof(struct sockaddr)) == SOCKET_ERROR)
      return INVALID_SOCKET;

    memset(tmp,0,255);

    // set username
    sprintf(tmp,"USER %s \"\" \"KOr\" :%s\r\n", nick,name); // YAY NOW LOCKDOWN WONT THROW US OUT
    send(sock,tmp,strlen(tmp),0);
    memset(tmp,0,255);

    // set bot mode +B(BOT)
    //sprintf(tmp,"MODE %s +b\r\n",nick);
    //send(sock,tmp,strlen(tmp),0);
    //memset(tmp,0,255);

    // set bots nick
    sprintf(tmp,"NICK %s\r\n",nick);
    send(sock,tmp,strlen(tmp),0);
    memset(tmp,0,255);
    Sleep(100);
    
    sprintf(tmp,"NICKSERV identify %s\r\n",password);
    send(sock,tmp,strlen(tmp),0);
    memset(tmp,0,255);
    Sleep(100);

    // join chan
    sprintf(tmp,"JOIN %s\r\n",chan);
    send(sock,tmp,strlen(tmp),0);
    Sleep(100);

    printf("Join Successful\n");
    memset(tmp,0,255);
    Sleep(10);

    memset(buff,0,4096);

    while(recv(sock, buff, sizeof(buff), 0) > 0)
    {
      printf(buff); //to find out wat the shit is going wrong

     //Make so it replys to the chan the command is in..
        strcpy(buff2, buff);
        if((pointer = strtok(buff2," ")) == NULL)
         continue;
        if((pointer = strtok(NULL, " ")) == NULL)
         continue;
        if((pointer = strtok(NULL, " ")) == NULL)
         continue;

        strncpy(chan, pointer,99); // ADDED BOUNDS CHECK

        memset(buff2,0,4096);
        //free(pointer); 

        if(strncmp(buff, "PING", 4) == 0) {
            sprintf(buff, "PONG\r\n");
            send(sock, buff, sizeof(buff), 0);
            memset(buff,0,4096);
            continue;
        }

         // Test Command, just to make sure its all working....:P
        else if (strstr(buff,"*test") != NULL)
        {
            sprintf(tmp, "NOTICE %s test\r\n", name);
            send(sock,tmp,strlen(tmp),0);
            memset(buff,0,4096);
            continue;
        }
        
        else if(strstr(buff,"*offended") != NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            message = strtok(pointer, " ");
            message = strtok(NULL, "\r\n");
            sprintf(tmp, "notice %s Here is the link: http://tinyurl.com/ypu4rs\r\n",pointer);
            send(sock,tmp,strlen(tmp),0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
        }

        else if(strstr(buff,"*info") != NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            message = strtok(pointer, " ");
            message = strtok(NULL, "\r\n");
            sprintf(tmp, "notice %s Here is the link: http://micurl.com/ofr1fz\r\n",pointer);
            send(sock,tmp,strlen(tmp),0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
        }

       //Notice Command usage *notice <nick>
        else if(strstr(buff,"*notice") != NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            message = strtok(pointer, " ");
            message = strtok(NULL, "\r\n");
            sprintf(tmp, "notice %s :%s\r\n",pointer ,message);
            send(sock,tmp,strlen(tmp),0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
        }

       //Kick Command usage *kick <nick>
        else if(strstr(buff,"*kick")!=NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            sprintf(tmp, "KICK %s %s\r\n",chan ,pointer);
            send(sock,tmp,strlen(tmp),0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
        }
        
        //Inivte Command usage *invite <nick>
        else if(strstr(buff,"*invite")!=NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            sprintf(tmp, "INVITE %s %s\r\n",pointer ,chan);
            send(sock,tmp,strlen(tmp),0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
        }
        
        //Kickban Command usage *kickban <nick>
        else if(strstr(buff,"*kickban")!=NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            sprintf(tmp, "MODE +b %s\r\n",pointer);
            send(sock,tmp,strlen(tmp),0);
            Sleep(100);
            sprintf(tmp, "KICK %s %s\r\n",chan ,pointer);
            send(sock,tmp,strlen(tmp),0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
        }
        
        //unban Command usage *unban <nick>
        else if(strstr(buff,"*unban")!=NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            sprintf(tmp, "MODE -b %s %s\r\n",chan ,pointer);
            send(sock,tmp,strlen(tmp),0);
        }

        //Join Command uasge *join <channel>
        else if (strstr(buff,"*join")!=NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            sprintf(tmp, "JOIN %s\r\n",pointer);
            send(sock,tmp,strlen(tmp),0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
        }

        else if (strstr(buff,"*time")!=NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            sprintf(tmp, "NOTICE #chatdom Time@Me: %s\n",asctime(timeinfo));
            send(sock,tmp,4096,0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
            
        }
        //Private Message, usage *pm <recipient> <message>
        else if(strstr(buff,"*pm")!=NULL)
        {
            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            message = strtok(pointer, " ");
            message = strtok(NULL, "\r\n");
            sprintf(tmp, "privmsg %s :%s\r\n",pointer ,message);
            send(sock,tmp,strlen(tmp),0);
            memset(tmp,0,4096);
            memset(buff,0,4096);
            free(pointer);
        }

        //Quit Section usage *quit <die or part>
        else if (strstr(buff,"*quit")!=NULL)
        {

            pointer = strtok(buff, "*");
            pointer = strtok(NULL," ");
            pointer = strtok(NULL,"\r\n");
            message = strtok(buff, "!");
            if (message[0]==':'){
            skip = buff+1;
            }
            puts(skip);

            if(strstr(skip,name)!=NULL){

            if (strstr(pointer,"die")!=NULL)
            {
                sprintf(tmp, "QUIT Time to die...\r\n");
                send(sock,tmp,strlen(tmp),0);
                memset(tmp,0,4096);
                memset(buff,0,4096);
                free(pointer);
            }
            if (strstr(pointer,"part")!=NULL)
            {
                sprintf(tmp, "PART %s\r\n",chan);
                send(sock,tmp,strlen(tmp),0);
                memset(tmp,0,4096);
                memset(buff,0,4096);
                free(pointer);
            }
            }

            else
            {
                sprintf(tmp, "privmsg %s :Auth Required\r\n", skip);
                send(sock,tmp,strlen(tmp),0);
                memset(tmp,0,4096);
                memset(buff,0,4096);
            }
        //End Quit Section
        }
    }

    Sleep(100);
    WSACleanup();
    return 0;
}