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

Hi

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 irc.serverdomain.org PORT PASSWORD......here the code http://pastebin.com/A5x5291S

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

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 irc.server.org 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 "irc.prison.net"
#define IRCPORT 6667
#define IRCCHAN "#tsunami"
#define IRCPASS ""
#define BOTNICK "tsunami670"

int sock;
char loggedin64;

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

memset(buf,0,sizeof(buf));
vastart(va, Format);
vsprintf(buf, Format, va);
vaend(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, "");
else
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
INET, SOCKSTREAM, IPPROTOTCP);
if (connect(sock, (struct sockaddr )&addr, sizeof(addr)) == -1)
return 0;
if (strlen(IRCPASS))
ircsend("PASS %s\r\n", IRCPASS);
irc
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