IRC Bot

Just starting out? Need help? Post your questions and find answers here.
oToom
User
User
Posts: 54
Joined: Sat May 03, 2008 5:38 pm

IRC Bot

Post by oToom »

Well, I am working on an irc bot.
I have this so far.

Code: Select all

OpenConsole()

If InitNetwork() = 0
  PrintN("Error, Can't initialize the network.")
EndIf 

Port = 6667
ConnectionID = OpenNetworkConnection("irc.raw-net.com", Port)

If ConnectionID

  Nick$ = "nwBot"
  Channel$ = "#rawnet"
  Databuffer.s=""
  DataBufferLength.w=1024
  
    SendNetworkString(ConnectionID, "NICK"+Nick$+Chr(13)+Chr(10))
    SendNetworkString(ConnectionID, "USER blah 8 * : blah"+Chr(13)+Chr(10))
    SendNetworkString(ConnectionID, "JOIN"+Channel$+Chr(13)+Chr(10))
    
      While 1 
        If NetworkClientEvent(ConnectionID)=2
          Result = ReceiveNetworkData(ConnectionID, @DataBuffer, DataBufferLength)
          PrintN(Databuffer)
        EndIf
      Wend


EndIf



End
COuld someone help me just do a simple command, Ping / Pong. Because this times out everytime it connects.
Thank you.

Also, just on a side note. In the console it says its connected, then times out.
Yet the bot is not actually joined the channel.

Thanks to anyone that can help me.

Need-Help:
Ping / Pong.
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Maybe this helps you:

http://www.purebasic.fr/english/viewtop ... hlight=irc

I use this procedures with success. If a PiNG-Request arrive you, you just have to send a PONG.

In my code it looks like this:

Code: Select all

    If Left(Commands(),4)="PING"
      SendNetworkString(NetID,ReplaceString(Commands(),"PING","PONG")+#NewLine)
    EndIf
Tranquil
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Still trying to disrupt MSN huh! :lol:
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
oToom
User
User
Posts: 54
Joined: Sat May 03, 2008 5:38 pm

Post by oToom »

Wtf, how has this got anything to do with msn?

This is an irc bot.
Eventually it will have commands such as, !google (query here)
And it will give the first 3 searches, At the moment i have no clue on how to go about doing this but hey.

At the moment i want it just to say stuff like, when someone says hello, it will greet them back.

So i do not know how this has anything to do with msn?
Explain to me. Go for it.
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Post by LuCiFeR[SD] »

hehehe, I have to agree with Rook, it does (from a casual observers perspective) look very suspicious :P

one minute it is MSN style malware you want to play with... then IRC... So what is it this time... a botnet?

But if you REALLY want to know how it all works... http://www.irchelp.org/irchelp/rfc/rfc.html

Actually.... you could download eggdrop or winbot, both have source code available for your browsing pleasure... why reinvent the wheel?
oToom
User
User
Posts: 54
Joined: Sat May 03, 2008 5:38 pm

Post by oToom »

I know what happens,
I code irc bots sometimes in perl.

But i don't know how to do it in purebasic.

And lol. A botnet? Seriously, if i wanted to, i would do it in C++ or something?


Anyway, no, this has nothing to do with malware. I just want a fricken irc bot working. Yet if you aren't up for helping. I'm off. Cya'z
maw

Post by maw »

Well, you have made 2 critical errors in your code. The first is when you send "NICK"+Nick$+Chr(13)+Chr(10) this will send NICKnwBot, you need a space! "NICK "+Nick$+Chr(13)+Chr(10), same goes for the join command.

The second mistake is the databuffer. You never allocate one! You need to either do a Databuffer.s = space(1024) or use AllocateMemory().

With those 2 fixed I'm sure you're gonna be able to continue a little easier.
oToom
User
User
Posts: 54
Joined: Sat May 03, 2008 5:38 pm

Post by oToom »

Ah, well. It joins fine now. And has yet to time out.

I didn't need the allocatememory thing in the end, or not as far as it goes. Not to mention i don't know hardly anything about pureBASIC.
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Post by Rook Zimbabwe »

Allocating memory will help if you get many requests at once... you can hold them there and parse them at your leisure.
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
oToom
User
User
Posts: 54
Joined: Sat May 03, 2008 5:38 pm

Post by oToom »

Well, i will try whatever! Lol!
Post Reply