<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>literal thoughts &#187; irc</title>
	<atom:link href="http://blog.nix.is/tag/irc/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.nix.is</link>
	<description>Come for the thoughts, stay for the rants</description>
	<lastBuildDate>Tue, 01 Sep 2009 13:15:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>POE::Component::IRC 6.00 is here</title>
		<link>http://blog.nix.is/poecomponentirc-600-is-here</link>
		<comments>http://blog.nix.is/poecomponentirc-600-is-here#comments</comments>
		<pubDate>Thu, 05 Mar 2009 03:03:33 +0000</pubDate>
		<dc:creator>Hinrik Örn Sigurðsson</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://blog.nix.is/?p=53</guid>
		<description><![CDATA[POE::Component::IRC version 6.00 has just been released on CPAN. I&#8217;ve neglected to blog about PoCo::IRC since I started contributing to it, but since a new major release has been rolled out[1], now would be a good time. Also, as it turns out, next May will be the tenth anniversary of the project&#8217;s first release.
For the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://search.cpan.org/dist/POE-Component-IRC">POE::Component::IRC</a> version 6.00 has just been released on CPAN. I&#8217;ve neglected to blog about PoCo::IRC since I started contributing to it, but since a new major release has been rolled out[1], now would be a good time. Also, as it turns out, next May will be the tenth anniversary of the project&#8217;s first release.</p>
<p>For the uninitiated, POE::Component::IRC is an event-driven IRC client library built on top of POE. People mostly use it to write bots. Some have made that even easier by creating a simpler interface suited to that task (see Bot::BasicBot).</p>
<p>I became involved in the project about 14 months ago, fixing bugs and adding features. There&#8217;ve been about 50 releases during that time, so there&#8217;s something for everybody. Following is a list of the most prominent ones.<br />
<span id="more-53"></span></p>
<h2 id="important-squashed-bugs">Important squashed bugs</h2>
<ul>
<li>Quite a few DCC-related bugs have been fixed, error handling and diagnostics have been improved.</li>
<li>A bug causing the NickReclaim plugin to only try to reclaim the nick once has been fixed.</li>
<li>POE::Component::IRC::State was reacting incorrectly to some WHO replies sent by IRC servers that veered from the RFCs, causing it to hold inconsistent information. This has been fixed.</li>
<li>When raw messages were enabled, the raw line was not provided with CTCP-related events. Fixed.</li>
<li>POE::Component::IRC::State would issue more WHO commands than necessary when another user would join more than one of the component&#8217;s channels. No more.</li>
</ul>
<h2 id="new-major-features">New major features</h2>
<ul>
<li>POE::Component::IRC::Common, which provides many helper functions, now has functions for identifying and stripping color/formatting from IRC messages. It also defines IRC color constants for use in messages.</li>
<li>We now handle FreeNode&#8217;s IDENTIFY-MSG capability, which means that can you always know whether a user had identified with NickServ when s/he wrote a particular message.</li>
<li>Sending and receiving files with spaces in them over DCC is now supported.</li>
<li>All DCC-related events now provide the IP address of the peer.</li>
<li>DCC resume support has been implemented.</li>
<li>The BotTraffic plugin now send an event for every CTCP ACTION issued by the client.</li>
<li>We now guard against sending IRC protocol messages that are too long and might get us booted off the server.</li>
<li>The Connector plugin (takes care of maintaining the connection to the IRC server) now supports cycling through a list of servers when reconnecting.</li>
<li>The CTCP plugin can now respond to CTCP SOURCE requests for you.</li>
<li>POE::Component::IRC::State and can now track the away status of users for you.</li>
<li>POE::Component::IRC::State now keeps track of a channel&#8217;s creation time.</li>
<li>Added NICKSERV, SERVLIST, and SQUERY commands.</li>
<li>Plugins can now respond to custom events which have not been explicitly defined by POE::Component::IRC.</li>
</ul>
<h2 id="new-plugins">New plugins</h2>
<p>I wrote 5 additional core plugins:</p>
<ul>
<li>First of all, the <strong>Logger</strong> plugin. It logs channel/private/dcc chat activity to files on disk like normal IRC clients do.</li>
<li>Then there&#8217;s <strong>AutoJoin</strong>, which takes care of keeping you on your favorite channels, whatever happens.</li>
<li><strong>NickServID</strong> deals with identifying your user to NickServ.</li>
<li>A <strong>CycleEmpty</strong> plugin which reclaims ops on channels that become empty.</li>
<li><strong>BotCommand</strong>, which allows you to register commands that your bot handles, and get back an appropriate event when one is issued.</li>
</ul>
<h2 id="testing">Testing</h2>
<p>The test suite has been reorganized, many tests improved and more added. The test coverage (as reported by Devel::Cover) has increased from 40% (version 5.48) to 61% (version 6.00).</p>
<h2 id="refactoring">Refactoring</h2>
<p>Much refactoring was done. The coding and indenting style has also been made consistent across the project, and many spotty coding practices have been eliminated (thanks, Perl::Critic).</p>
<p>POE::Filter::CTCP was merged with POE::Filter::IRC:Compat, and the former was removed. DCC support has been moved into its own plugin, and the plugin system itself has been ripped out in favor of POE::Component::Pluggable (which is based on the aforementioned plugin system).</p>
<p>Using the project&#8217;s current Perl::Critic parameters, version 6.00 has zero policy violations in 11,791 lines of code, compared to version 5.48&#8217;s 242 violations in 10,634 lines of code. The average <a href="http://en.wikipedia.org/wiki/Cyclomatic_complexity">McCabe</a> score of subroutines also dropped from 4.21 to 3.45.</p>
<h2 id="documentation">Documentation</h2>
<p>Last but not least, the Pod docs have been improved. Errors have been fixed, much more formatting and linking has been added for easier reading and browsing, consistency has been improved, and many sections have been expanded.</p>
<p>I also added a <a href="http://search.cpan.org/perldoc?POE::Component::IRC::Cookbook">cookbook</a> with a few recipes showing off some of the things one can do with POE::Component::IRC.</p>
<h2 id="credits">Credits</h2>
<p>Thanks to all the users who provided feedback, bug reports and patches. You helped make this happen. I also couldn&#8217;t have done many of these things without the help of Chris &#8216;BinGOs&#8217; Williams, the senior maintainer of POE::Component::IRC.</p>
<p>Now go write some IRC bots (or clients)!</p>
<p><em>Notes:</em><br />
1. It&#8217;s actually quite an insignificant release. Historically, POE::Component::IRC versions have always passed the whole-number boundaries naturally as part of a regular &#8220;bump the version number up by 0.02 for the next release&#8221; process.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nix.is/poecomponentirc-600-is-here/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spicing up IRC with MegaHAL</title>
		<link>http://blog.nix.is/spicing-up-irc-with-megahal</link>
		<comments>http://blog.nix.is/spicing-up-irc-with-megahal#comments</comments>
		<pubDate>Fri, 29 Aug 2008 04:45:56 +0000</pubDate>
		<dc:creator>Hinrik Örn Sigurðsson</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://blog.nix.is/?p=34</guid>
		<description><![CDATA[I released POE::Component::IRC::Plugin::MegaHAL the other day, a POE::Component::IRC plugin for the esteemed and humorous conversation simulator known as MegaHAL. This makes it very easy to add a MegaHAL brain to an IRC bot. I wrote one and fed him IRC logs of a channel that I frequent, then let him loose online (he&#8217;s a &#8220;he&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>I released <a href="http://search.cpan.org/perldoc?POE::Component::IRC::Plugin::MegaHAL">POE::Component::IRC::Plugin::MegaHAL</a> the other day, a <a href="http://search.cpan.org/perldoc?POE::Component::IRC">POE::Component::IRC</a> plugin for the esteemed and humorous conversation simulator known as <a href="http://megahal.alioth.debian.org/">MegaHAL</a>. This makes it very easy to add a MegaHAL brain to an IRC bot. I wrote one and fed him IRC logs of a channel that I frequent, then let him loose online (he&#8217;s a &#8220;he&#8221; because the IRC logs primarily include ramblings from male users). Some examples of his brilliance follow.<br />
<span id="more-34"></span></p>
<pre>
&lt;failo&gt; Or maybe it's about sexual liberation and not perl &#038; python.
&lt;failo&gt; Yes, printing passport photos at home is surely a sign of a flock of aids infected prisoners with big sloppy dicks.
&lt;failo&gt; I heard failo is a fact of evolution that cannot be shown because it looks like he knows what electricity is
&lt;failo&gt; Fucking get your cock out and jerk each other off in proportion to how much dexter's wedding dinner is going your way
&lt;failo&gt; Sir you had me at "balls."
&lt;failo&gt; Every porn dvd has a "grill setting"
&lt;failo&gt; So only 2% of americans also believe that the government is composed of thong-wearing oiled-up muscle boys.
&lt;failo&gt; Increased struggling from the bees made honey in the darkened cubicle, waiting for another musky man-pole to probe its way through the light to go mushroom hunting with me
&lt;failo&gt; I bet all drug users keep a human skull on their myspace page.
&lt;failo&gt; Earle: everybody's gay for a prison system in which millions of our descendants murder each other in prison.
&lt;failo&gt; Either you're gay or associated with all drugs.
&lt;failo&gt; The war on polarbears is going to cum buckets into my gaping /dev/null.
</pre>
<p>I&#8217;m afraid these results say more about the quality of conversation in this channel than they do about anything else&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nix.is/spicing-up-irc-with-megahal/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>IRC and character encoding</title>
		<link>http://blog.nix.is/irc-and-character-encoding</link>
		<comments>http://blog.nix.is/irc-and-character-encoding#comments</comments>
		<pubDate>Thu, 01 May 2008 01:44:50 +0000</pubDate>
		<dc:creator>Hinrik Örn Sigurðsson</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[irc]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://blog.nix.is/?p=13</guid>
		<description><![CDATA[A while ago, I wrote an IRC logger for POE::Component::IRC, which is an IRC client module for Perl. The main challenge I faced was the issue of character encodings. Since IRC is ripe with clients that use different encodings, messages must be reliably decoded before they are written to a file.

You see, RFC 1459, the [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I wrote an IRC logger for <a href="http://search.cpan.org/dist/POE-Component-IRC/">POE::Component::IRC</a>, which is an IRC client module for Perl. The main challenge I faced was the issue of character encodings. Since IRC is ripe with clients that use different encodings, messages must be reliably decoded before they are written to a file.<br />
<span id="more-13"></span></p>
<p>You see, <a href="http://www.faqs.org/rfcs/rfc1459.html">RFC 1459</a>, the standards document describing the IRC protocol, does not regulate the use of character encodings:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">2.2 Character codes
&nbsp;
   No specific character set is specified. The protocol is based on a
   set of codes which are composed of eight (8) bits, making up an
   octet. Each message may be composed of any number of these octets;
   however, some octet values are used for control codes which act as
   message delimiters.
&nbsp;
   Regardless of being an 8-bit protocol, the delimiters and keywords
   are such that protocol is mostly usable from USASCII terminal and a
   telnet connection.</pre></div></div>

<p>ASCII uses the first 7 bits. So, from the looks of it, you should only be able to rely on the first seven bits representing an ASCII character, the interpretation of the last bit being anyone&#8217;s guess. That&#8217;s bad.</p>
<p>For most of IRC&#8217;s history, the most popular IRC client has been mIRC. Until recently, mIRC decoded incoming messages using the ANSI code page that was currently being used on the user&#8217;s Windows system. This meant that whenever mIRC users wanted to communicate using anything other than ASCII characters, they&#8217;d better be using the same code page. In later versions, mIRC decodes incoming messages as UTF-8 if they look UTF-8 encoded, or code page 1252 (used by most Westerners). As for <i>how</i> it does this, I cannot know since mIRC is closed-source.</p>
<p>The open-source client irssi handles the situation similarly. It uses GLib&#8217;s <a href="http://library.gnome.org/devel/glib/2.16/glib-Unicode-Manipulation.html#g-utf8-validate">g_utf8_validate()</a> function to check if the incoming message is UTF-8 encoded, otherwise it falls back to CP1252 by default. As for XChat, it uses the same GLib function, but if it determines that the message is not UTF-8, XChat decodes the message in a rather novel way. Here is an excerpt from its <code><a href="http://xchat.cvs.sourceforge.net/xchat/xchat2/src/common/text.c?view=markup">src/common/text.c</a></code>:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">/* converts a CP1252/ISO-8859-1(5) hybrid to UTF-8                           */
/* Features: 1. It never fails, all 00-FF chars are converted to valid UTF-8 */
/*           2. Uses CP1252 in the range 80-9f because ISO doesn't have any- */
/*              thing useful in this range and it helps us receive from mIRC */
/*           3. The five undefined chars in CP1252 80-9f are replaced with   */
/*              ISO-8859-15 control codes.                                   */
/*           4. Handles 0xa4 as a Euro symbol ala ISO-8859-15.               */
/*           5. Uses ISO-8859-1 (which matches CP1252) for everything else.  */
/*           6. This routine measured 3x faster than g_convert :)            */</pre></div></div>

<p>How would I handle this in Perl? I don&#8217;t want to depend on GLib, and I don&#8217;t want to write any C code (requiring the user to have a C compiler). At first I tried using <a href="http://search.cpan.org/dist/Encode-Detect/">Encode::Detect</a>, but there are two problems with it. It&#8217;s an extra dependency, and more importantly, it works heuristically, deciding which character set is being used based on the number of occurences of each character code. As such, it&#8217;s only reliable when large amounts of data are involved. Like a whole web page, for example, which is what the code was written for. Then I learned of <a href="http://perldoc.perl.org/Encode/Guess.html">Encode::Guess</a>, which is included with Perl as of version 5.6.0. The following decodes <code>$line</code> as UTF-8 if Encode::Guess is sure that it&#8217;s UTF-8. Otherwise it decodes it as CP1252.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Encode <span style="color: #000066;">qw</span><span style="color: #009900;">&#40;</span>decode<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Encode<span style="color: #339933;">::</span><span style="color: #006600;">Guess</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$utf8</span> <span style="color: #339933;">=</span> guess_encoding<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$line</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">'utf8'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$line</span> <span style="color: #339933;">=</span> <span style="color: #000066;">ref</span> <span style="color: #0000ff;">$utf8</span> <span style="color: #339933;">?</span> decode<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'utf8'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$line</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> decode<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'cp1252'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>So far this method has worked flawlessly for me on channels with mixed encodings. However, I don&#8217;t know exactly how Encode::Guess works, so I&#8217;m not as confident in this method as I could be. Any feedback on this issue would be quite welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nix.is/irc-and-character-encoding/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
