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.
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:
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.