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  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
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? 
Google.com  
PYTHON

IRC on a Higher Level Continued
By: Peyton McCullough
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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
     

       

    PYTHON ARTICLES

    - Tuples and Other Python Object Types
    - The Dictionary Python Object Type
    - String and List Python Object Types
    - Introducing Python Object Types
    - Mobile Programming using PyS60: Advanced UI ...
    - 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





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek