eggdrop.pm 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package Pisg::Parser::Format::eggdrop;
  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+):\d+(?:\:\d+)?\] <([^>]+)> (.*)$',
  11. actionline => '^\[(\d+):\d+(?:\:\d+)?\] Action: (\S+) (.*)$',
  12. thirdline => '^\[(\d+):(\d+)(?:\:\d+)?\] (\S+) (\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. $hash{hour} = $1;
  23. $hash{nick} = $2;
  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} = $1;
  36. $hash{nick} = $2;
  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. $hash{hour} = $1;
  49. $hash{min} = $2;
  50. $hash{nick} = $3;
  51. if (($4.$5) eq 'kickedfrom') {
  52. $7 =~ /^ by ([\S]+):\s*(.*)/;
  53. $hash{kicktext} = $2;
  54. $1 =~ /([^!]+)/; # Remove anything after the !
  55. $hash{kicker} = $1;
  56. } elsif ($3 eq 'Topic') {
  57. $7 =~ /^ by (\S*)!(\S+): (.*)/;
  58. $hash{nick} = $1 || $2; # $1 might be empty if topic is reset by server
  59. $hash{newtopic} = $3;
  60. } elsif (($4.$5) eq 'modechange') {
  61. my $newmode = $6;
  62. if ($7 =~ /^ (.+) by ([\S]+)!.*/) {
  63. $hash{modechanges} = $2;
  64. $hash{nick} = $2;
  65. $newmode =~ s/^\'//;
  66. $hash{newmode} = $newmode;
  67. }
  68. } elsif ($5 eq 'joined') {
  69. $hash{newjoin} = $3;
  70. } elsif (($3.$4) eq 'Nickchange:') {
  71. $hash{nick} = $5;
  72. $7 =~ /([\S]+)/;
  73. $hash{newnick} = $1;
  74. } elsif (($3.$4.$5) eq 'Lastmessagerepeated') {
  75. $hash{repeated} = $6;
  76. }
  77. $hash{nick} =~ /([^!]+)/;
  78. $hash{nick} = $1;
  79. return \%hash;
  80. } else {
  81. return;
  82. }
  83. }
  84. 1;