my @channels_to_notify = get_unused_channels(); my @joined_channels; my @notified_channels; # in a timer, every minute or so: while(@channels_to_notify) { if( @joined_channels < 100 ) { my $name = shift @channels_to_notify; join_channel( $name ); }; }; # This should trigger on the message when you(r bot) joins a channel sub on_join { my ($name) = @_; $irc->yield(privmsg => $msg_channel, $message); $irc->yield(part => $msg_channel); }; # This should trigger on the message when you(r bot) parts a channel sub on_part { my ($name) = @_; @joined_channels = grep { $_ ne $name } @joined_channels; };