<?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>Shane&#039;s blog &#187; IRC</title>
	<atom:link href="http://blog.shamess.info/category/internet/irc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.shamess.info</link>
	<description>Personal blog of Shane Preece. Occaisional politics and tech minddump.</description>
	<lastBuildDate>Wed, 18 Jan 2012 10:28:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Perl IRC Bot</title>
		<link>http://blog.shamess.info/2008/11/08/perl-irc-bot/</link>
		<comments>http://blog.shamess.info/2008/11/08/perl-irc-bot/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 15:00:43 +0000</pubDate>
		<dc:creator>Shane</dc:creator>
				<category><![CDATA[IRC]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Unresolved problems]]></category>

		<guid isPermaLink="false">http://blog.shamess.info/?p=159</guid>
		<description><![CDATA[I tried using EggDrop, but couldn&#8217;t seem to get that working well (at all). So I decided meh! I&#8217;ll just make my own! So I started. After researching, I found an O&#8217;Reilly tutorial on how to make an IRC bot &#8230; <a href="http://blog.shamess.info/2008/11/08/perl-irc-bot/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I tried using EggDrop, but couldn&#8217;t seem to get that working well (at all). So I decided <em>meh! I&#8217;ll just make my own!</em></p>
<p>So I started. After researching, I found an O&#8217;Reilly tutorial on <a href="http://oreilly.com/pub/h/1964">how to make an IRC bot in perl</a> so I&#8217;m using that as a template.<span id="more-159"></span> Here&#8217;s what I have so far:</p>
<pre>#!/usr/bin/perl

use strict;

# We will use a raw socket to connect to the IRC server
use IO::Socket;

# The server to connect to and our details
my $server = "irc.dal.net";
my $nick = "PirateBot";

# Connect to the IRC server.
my $sock = new IO::Socket::INET(PeerAddr =&gt; $server,
                                PeerPort =&gt;; 6667,
                                Proto =&gt;; 'tcp') or
                                    die "Can't connectn";

# Log on to the server.
print $sock "NICK $nickrn";
print $sock "USER $nick 3 * :Pirate Botrn";

# Read lines from the server until it tells us we have connected.
while (my $response = ) {
  # Check the numerical responses from the server.
  if ($response =~ /004/) {
    # We are now logged in.
    last;
  }
  elsif ($response =~ /433/) {
    die "Nickname is already in use.";
  }
}
# Join the channel.
print $sock "JOIN #dmurn";

# Include the functions here
#include "functions.perl";

# Keep reading lines from the server.
while (my $response = ) {
  chop $response;
  #Always print the responses
  print "$responsen";
  if ($response =~ /^PING (.*)$/i) {
    # We must respond to PINGs to avoid being disconnected.
    print $sock "PONG $1rn";
    print "PONG $1rn";
  } elsif ($response =~ /Any pirates around?/i) { #This is just a random test thing
    print $sock "PRIVMSG #dmu :Hell yes!nr";
    print "PRIVMSG #dmu :Hell yes!nr";
  } elsif ($response =~ /^:(.+)!~.+ JOIN :#dmu/i) { #This just says hello to people as they come into the room
    my $usersNick = $1;
    if ($usersNick eq $nick) {
      print $sock "PRIVMSG #dmu :Ahoy! Did you miss me?rn";
      print "PRIVMSG #dmu :Ahoy! Did you miss me?rn";
    } else {
      print $sock "PRIVMSG #dmu :Ahoy, $usersNick.rn";
      print "PRIVMSG #dmu :Ahoy, $usersNick.rn";
    }
  } elsif ($response =~ /^$nick, seen (.+).*?/i) { #Seen command
    print $sock "PRIVMSG #dmu :I can't do that just yet...rn";
    print "PRIVMSG #dmu :I can't do that just yet...rn";
  }
}</pre>
<p>The problem with that is that I can&#8217;t do much with it&#8230; To do the <em>seen </em>command I want I&#8217;d need to do a <em>ULIST -c #dmu</em> and grab that output, but that&#8217;d make it go around the loop again&#8230; So, I&#8217;ll need to rethink that design&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.shamess.info/2008/11/08/perl-irc-bot/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

