D-0 has asked for the wisdom of the Perl Monks concerning the following question:

Hello all,

I coded my irc bot

but i need something to do
if($text =~ /!about/gi) { &snd_msg("About"); } sub snd_msg { my($msg) = @_; print $sock "privmsg ",$channel," \:",$msg,"\n"; }
I want if (nick) type !about 2time
I want the bot ignore this nick after 1min unignore.

Any help?

2006-06-07 Retitled by holli, as per Monastery guidelines
Original title: 'Stop flood'

Replies are listed 'Best First'.
Re: Preventing IRC flood
by rminner (Chaplain) on Jun 07, 2006 at 07:17 UTC
    You could simply store the time when you last send the mesage to that nick in a hash (in the example called "received_about"), and only send the message, if the last time you send that message was more than 60seconds ago
    if ($received_about{$nick} and (time - $received_about{$nick}) > 60) { $received_about{$nick} = time; &snd_msg("About"); }
    UPDATE: as noted correctly by bart, there was an error in my logic, his code is correct:
    if (!$received_about{$nick} or (time - $received_about{$nick}) > 60) { $received_about{$nick} = time; &snd_msg("About"); }
      Your method is solid, your logic is flawed. You need to send the info too if $received_about{$nick} isn't set. I think this will work:
      if (!$received_about{$nick} or (time - $received_about{$nick}) > 60) { $received_about{$nick} = time; &snd_msg("About"); }
      Ok could you tell me how can i use DCC send in perl ? thanks
        Haven't used it myself, but i guess what you are looking for is Net::IRC. It seems to support DCC send (at least its submodule Net::IRC::DCC).