|
Cookbook: IRCClient
The InterfaceThe IRCClient module provides an inbox/outbox interface to IRC. Call SimpleIRCClientPrefab to obtain a connection to an IRC server.Sending messagesSend tuples in the form *(cmd, [arg1] [,arg2] [,arg3...])* to SimpleIRCClientPrefab's "inbox". *cmd* should be an IRC command specified in RFC 1459 or RFC 2812. The first parameter specified by the RFCs should be *arg1*, the second should be *arg2*, and so on. Example messages to "inbox"::
Note that "BERSERKER" is not a recognized IRC command. IRC_Client will not complain about this, as it treats commands uniformly, but you might get an error 421, "ERR_UNKNOWNCOMMAND" back from the server. Sending CTCP commandsIRC_Client also handles a few CTCP commands::ACTION: ("ME", channel-or-user, the-action-that-you-do). :MSG: If you use the outformat function defined here, 'MSG' commands are treated as 'PRIVMSGs'. No other CTCP commands are implemented. A simple client that logs in...and spams the channel #kamtest with 10 "Hello world" messages. (It's okay because no one else is ever on this channel)class Spammer(component): Now you will want to receive messages too, so your client isn't doomed to be a spammer. Lucky for you, SimpleIRCClientPrefab transmits IRC messages it receives in the form (cmd, sender, receiver, anything else). Simply link your component up to its "outbox" to receive these messages. LoggerLogs in to a channel and writes all IRC traffic it hears to a text file.from Kamaelia.File.Writing import SimpleFileWriter That's all there is! Have fun using the IRC components! |
Kamaelia
is an open source project originated from and guided by BBC
Research. For more information browse the site or get in
contact.
This is an ongoing community based development site. As a result the contents of this page is the opinions of the contributors of the pages involved not the organisations involved. Specificially, this page may contain personal views which are not the views of the BBC. (the site is powered by a wiki engine)
(C) Copyright 2008 Kamaelia Contributors, including the British Broadcasting Corporation, All Rights Reserved