dircproxy.pm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 => '^@(\d+)\s<([^!]+)![^>]+>\s(.+)$',
  11. actionline => '^@(\d+)\s\[([^!]+)![^\]]+\]\sACTION\s(.+)$',
  12. thirdline => '^@(\d+)\s\-(\S+)\-\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. my @time = localtime($1);
  23. $hash{hour} = $time[2];
  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. my @time = localtime($1);
  37. $hash{hour} = $time[2];
  38. $hash{nick} = $2;
  39. $hash{saying} = $3;
  40. return \%hash;
  41. } else {
  42. return;
  43. }
  44. }
  45. sub thirdline
  46. {
  47. my ($self, $line, $lines) = @_;
  48. my %hash;
  49. if ($line =~ /$self->{thirdline}/o) {
  50. my ($time, @line);
  51. return
  52. if ($2 eq 'dircproxy');
  53. @line = split(/\s+/, $3);
  54. my @time = localtime($1);
  55. $hash{hour} = $time[2];
  56. $hash{min} = $time[1];
  57. $hash{nick} = $line[0];
  58. if ($line[0] eq 'Kicked') {
  59. $hash{kicker} = $line[3];
  60. $hash{nick} = $self->{cfg}->{maintainer};
  61. } elsif ($line[1] eq 'kicked') {
  62. $hash{kicker} = $line[4];
  63. } elsif ($line[2] eq 'changed') {
  64. if ($line[3] eq 'mode:') {
  65. $hash{newmode} = join(' ', @line[4..$#line]);
  66. } elsif ($line[3] eq 'topic:') {
  67. $hash{newtopic} = join(' ', @line[4..$#line]);
  68. }
  69. } elsif ($line[2] eq 'joined') {
  70. $hash{newjoin} = $hash{nick};
  71. }
  72. # elsif ($line[0] eq 'NICK') {
  73. # $hash{newnick} = $line[1];
  74. # $hash{newnick} =~ s/^://;
  75. #}
  76. return \%hash;
  77. } else {
  78. return;
  79. }
  80. }
  81. 1;