dircproxy.pm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package Pisg::Parser::Format::dircproxy;
  2. # Documentation for the Pisg::Parser::Format modules is found in Template.pm
  3. use strict;
  4. $^W = 1;
  5. sub new
  6. {
  7. my ($type, %args) = @_;
  8. my $self = {
  9. cfg => $args{cfg},
  10. normalline => '^<([^!]+)![^>]+>\s\[(\d{2}):\d{2}\]\s(.+)$',
  11. actionline => '^\[([^!]+)![^\]]+\]\s\[(\d{2}):\d{2}\]\sACTION\s(.+)$',
  12. thirdline => '^\-(\S+)\-\s\[(\d{2}:\d{2})\]\s(.+)$'
  13. };
  14. bless($self, $type);
  15. return $self;
  16. }
  17. sub normalline
  18. {
  19. my ($self, $line, $lines) = @_;
  20. my %hash;
  21. if ($line =~ /$self->{normalline}/o) {
  22. $hash{hour} = $2;
  23. $hash{nick} = $1;
  24. $hash{saying} = $3;
  25. return \%hash;
  26. } else {
  27. return;
  28. }
  29. }
  30. sub actionline
  31. {
  32. my ($self, $line, $lines) = @_;
  33. my %hash;
  34. if ($line =~ /$self->{actionline}/o) {
  35. $hash{hour} = $2;
  36. $hash{nick} = $1;
  37. $hash{saying} = $3;
  38. return \%hash;
  39. } else {
  40. return;
  41. }
  42. }
  43. sub thirdline
  44. {
  45. my ($self, $line, $lines) = @_;
  46. my %hash;
  47. if ($line =~ /$self->{thirdline}/o) {
  48. my ($time, @line);
  49. return
  50. if ($1 eq 'dircproxy');
  51. @line = split(/\s+/, $3);
  52. my @time = split(/:/, $2);
  53. $hash{hour} = $time[0];
  54. $hash{min} = $time[1];
  55. $hash{nick} = $line[0];
  56. if (defined($line[3]) && $line[0] eq 'Kicked') {
  57. $hash{kicker} = $line[3];
  58. $hash{nick} = $self->{cfg}->{maintainer};
  59. } elsif (defined($line[4]) && $line[1] eq 'kicked') {
  60. $hash{kicker} = $line[4];
  61. } elsif (defined($line[3]) && $line[2] eq 'changed') {
  62. if ($line[3] eq 'mode:') {
  63. $hash{newmode} = join(' ', @line[4..$#line]);
  64. } elsif ($line[3] eq 'topic:') {
  65. $hash{newtopic} = join(' ', @line[4..$#line]);
  66. }
  67. } elsif (defined($line[2]) && $line[2] eq 'joined') {
  68. $hash{newjoin} = $hash{nick};
  69. }
  70. # elsif ($line[0] eq 'NICK') {
  71. # $hash{newnick} = $line[1];
  72. # $hash{newnick} =~ s/^://;
  73. #}
  74. return \%hash;
  75. } else {
  76. return;
  77. }
  78. }
  79. 1;