IRCAP.pm 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. package Pisg::Parser::Format::IRCAP;
  2. # Documentation for the Pisg::Parser::Format modules is found in Template.pm
  3. # Modifications to parse IRCAP 7.5 logs, made by Armando Camarero, September 2003.
  4. # This file is a modification of the mIRC6 parser file included in Pisg 0.49.
  5. # Copyright (C) 2003 Armando Camarero <arcepi10@terra.es>
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # To see this script working visit http://arcepi.hn.org/ED/ (statistics aren't online 24x7 - hosted at my computer...)
  22. # Sorry if the script isn't too clean, it is the first thing I programmed (I also learnt Perl doing this), but I can say
  23. # it works perfectly.
  24. # This script needs log timestamp to be enabled in mIRC: File -> Options -> IRC: Logging and mark Timestamp logs.
  25. use strict;
  26. $^W = 1;
  27. sub new
  28. {
  29. my ($type, %args) = @_;
  30. my $self = {
  31. cfg => $args{cfg},
  32. normalline => '^\[(\d+):\d+:?\d*\] <([^>]+)> (.*)',
  33. thirdline => '^\[(\d+):(\d+):?\d*\] (\*\*\*|\*) (.+)',
  34. };
  35. bless($self, $type);
  36. return $self;
  37. }
  38. sub normalline
  39. {
  40. my ($self, $line, $lines) = @_;
  41. my %hash;
  42. if ($line =~ /$self->{normalline}/o) {
  43. $hash{hour} = $1;
  44. ($hash{nick} = $2) =~ s/^[@%\+]//o; # Remove prefix
  45. $hash{saying} = $3;
  46. return \%hash;
  47. } else {
  48. return;
  49. }
  50. }
  51. sub actionline
  52. {
  53. my ($self, $line, $lines) = @_;
  54. my %hash;
  55. return $self->thirdline($line, $lines, 1);
  56. }
  57. sub thirdline
  58. {
  59. my ($self, $line, $lines, $action) = @_;
  60. my %hash;
  61. if ($line =~ /$self->{thirdline}/o) {
  62. my @line = split(/\s/, $3);
  63. my @linea = split (/\s/, $line);
  64. $hash{hour} = $1;
  65. $hash{min} = $2;
  66. $hash{saying} = $3;
  67. ($hash{nick} = $line[0]) =~ s/^[@%\+]//o; # Remove prefix
  68. if ($#linea >= 2 and $linea[2] eq 'topic:') {
  69. #print $linea[2], "\n";
  70. }
  71. if ($#linea >= 7 && ($linea[3].$linea[4]) eq 'hasido') {
  72. $hash{kicker} = $linea[7];
  73. $hash{nick} = $linea[2];
  74. my $razon = join (' ', @linea[8..$#linea]);
  75. $razon =~ s/(\(|\))//g;
  76. $hash{kicktext} = $razon;
  77. #print "kick detectado: $linea[7] kickeo a $linea[2], razón $razon\n";
  78. } elsif ($#line >= 4 && ($line[1].$line[2]) eq 'werekicked' && ($line[$#line] =~ /\)$/)) {
  79. $hash{kicker} = $line[4];
  80. $hash{nick} = $self->{cfg}{maintainer};
  81. } elsif ($#linea >= 4 && ($linea[2] eq 'topic:')) {
  82. $hash{newtopic} = join(' ', @linea[5..$#linea]);
  83. $hash{newtopic} =~ s/^'//;
  84. $hash{newtopic} =~ s/'$//;
  85. $hash{nick} = $linea[3];
  86. } elsif ($#linea >= 5 && $linea[2] eq 'modo:') {
  87. #print "Cambio de modo detectado\n";
  88. $linea[5] =~ s/\[//g;
  89. $linea[6] =~ s/\]//g;
  90. #print $linea[6], "\n";
  91. $hash{newmode} = $linea[5]; # newmode es +o -o etc....
  92. $hash{modechanges} = $linea[6]; # modechanges es el nick al que se le da/quita la @
  93. $hash{nick} = $linea[3]; # nick, como siempre, es el que la da.
  94. } elsif ($#linea == 7 && $linea[6] eq 'entra') {
  95. #print "Entrada al canal detectada de $linea[2]\n";
  96. $hash{newjoin} = $linea[2];
  97. $hash{nick} = $linea[2];
  98. } elsif ($#linea == 5 && ($linea[3].$linea[4]) eq 'esahora') {
  99. #print "Cambio de nick detectado\n";
  100. $hash{newnick} = $linea[5];
  101. $hash{nick} = $linea[2];
  102. } elsif ($action) {
  103. $line =~ s/^\[(\d+):(\d+):?\d*\] \* //;
  104. $hash{saying} = $line;
  105. my @nick = split (' ', $hash{saying});
  106. $hash{nick} = $nick[0];
  107. #print $line, "\n";
  108. #print $hash{saying}, "\n";
  109. if (
  110. ($hash{saying} =~ /^Set by \S+ on \S+ \S+ \d+ \d+:\d+:\d+/) ||
  111. ($hash{saying} =~ /^Now talking in #\S+/) ||
  112. ($hash{saying} =~ /^Topic is \'.*\'/) ||
  113. ($hash{saying} =~ /^Disconnected/) ||
  114. ($hash{saying} =~ /^\S+ has quit IRC \(.+\)/) ||
  115. ($hash{saying} =~ /^\S+ has left \#\S+/) ||
  116. ($hash{saying} eq "You're not channel operator") ||
  117. ($hash{nick} eq 'Attempting') ||
  118. ($hash{nick} eq 'Rejoined') ||
  119. ($hash{saying} =~ /^Retrieving #\S+ info\.\.\./) ||
  120. ($hash{saying} =~ /^\[/)
  121. ) {
  122. #print "$hash{saying} No es una ACCION\n";
  123. return 0;
  124. } else {
  125. #print "Detectada una ACCION: $hash{saying}\n";
  126. #print $nick[0], "\n";
  127. $hash{saying} =~ s/^\Q$hash{nick}\E //;
  128. return \%hash;
  129. }
  130. } else {
  131. return;
  132. }
  133. return \%hash
  134. unless ($action);
  135. }
  136. return;
  137. }
  138. 1;