Home arrow Python arrow Page 2 - Basic IRC Tasks

Communication Tasks - Python

Following up on an earlier DevShed article covering the basics of Python and Internet Relay Chat, this article takes some common IRC tasks, such as listing the users in a given channel or manipulating a channel's modes, and shows how to turn them into Pyton code.

  1. Basic IRC Tasks
  2. Communication Tasks
  3. Channel Related Tasks
  4. User Related Tasks
  5. Processing Information
By: Peyton McCullough
Rating: starstarstarstarstar / 4
April 18, 2005

print this article



All right. It's time to get into some actual tasks now that the basics of our module are completed. Let's start with communication, since it's pretty basic. “PRIVMSG” is the logical place to start. Recall the command from the last article:

PRIVMSG destination :message

This is easy to work into our class. We'll just create a method, privmsg, that accepts two arguments. The first argument is the destination, and the second argument is the message to be sent:

def privmsg ( self, destination, message ):

   self.send ( 'PRIVMSG ' + destination + ' :' + message )

The “PRIVMSG” command works with nicknames and channels both.

The “NOTICE” command can also be used to send messages:

def notice ( self, destination, message ):

   self.send ( 'NOTICE ' + destination + ' :' + message )

As you can see, “NOTICE” works very similarly to “PRIVMSG.” The only difference is how the commands are intended to be handled. “NOTICE” must never be automatically replied to.

>>> More Python Articles          >>> More By Peyton McCullough

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- 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

Developer Shed Affiliates


Dev Shed Tutorial Topics: