mIRC6hack.pm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package Pisg::Parser::Format::mIRC6hack;
  2. # Documentation for the Pisg::Parser::Format modules is found in Template.pm
  3. # To use this logging format, add the following to mIRC's remote script
  4. # section:
  5. #
  6. # on ^1:ACTION:*:*: {
  7. # haltdef
  8. # echo $chan ** $nick $1-
  9. # }
  10. use strict;
  11. $^W = 1;
  12. sub new
  13. {
  14. my ($type, %args) = @_;
  15. my $self = {
  16. cfg => $args{cfg},
  17. normalline => '^\[(\d+):\d+:?\d*\] <([^>]+)> (.*)',
  18. actionline => '^\[(\d+):\d+:?\d*\] \*\* (\S+) (.+)',
  19. thirdline => '^\[(\d+):(\d+):?\d*\] \* (.+)'
  20. };
  21. bless($self, $type);
  22. return $self;
  23. }
  24. sub normalline
  25. {
  26. my ($self, $line, $lines) = @_;
  27. my %hash;
  28. if ($line =~ /$self->{normalline}/o) {
  29. $hash{hour} = $1;
  30. $hash{saying} = $3;
  31. ($hash{nick} = $2) =~ s/^[@%\+]//o; # Remove prefix
  32. return \%hash;
  33. } else {
  34. return;
  35. }
  36. }
  37. sub actionline
  38. {
  39. my ($self, $line, $lines) = @_;
  40. my %hash;
  41. if ($line =~ /$self->{actionline}/o) {
  42. $hash{hour} = $1;
  43. $hash{saying} = $3;
  44. ($hash{nick} = $2) =~ s/^[@%\+]//o; # Remove prefix
  45. return \%hash;
  46. } else {
  47. return;
  48. }
  49. }
  50. sub thirdline
  51. {
  52. my ($self, $line, $lines, $action) = @_;
  53. my %hash;
  54. if ($line =~ /$self->{thirdline}/o) {
  55. my @line = split(/\s/, $3);
  56. $hash{hour} = $1;
  57. $hash{min} = $2;
  58. $hash{saying} = $3;
  59. ($hash{nick} = $line[0]) =~ s/^[@%\+]//o; # Remove prefix
  60. if ($#line >= 4 && ($line[1].$line[2]) eq 'waskicked' && ($line[$#line] =~ /\)$/)) {
  61. $hash{kicker} = $line[4];
  62. } elsif ($#line >= 4 && ($line[1].$line[2]) eq 'werekicked' && ($line[$#line] =~ /\)$/)) {
  63. $hash{kicker} = $line[4];
  64. $hash{nick} = $self->{cfg}{maintainer};
  65. } elsif ($#line >= 4 && ($line[1] eq 'changes') && ($line[$#line] =~ /\'$/)) {
  66. $hash{newtopic} = join(' ', @line[4..$#line]);
  67. $hash{newtopic} =~ s/^'//;
  68. $hash{newtopic} =~ s/'$//;
  69. } elsif ($#line >= 3 && ($line[1].$line[2]) eq 'setsmode:') {
  70. $hash{newmode} = $line[3];
  71. } elsif ($#line == 4 && ($line[2].$line[3]) eq 'hasjoined') {
  72. $hash{newjoin} = $line[0];
  73. } elsif ($#line == 5 && ($line[2].$line[3]) eq 'nowknown') {
  74. $hash{newnick} = $line[5];
  75. } elsif ($action) {
  76. if (
  77. ($hash{saying} =~ /^Set by \S+ on \S+ \S+ \d+ \d+:\d+:\d+/) ||
  78. ($hash{saying} =~ /^Now talking in #\S+/) ||
  79. ($hash{saying} =~ /^Topic is \'.*\'/) ||
  80. ($hash{saying} =~ /^Disconnected/) ||
  81. ($hash{saying} =~ /^\S+ has quit IRC \(.+\)/) ||
  82. ($hash{saying} =~ /^\S+ has left \#\S+/) ||
  83. ($hash{saying} =~ /^\S+\s\S+ has left \#\S+/) ||
  84. ($hash{saying} =~ /^\S+\s\S+ Quit \S+/) ||
  85. ($hash{saying} eq "You're not channel operator") ||
  86. ($hash{nick} eq 'Attempting' && $hash{saying} =~ /^to rejoin channel/) ||
  87. ($hash{nick} eq 'Rejoined' && $hash{saying} =~ /^channel/) ||
  88. ($hash{saying} =~ /^Retrieving #\S+ info\.\.\./)
  89. ) {
  90. return 0;
  91. } else {
  92. $hash{saying} =~ s/^\Q$hash{nick}\E //;
  93. return \%hash;
  94. }
  95. } else {
  96. return;
  97. }
  98. return \%hash
  99. unless ($action);
  100. }
  101. return;
  102. }
  103. 1;