# statistics
%main::statistics = ();
init_statistics();
+# channel ringbuffer
+%main::channels = ();
######################################################################
}
+# store_channel_message_in_ringbuffer()
+#
+# store last x messages for each channel
+#
+# parameter:
+# - POE kernel
+# - POE heap
+# - the full who of the message sender, including the nick name
+# - the nick name of the message sender
+# - the message itself
+# - POE sender
+# - sender nick name
+# - the channel name
+# - session irc handle
+# - the sessiom handle
+# return:
+# none
+sub store_channel_message_in_ringbuffer {
+ my $kernel = shift;
+ my $heap = shift;
+ my $who = shift;
+ my $where = shift;
+ my $msg = shift;
+ my $sender = shift;
+ my $nick = shift;
+ my $channel = shift;
+ my $irc = shift;
+ my $session = shift;
+
+ if (lc($channel) eq lc($irc->nick_name())) {
+ return;
+ }
+
+ if (!defined($main::channels{$channel})) {
+ $main::channels{$channel} = [];
+ #print_msg("initialize channel ringbuffer: $channel", DEBUG);
+ }
+
+ push(@{$main::channels{$channel}}, $nick . ' = ' . $msg);
+ #print_msg("have " . scalar(@{$main::channels{$channel}}) . " entries in ringbuffer for channel " . $channel, DEBUG);
+
+ while (scalar(@{$main::channels{$channel}}) > 50) {
+ shift(@{$main::channels{$channel}});
+ }
+ #print_msg("ringbuffer: " . join(" | ", @{$main::channels{$channel}}), DEBUG);
+}
+
+
# handle_command()
#
# wrapper to handle all commands
print_msg("on_message($msg), session: $session", DEBUG);
+ # if this is a message sent to a channel
+ if (lc($channel) ne lc($irc->nick_name())) {
+ # store it in the ringbuffer
+ store_channel_message_in_ringbuffer($kernel, $heap, $who, $where, $msg, $sender, $nick, $channel, $irc, $session);
+ }
+
+
# recognize valid command (admin, operator and unprivileged)
my ($command, $string) = find_command($msg, (is_a_channel($channel)) ? $channel : undef);