Library tutorials & articles

A Console IRC Bot

Introduction

I'm planning to write some articles based on questions I get from fellow students. The first one is how to get on IRC with C#? . So, here it is, the first article of (hopefully) many.

Let's start by telling what IRC is. This is best done by reading the Internet Relay Chat Protocol RFC. You can find anything you want about the IRC protocol in there.

Getting on IRC is as simple as:

  • Establishing a connection.
  • Logging in.
  • Maintaining a connection and reacting to commands.

As this is an article on how to establish an IRC connection and work with the commands, I'm not going to spent any time on UI. Therefore this will be a simple Console Application ( cIRC ).

We'll make a seperate class for the IRC functions so we could re-use it later when we want to add a UI.

using System;
using System.Net;
using System.Net.Sockets;
using System.IO;

namespace System.Net {
      public class IRC {

      } /* IRC */
} /* System.Net */

Comments

  1. 19 Apr 2007 at 22:25

    i have the same error as this guy, i know this was LONG ago but i cannot figure out how to get past this !

     

    can someone please contact me

    Email:  vincecarter15x15@aol.com    

    AIM : skatecrashrepeat

    Alternative Email: Punk123@myway.com

      PLEASE I NEED THIS DESPERATELY

  2. 19 Aug 2006 at 00:08

    That is not a C# error.. It's actually an IRC error, which means you connected to the server. You need to do a few commands so that you can login/etc.

    Example:

    USER Veeresh Veeresh :Veeresh Veeresh\r\n

    NICK Veeresh\r\n

    JOIN #quakenet\r\n

    PRIVMSG #quakenet :Hey, what's up\r\n

  3. 17 Jun 2005 at 07:16

    i tried to run this application, i got following error, plz help me out.


    NOTICE AUTH :* Looking up your hostname NOTICE AUTH : Checking Ident NOTICE AUTH :** Couldn't look up your hostname :blueyonder2.uk.quakenet.org 451 * :Register first. :blueyonder2.uk.quakenet.org 451 * :Register first. :blueyonder2.uk.quakenet.org 451 * :Register first. :blueyonder2.uk.quakenet.org 451 * :Register first. :blueyonder2.uk.quakenet.org 451 * :Register first. :blueyonder2.uk.quakenet.org 451 * :Register first. ERROR :Closing Link: by blueyonder2.uk.quakenet.org (Registration Timeout) Cannot read from a closed TextReader.

  4. 22 Dec 2004 at 16:26

    please put it in vb.net form :]


    or any vb

  5. 25 Mar 2004 at 05:57

    Welcome to Developer Fusion, David!

  6. 24 Mar 2004 at 14:29
    Well, hello This is my first article here, thanks to James Crowley. Nice site you have!

    Feel free to ask me anything on my blog if you want more info.
  7. 01 Jan 1999 at 00:00

    This thread is for discussions of A Console IRC Bot.

Leave a comment

Sign in or Join us (it's free).

David Cumps

Want to stay in touch with what's going on? Follow us on twitter!