.NET
  Home arrow .NET arrow Page 3 - Using SmartIrc4net
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Using SmartIrc4net
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 8
    2006-08-14

    Table of Contents:
  • Using SmartIrc4net
  • IrcConnection
  • IrcCommands
  • IrcClient

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using SmartIrc4net - IrcCommands


    (Page 3 of 4 )

    The next layer is provided by theIrcCommands class. IrcCommands derives from IrcConnection, but it adds several dozen additional methods that provide shortcuts to WriteLine (though WriteLine is still available should you ever need it). We can easily modify the previous application to use IrcCommands rather than IrcConnection. First, make irc an instance of IrcCommands rather than IrcConnection:

    private  IrcCommandsirc = new  IrcCommands();

    Then, we simply have to replace two methods:

        void OnConnected(object sender, EventArgs e)
        {
            Console.WriteLine("Connected."
    );
            irc.RfcNick("CSharp", Priority
    .Critical);
            irc.RfcUser("CSharp", 0, "CSharp Bot",
    Priority
    .Critical);
            irc.RfcJoin(channel);
            irc.Listen();
        }

        void OnReadLine(object sender, ReadLineEventArgs e)
        {
            if (e.Line.StartsWith("PING"
    ))
            {
                string server = e.Line.Split(' '
    )[1];
                irc.RfcPong(server, Priority
    .Critical);
                Console.WriteLine("Responded to ping at {0}.",
    DateTime
    .Now.ToShortTimeString());
            }
        }

    There, our application now makes use of the new methods provided by IrcCommands. IrcCommands also defines a number of other methods, including methods such as Ban, Voice and Deop. These methods are pretty straightforward, but the SendMessage method is worth taking a look at. It requires three arguments, but it can also take an additional fourth argument containing a member of the Priority enumeration. Here are a few examples of the SendMessage method in use:

            irc.SendMessage(SendType.Message, "Peyton", "Hello.");
            irc.SendMessage(SendType.Message, channel, "Hello,
    channel."
    , Priority
    .BelowMedium);
            irc.SendMessage(SendType.Action, channel, "dances"
    );
            irc.SendMessage(SendType.Notice, "Peyton", "THIS IS A
    NOTICE."
    );
            irc.SendMessage(SendType.CtcpRequest, "Peyton",
    "VERSION");

            // Convert the time to a UNIX timestamp
            TimeSpan timestamp = (DateTime.UtcNow - new  DateTime
    (1970, 1, 1));
            irc.SendMessage(SendType.CtcpReply, "Peyton", "PING"+
    (
    int)timestamp.TotalSeconds);

    More .NET Articles
    More By Peyton McCullough


       · Working with IRC might not be productive on, say, a business scale, but I've always...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
    Stay green...Green IT