![]() ![]() Notes and Contact InfoĬopyright © 2009 Ferry Boender For EnterpriseĪvailable as part of the Tidelift Subscription. Must use one of the above techniques for decoding input to text. Processing, so a decoding buffer must be used. DecodingLineBuffer ): def handle_exception ( self ): pass irc. Or, to simply ignore all input that cannot be decoded: class IgnoreErrorsBuffer ( buffer. Or decode to UTF-8, but use a replacement character for unrecognized byte To decode all input as latin-1 (which decodes any input), connect ()Īlternatively, some clients may still want to decode the input using aĭifferent encoding. Overridden before the connection is established): server = irc. The buffer may be overridden on a per-instance basis (as long as it’s Will avoid UnicodeDecodeError in all cases (but may produce unexpectedīehavior if an IRC user is using another encoding). The LenientDecodingLineBuffer attempts UTF-8 but falls back to latin-1, which ServerConnection by overriding the class attribute.įor example: from jaraco.stream import buffer irc. The buffer_class attribute may be assigned for all instances of Re-assigned with another class, following the interface of buffer.LineBuffer. Input stream, using the buffer module in jaraco.stream. ServerConnection determines which class is used for buffering lines from the Library provides options to customize decoding of input by customizing the Since assuming UTF-8 is not reasonable in the general case, the IRC UTF-8, even though the IRC spec stipulates that no specific encoding can beĮxpected. _class = ScheduleScheduler Decoding Inputīy default, the IRC library attempts to decode all incoming streams as Raise NotImplementedError(“Not supported”) def run_pending(self): Schedule.at(when).do(func) def execute_after(self, delay, func): ![]() Schedule.every(period).do(func) def execute_at(self, when, func): In your dependencies and install it into the IRC library as so: class ScheduleScheduler(): def execute_every(self, period, func): The library includes a default event Scheduler asīut this scheduler can be replaced with any other scheduler. NOTE: If you’re running one of the examples on a unix command line, you need Invitations and echos back sent DCC chat messages. The bot enters a channel and listens for commands in servermap connects to an IRC server,įinds out what other IRC servers there are in the net and printsĪ tree-like map of their interconnections.Īn example bot that uses the SingleServerIRCBot class from Same as above, but using the AioSimpleIRCClient classĪnother simple example. Same as above, but uses the asyncio-based event loop inĪioReactor instead of the select() based Reactor. The same as above, but using the SimpleIRCClient class. Text from stdin and writes it to a specified user or channel on Invoke the server with python -m irc.server.Įxample scripts in the scripts directory:Ī simple example of how to use the IRC client. ![]() Interface/API is otherwise functionally identical to the classesĪ basic IRC server implementation. Python 3’s native asyncio library for the core event loop. Use it at your own riskĪll the functionality of the above library, but utilizing Read the code along with comments andĭocstrings to get a grip of what it does. ![]() The following modules might be of interest: Understand the example program irccat, which is included in the I think the best way to get started is to read and Unfortunately, this library isn’t as well-documented as I would like Like most projects, documentation is lacking …ĭCC is not currently implemented in the asyncio-based version the write() may block if the TCP buffers are stuffed. The IRC protocol shines through the abstraction a bit too much.ĭata is not written asynchronously to the server (and DCC peers), That dispatches events to instance methods is included. Other IRC client implementation that handles the CTCPĪ kind of simple, single-server, object-oriented IRC client class You can use sockets in an internal select() loop OR useįunctions can be registered to execute at specified times by theĭecodes CTCP tagging correctly (hopefully) I haven’t seen any Multiple options for reading from and writing to an IRC server: Messages from an IRC server triggers events, which can be caught Messages to the IRC server are done by calling methods on an IRC Handles multiple simultaneous IRC server connections. The main features of the IRC client framework are: In order to understand how to make an IRC client, it’s best to read up first It hasĪ fairly thorough support for the basic IRC protocol, CTCP, and DCC It provides an event-driven IRC client framework. This library provides a low-level implementation of the IRC protocol for Full-featured Python IRC library for Python. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |