Python
  Home arrow Python arrow Page 2 - IRC on a Higher Level Continued
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
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? 
PYTHON

IRC on a Higher Level Continued
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2005-10-19

    Table of Contents:
  • IRC on a Higher Level Continued
  • More Action Methods
  • Client-To-Client Protocol
  • Sending to Another Client

  • 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


    IRC on a Higher Level Continued - More Action Methods


    (Page 2 of 4 )

    In case you need to see what time it is according to the server, you can use the time method. You simply call it, passing no arguments:

    ...
    server.time()
    ...

    The server replies with a “391” message. By looking through the list I gave you earlier, you will find that this equates to the “time” code.

    If we need to know the administrator of a certain server, we can use the admin method. It simply sends an “ADMIN” command to the server, and the server sends back the appropriate information. The admin method takes no arguments:

    ...
    server.admin()
    ...

    We can get more information about the server by using the “INFO” command, which is called by the corresponding method, info. Like the admin method, the info method takes no arguments:

    ...
    server.info()
    ...

    The message of the day may be retreived using the motd method:

    ...
    server.motd()
    ...

    A list of channels might prove extremely useful to your application. For example, let's say your application needed to join channels with over 20 users, or let's say that your application always needed to be in the most popular channel on the network. The list method may be used, which issues the “LIST” command to the server, and the server's response can be caught by setting handlers for the events “LISTSTART”, “LIST” and “LISTEND”:

    ...
    server.list()
    ...

    If you need to examine the topic of a channel, you can send a “TOPIC” command with the topic method:

    ...
    server.topic ( '#channel' )
    ...

    If you are a channel operator, you may also use the list method to set the topic of a given channel by passing an additional argument to the method:

    ...
    server.topic ( '#channel', 'New Topic' )
    ...

    Similarly, the modes of a channel may be examined by using the mode method. The method may also be used to examine user methods:

    ...
    server.mode ( '#channel' )
    server.mode ( 'User_Name' )
    ...

    If you wish to set a mode, the same method is used along with an additional argument:

    ...
    server.mode ( '#channel', '+m' )
    ...

    You may want to create an application that is responsible for controlling a channel. For example, let's say you wanted to kick users who sent too many messages to the channel too quickly. The kick method is used for this:

    ...
    server.kick ( '#channel', 'User_Name' )
    ...

    It might also be a good idea to leave a reason for kicking the user:

    ...
    server.kick ( '#channel, 'User_Name', 'Kicked for flooding.' )
    ...

    If your application needs a lot of power to operate, you can log on as an IRC operator:

    ...
    server.oper ( 'User_Name', 'password' )
    ...

    You can also send a raw string to the server using the send_raw method. It takes one argument, which is the string you want to send:

    ...
    server.send_raw ( 'NICK UserName2' )
    ...

    More Python Articles
    More By Peyton McCullough


       · This article is simply a continuation of the previous article, introducing more of...
     

       

    PYTHON ARTICLES

    - Nested Functions in Python
    - Python Parameters, Functions and Arguments
    - Python Statements and Functions
    - Statements and Iterators in Python
    - Sequences and Sets in Python
    - Python Expressions and Operators
    - Dictionaries, Variables and Statements in Py...
    - Data Types in Python
    - The Python Language
    - SSH with Twisted
    - Mobile Programming in Python using PyS60: UI...
    - Python: Count on It
    - Python Strings: Spinning Yarns
    - Python: More Fun with Strings
    - Python: Stringing You Along

     
    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 5 hosted by Hostway
    Stay green...Green IT