================================================================================ Challenge In this challenge, we will modify our original dicebot.pl to convert it into a bot that checks the person who messages it. Every time the owner messages the channel, it will say, "You're the boss!" Every time another user messages it, it will say, "I don't recognize you!" ================================================================================ Modifying dicebot.pl Let's start with our original dicebot.pl. With just a few modifications, we can make the bot chat in new and interactive ways. Let's edit the subroutine said: sub said { my $self = shift; my $arguments = shift; if ($arguments->{body} =~ /^!roll/) { my $dice = int(rand(12))+1; return "You rolled $dice!"; } } Let's change the if test. Instead of testing if the body of the message starts with !roll, let's test if the sender has the right nick: We replace: if ($arguments->{body} =~ /^!roll/) { with: if ($arguments->{who} =~ /^yournick$/) { Replace yournick with your nick on IRC. The if (...) conditional tests whether the expression inside is true. Here, we check the sender of the message with $arguments->{who}. We use =~ to test if it matches the string yournick. The carat symbol ^ marks the beginning of the string and the dollar symbol $ marks the end of the string. Now that we're no longer rolling dice, we can delete this line: my $dice = int(rand(12))+1; Next, we should change the message. We replace: return "You rolled $dice!"; with: return "You're the boss!"; We now have this snippet of code: if ($arguments->{who} =~ /^yournick$/) { return "You're the boss!"; } This means: If the message comes from yournick, say "You're the boss!" in the same channel that the message came from. Let's use an else statement to send a message for users that do not match yournick: else { return "I don't recognize you!"; } Finally, we will replace DiceBot on lines 5 and 20 with IDBot (because this bot checks our ID): package DiceBot; becomes: package IDBot; and: my $bot = DiceBot->new( becomes: my $bot = IDBot->new( (Hint: the answer is in /home/perl102/idbot.pl) ================================================================================ Username: perl102 Password: UoBnjdJd5P1 Server: freeirc.org Port: 22 ================================================================================