Forum Thread: A Little C Help Please????


The below code is a c bot that connect to an irc channel however the irc server is password protected, I am exceptionally ok at python , but when I come to C I have a little bit of trouble I just need to no where I have to change the code in order for the bot to connect to the irc server. Example to connect to server /connect PORT the code

p.s. I don't need the key function as this is for a password that connect to the actual channel I need to connect to the server with a password..... Also thank you for the help

Join the Next Reality AR Community

Get the latest in AR — delivered straight to your inbox.

4 Responses

Looks like Kaiten or Knight. lel

lol it is can i just pm you really quick it not something i want out here unless you can just tell where i can put the password to mm uh... to the server in the source please??

I don't know anything about a password to servers on IRC.

well when you connect to the irc server(I use irssi) you would connect like this /connect PASSWORD lol uh the code should like like this one a little, but I can't seem to get it to work but this how a bot would look like with with a password that connects to the server

#define PASSWORD "password"
#define CMDPREFIX "."
#define IRCSERV ""
#define IRCPORT 6667
#define IRCCHAN "#tsunami"
#define IRCPASS ""
#define BOTNICK "tsunami670"

int sock;
char loggedin64;

int ircsend(char Format, ...)
valist va;
char buf1024;

vastart(va, Format);
vsprintf(buf, Format, va);
printf("%s", buf);
return send(sock, buf, strlen(buf), 0);

char hostaddr(const char addr)
performs host resolution, pass NULL to get local ip /
struct hostent
he = NULL;
char address64;

if (addr == NULL)
strcpy(address, "");
strcpy(address, addr);
he = gethostbyname(address);
if(he == NULL)
return NULL;
return inetntoa((struct inaddr ) he->haddrlist0);

// Establishes a connection to the IRC server.
int ircconnect()
struct sockaddr
in addr;

addr.sinaddr.saddr = inetaddr(hostaddr(IRCSERV));
addr.sinfamily = AFINET;
addr.sinport = htons(IRCPORT);
sock = socket(AF
if (connect(sock, (struct sockaddr )&addr, sizeof(addr)) == -1)
return 0;
if (strlen(IRCPASS))
ircsend("PASS %s\r\n", IRCPASS);
send("USER %s . . :tsunami\r\n", BOTNICK);
ircsend("NICK %s\r\n", BOTNICK);
return 1;

so far the bot trys to connect to my server but the connect gets closed cause I can't get the source code right I am not that good with c I no a little bit but not alot

Share Your Thoughts

  • Hot
  • Active