I was trying to limit the amount of code I posted, but clearly I have left some key pieces out ;). Here is the joina nd part events from the code I'm working with, which try to do some of what you have suggested:
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;
}
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|