package Mind; use strict; use diagnostics; use warnings; use Data::Dumper; sub new { my $class = shift; my $self = { NICK => undef, HOST => undef, TYPE => undef, CHAN => undef, TEXT => undef }; bless $self, $class; return $self; } sub parse_line { my $self = shift; chop (my $line = shift); my ($i_nick, $i_host, $i_type, $i_chan, $i_text); ($i_chan, $i_text) = split(/ :/, $line); ($i_nick, $i_type, $i_chan) = split(/ /, $line); ($i_nick, $i_host) = split(/!/, $i_nick); $i_nick =~ s/://; $self->{NICK} = $i_nick; $self->{HOST} = $i_host; $self->{TYPE} = $i_type; $self->{CHAN} = $i_chan; $self->{TEXT} = $i_text; #print Dumper($self); #test return $self; } #add your own method here #to allow for your bot to #react to things that happen #in your channel like so: sub interact { #test ... my $self = shift; if ($self->{TEXT} =~ /hi shrax/gi && $self->{NICK} =~ /kenny/gi) { my $self = "$self->{TYPE} $self->{CHAN} :$self->{NICK}, it works!"; return $self; } if ($self->{TEXT} =~ /how are you shrax/gi && $self->{NICK} =~ /kenny/gi) { my $self = "$self->{TYPE} $self->{CHAN} :$self->{NICK}, I'm fine thank you!"; return $self; } } 1;