sub irc_join { my $heap = $_[HEAP]; my $nick = ( split /!/, $_[ARG0] )[0]; my $channel = $_[ARG1]; my $hash_channel = (split /#/, $channel)[1]; my $irc = $_[SENDER]->get_heap(); my $joincount = $heap->{joincount}; my $batch_of_channels = $heap->{batch_of_channels_hash}; my $verbose = $heap->{verbose}; my $message = $heap->{cleanup_message}; my $nickname = $heap->{nickname}; my $channel_db = $heap->{channel_info_db}; $logger->info("Got join event from $channel as $$nickname - person joining was $nick"); if ( $nick eq $irc->nick_name() ) { # Number of channels joined $$joincount++; $logger->info("Which is $$joincount channels joined now"); # Only send the message if we're the one joining $logger->info("Messaging $channel"); # Mark the channel as joined $batch_of_channels->{$hash_channel}{joined} = 1; # Mark the channel as "being messaged" in the database, so it won't get selected in lock_channels.pl by mistake my $data_entry = $channel_db->resultset('Channel')->find({name => $hash_channel}); $data_entry->being_messaged('true'); $data_entry->update; $irc->yield(privmsg => $channel, $message); $irc->yield(part => $channel); } return; } sub irc_part { my $heap = $_[HEAP]; my $nick = ( split /!/, $_[ARG0] )[0]; my $channel = $_[ARG1]; my $hash_channel = (split /#/, $channel)[1]; my $part_msg = $_[ARG2]; my $irc = $_[SENDER]->get_heap(); my $joincount = $heap->{joincount}; my $batch_of_channels = $heap->{batch_of_channels_hash}; my $verbose = $heap->{verbose}; my $message = $heap->{cleanup_message}; my $nickname = $heap->{nickname}; my $channel_db = $heap->{channel_info_db}; $logger->info("Got part event from $channel as $$nickname - person leaving was $nick"); if ($nick eq $irc->nick_name()) { $$joincount--; $logger->info("Left a channel, so $$joincount channels joined now"); $batch_of_channels->{$hash_channel}{joined} = 0; } }