4
0

ircle.pm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. package Pisg::Parser::Format::ircle;
  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. debug => $args{debug},
  11. normalline => '^(\d+):\d+ \w+:[^\w]+(\w+): (.*)',
  12. actionline => '^(\d+):\d+ \w+:[^\w]+(\w+) (.*)',
  13. thirdline => '^(\d+):(\d+) \w+: \*\*\* (\S+) (\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}/) {
  23. $self->{debug}->("[$lines] Normal: $1 $2 $3");
  24. $hash{hour} = $1;
  25. $hash{nick} = $2;
  26. $hash{saying} = $3;
  27. return \%hash;
  28. } else {
  29. return;
  30. }
  31. }
  32. sub actionline
  33. {
  34. my ($self, $line, $lines) = @_;
  35. my %hash;
  36. if ($line =~ /$self->{actionline}/) {
  37. $self->{debug}->("[$lines] Action: $1 $2 $3");
  38. $hash{hour} = $1;
  39. $hash{nick} = $2;
  40. $hash{saying} = $3;
  41. return \%hash;
  42. } else {
  43. return;
  44. }
  45. }
  46. sub thirdline
  47. {
  48. my ($self, $line, $lines) = @_;
  49. my %hash;
  50. if ($line =~ /$self->{thirdline}/) {
  51. if (defined $8) {
  52. $self->{debug}->("[$lines] ***: $1 $2 $3 $4 $5 $6 $7 $8");
  53. } else {
  54. $self->{debug}->("[$lines] ***: $1 $2 $3 $4 $5 $6 $7");
  55. }
  56. $hash{hour} = $1;
  57. $hash{min} = $2;
  58. $hash{nick} = $3;
  59. if (($5.$6) eq 'beenkicked') {
  60. $hash{kicker} = $11;
  61. } elsif ($3 eq 'Topic') {
  62. $hash{newtopic} = "$6 $7 $8";
  63. } elsif (($3.$4) eq 'Modechange') {
  64. $hash{newmode} = substr($5, 1);
  65. } elsif (($5.$6) eq 'hasjoined') {
  66. $hash{newjoin} = $3;
  67. } elsif (($5.$6) eq 'nowknown') {
  68. $hash{newnick} = $8;
  69. }
  70. return \%hash;
  71. } else {
  72. return;
  73. }
  74. }
  75. 1;