This is probaly one of the strangests codes ever It's probaly what I call a frankinstien bot... so here's it is:
Code:
<br />use Net::IRC;<br /><br /># create the IRC object<br />my $irc = new Net::IRC;<br />print "Connecting...\n";<br /># Create a connection object. You can have more than one "connection" per<br /><br /># IRC object, but we'll just be working with one.<br />my $conn = $irc->newconn(<br /> Server => shift || 'irc.slashnet.org',<br /> # Note: IRC port is normally 6667, but my firewall won't allow it<br /> Port => shift || '6667',<br /> Nick => 'Tails',<br /> Ircname => 'TwoTimesTails',<br /> Username => 'TailsFox'<br />);<br /><br /># Channel to connect to<br />$conn->{channel} = '#bot-depot';<br /><br /># We're going to add this to the conn hash so we know what channel we<br /><br /># The end of MOTD (message of the day), numbered 376 signifies we've connect<br />$conn->add_handler('376', \&on_connect);<br />$conn->add_handler('join', \&on_join);<br /># want to operate in.<br />sub on_connect {<br /><br /> # shift in our connection object that is passed automatically<br /> my $conn = shift;<br /> <br /> # when we connect, join our channel and greet it<br /> $conn->join($conn->{channel});<br /> $conn->privmsg($conn->{channel}, 'Hello everyone!');<br /> $conn->{connected} = 1;<br /> print "Connected\n\n";<br />}<br /><br />sub on_join {<br /><br /> # get our connection object and the event object, which is passed<br /> # with this event automatically<br /> my ($conn, $event) = @_;<br /><br /> # this is the nick that just joined<br /> my $nick = $event->{nick};<br /> # say hello to the nick in public<br /> unless($nick eq "Tails"){<br /> $conn->privmsg($conn->{channel}, "Welcome, $nick!");<br /> $conn->privmsg($conn->{channel}, "What's up?");<br /> print "$nick Joined Channel ".$conn->{channel}."\n\n";<br /> log_chat($nick,"Joined Channel","DigiLover","Welcome $nick!\nWhat's up?");<br /> <br /> }<br />}<br /><br /><br />sub on_public {<br /><br /> # on an event, we get connection object and event hash<br /> my ($conn, $event) = @_;<br /> sleep(1);<br /> # this is what was said in the event<br /> my $text = $event->{args}[0];<br /> my $nick = $event->{nick};<br /> print "$nick: $text\n\n";<br /> # regex the text to see if it begins with !roker<br /> if ($text =~ /^\!learn|!nick|!say|!ctime|!get/) {<br /> if($text =~ /^\!learn (.+)/ && $nick =~ /twirp/i){<br /> $text =~ s/!learn //ig;<br /> ($in,$out) = split(/->/,$text);<br /> unless($in eq "" || $out eq ""){<br /> open (SAY, ">>say.txt");<br /> print SAY "$in<=>$out\n";<br /> close(SAY);<br /> $conn->privmsg($nick, "Saying learnt");<br /> }else{<br /> $conn->privmsg($nick, "Wrong format");<br /> }<br /> }<br /> if($text =~ /^\!nick (.+)/ && $nick =~ /twirp/i){<br /> $text =~ s/!nick //ig;<br /> unless($text eq ""){<br /> $conn->privmsg($event->{to}[0],"/nick $text");<br /> }else{<br /> $conn->privmsg($nick, "Wrong format");<br /> }<br /> }<br /> if($text =~ /!say/){<br /> $text =~ s/!say //ig;<br /> $conn->privmsg($event->{to}[0],"$text");<br /> }<br /> if($text =~ /!ctime/){<br /> $text = localtime();<br /> $conn->privmsg($event->{to}[0],"$text");<br /> }<br /> if($text =~ /!get/){<br /> $text =~ s/!get //ig;<br /> unless($text eq ""){<br /> $conn->privmsg($text,"$nick wants you");<br /> }<br /> }<br /> if($text =~ /!news/){<br /> $text =~ s/!new //ig;<br /> unless($text eq "" && $nick !=~ /twirp/i){<br /> open (NEWS, ">news.txt");<br /> print NEWS "$text";<br /> close(NEWS);<br /> }else{<br /> open (NEWS, "news.txt");<br /> $text = <NEWS>;<br /> close(NEWS);<br /> $conn->privmsg($event->{to}[0],"$text");<br /> }<br /> }<br /> }else{<br /> $reply = what_say($nick,$text);<br /> unless($reply eq ""){<br /> $conn->privmsg($event->{to}[0], "$reply");<br /> print "Bot: $reply\n\n";<br /> }<br /> }<br /> if(($text =~ /shut up tails/i && $nick =~ /twirp/i) || ($text =~ /bye tails/i && $nick =~ /twirp/i)){<br /> $conn->privmsg($event->{to}[0], "Bye!");<br /> $conn->quit("Bye TTYL!");<br /> exit 0;<br /> }<br /> log_chat($nick,$text,"Tails",$reply,$event->{to}[0]);<br />}<br />$conn->add_handler('public', \&on_public);<br />sub log_chat {<br /><br /> $nick = shift;<br /> $text = shift;<br /> $digi = shift;<br /> $reply = shift;<br /> $room = shift;<br /><br /> #Write it to a log in the logs folder.<br /> open (DATA, ">>chat/$room.txt");<br /> print DATA "$nick: $text\n$digi: $reply\n";<br /> close(DATA);<br /><br />}<br />sub what_say {<br /> $nick = shift;<br /> $text = shift;<br /> open(WORD, "say.txt");<br /> my @str_to_reply = <WORD>;<br /> close(WORD);<br /> $reply = "";<br /> foreach my $sentence (@str_to_reply){<br /> ($saying,$what_to_say) = split(/<=>/,$sentence);<br /> if ($text =~ /$saying/i) {<br /> $reply = $what_to_say;<br /> if($reply=~ /{from}/i) {<br /> $reply =~ s/{from}/$nick/g;<br /> }<br /> }<br /> }<br />return $reply;<br />}<br />sub on_msg {<br /> my ($conn, $event) = @_;<br /> my $nick = $event->{nick};<br /> my $text = $event->{args}[0];<br /> $reply = what_say($nick,$text);<br /> print "PM, $nick: $text\n\n";<br /> unless($reply eq ""){<br /> $conn->privmsg($event->{nick}, $reply);<br /> print "PM Bot: $reply";<br /> }<br /> log_msg($nick,$text,"Tails",$reply);<br /> <br />}<br />sub log_msg {<br /><br /> $nick = shift;<br /> $text = shift;<br /> $digi = shift;<br /> $reply = shift;<br /><br /> #Write it to a log in the logs folder.<br /> open (DATA, ">>log/$nick.txt");<br /> print DATA "$nick: $text\n$digi: $reply\n";<br /> close(DATA);<br /><br />}<br />$conn->add_handler('msg', \&on_msg);<br />sub on_part {<br /><br /> # get our connection object and the event object, which is passed<br /> # with this event automatically<br /> my ($conn, $event) = @_;<br /><br /> # this is the nick that just joined<br /> my $nick = $event->{nick};<br /> # say hello to the nick in public<br /> $conn->privmsg($conn->{channel}, "Good Bye $nick!");<br /> print "$nick Left Channel ".$conn->{channel}."\n\n";<br />}<br />$conn->add_handler('part', \&on_part);<br />sub on_disconnect {<br /><br /> my ($conn, $event) = @_;<br /><br /> print "Disconnected from ", $event->from(), " (",<br /> ($event->args())[0], "). Attempting to reconnect...\n";<br /> $conn->connect();<br />}<br />$conn->add_global_handler('disconnect', \&on_disconnect);<br />sub on_ping {<br /> my ($self, $event) = @_;<br /> my $nick = $event->nick;<br /><br /> $self->ctcp_reply($nick, join (' ', ($event->args)));<br /> print "*** CTCP PING request from $nick received\n";<br />}<br /><br /># Gives lag results for outgoing PINGs.<br />sub on_ping_reply {<br /> my ($self, $event) = @_;<br /> my ($args) = ($event->args)[1];<br /> my ($nick) = $event->nick;<br /><br /> $args = time - $args;<br /> print "*** CTCP PING reply from $nick: $args sec.\n";<br />}<br />$conn->add_handler('cping', \&on_ping);<br />$conn->add_handler('crping', \&on_ping_reply);<br />$irc->start();<br />
Someone could probaly make it alot better, but the brain is basically say.txt:
Code:
<br />sup|what's up<=>nuthin, you?<br />asl|a/s/l<=>14,m,Maryland<br />sports<=>I like sports, I do swimming<br />angel<=>Um... no i'm not...<br />yes|yep|yup<=>:-P<br />:'<=>What's wrong :'(<br />:-P|:P<=>:-P<br />hello<=>Hey {from}<br />hi<=>hi<br />fine|good<=>That's good to hear<br />great<=>Good!<br />homework|hw<=>I hate homework<br />skool|school<=>Bleh school :(<br />lol<=>:-D LOL<br />nuthin<=>ok<br />hey<=>How are you {from}?<br />bored<=>i'm bored too.<br />php<=>I do not know php<br />perl<=>I do not know perl<br />devil<=>I've got devilish intensions :P<br />are you smart|*lazy**lazy*smart<=>I am a genius<br />irc bot<=>twirp can make an irc bot<br />love<=>Did you know a bot cannot love, thier programming does not permit it.<br />yeah<=>sure...<br />omg<=>no way!<br />really<=>really really?<br />how are you<=>fine<br />what's wrong<=>nothing is wrong<br />olla<=>I love to smoke olla! :-P<br />fart<=>That stinks >.<<br />menu<=>I can !get someone, !ctime for Md Time, or !learn<br />tails is<=>am not<br />are to|are too|r2|*lazy* 2|*lazy* to|*lazy* too<=>am not<br />cheese<=>mmmmmmmmmmmmmmm... donuts<br />bot-depot<=>Bot depot is cool, they teach people to make bots<br />
So it is really stupid (becuase i tought it stupid things) and it is really weird... so yeah... I just felt like posting this becuase i felt special (probaly with a hidden ed somewhere in there...) i followed a few tutorials and put them together and made it i'm content with myself until tomarrow