xchat.pm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package Pisg::Parser::Format::xchat;
  2. # Documentation for the Pisg::Parser::Format modules is found in Template.pm
  3. # This module supports both the old and new logformat (after 1.8.7)
  4. use strict;
  5. $^W = 1;
  6. sub new
  7. {
  8. my ($type, %args) = @_;
  9. my $self = {
  10. cfg => $args{cfg},
  11. normalline => '(\d+):\d+:\d+ <([^>\s]+)>\s+(.*)',
  12. actionline => '(\d+):\d+:\d+ \*\s+(\S+) (.*)',
  13. thirdline => '(\d+):(\d+):\d+ .--\s+(\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (.*)',
  14. };
  15. bless($self, $type);
  16. return $self;
  17. }
  18. sub normalline
  19. {
  20. my ($self, $line, $lines) = @_;
  21. my %hash;
  22. if ($line =~ /$self->{normalline}/o) {
  23. $hash{hour} = $1;
  24. $hash{nick} = $2;
  25. $hash{saying} = $3;
  26. return \%hash;
  27. } else {
  28. return;
  29. }
  30. }
  31. sub actionline
  32. {
  33. my ($self, $line, $lines) = @_;
  34. my %hash;
  35. if ($line =~ /$self->{actionline}/o) {
  36. $hash{hour} = $1;
  37. $hash{nick} = $2;
  38. $hash{saying} = $3;
  39. return \%hash;
  40. } else {
  41. return;
  42. }
  43. }
  44. sub thirdline
  45. {
  46. my ($self, $line, $lines) = @_;
  47. my %hash;
  48. if ($line =~ /$self->{thirdline}/o) {
  49. $hash{hour} = $1;
  50. $hash{min} = $2;
  51. $hash{nick} = $3;
  52. if (($4.$5) eq 'haskicked') {
  53. $hash{kicker} = $3;
  54. $hash{nick} = $6;
  55. } elsif (($4.$5) eq 'haschanged') {
  56. $hash{newtopic} = $9;
  57. } elsif (($4.$5) eq 'giveschannel') {
  58. $hash{newmode} = '+o';
  59. } elsif (($4.$5) eq 'removeschannel') {
  60. $hash{newmode} = '-o';
  61. } elsif (($5.$6) eq 'hasjoined') {
  62. $hash{newjoin} = $1;
  63. } elsif (($5.$6) eq 'nowknown') {
  64. $hash{newnick} = $8;
  65. }
  66. return \%hash;
  67. } else {
  68. return;
  69. }
  70. }
  71. 1;