winbot.pm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package Pisg::Parser::Format::winbot;
  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):\d\d\.\d\d \d+\/\d+\/\d+ <([^\/]+)\/([^\>]+)> (.*)',
  12. actionline => '^(\d\d):\d\d\.\d\d \d+\/\d+\/\d+ \* ([^\/]+)\/(\S+) (.*)',
  13. thirdline => '^(\d\d):(\d\d)\.\d\d \d+\/\d+\/\d+ \*{3}\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 && $3 eq $self->{cfg}->{channel}) {
  23. $self->{debug}->("[$lines] Normal: $1 $2 $3 $4");
  24. $hash{hour} = $1;
  25. $hash{nick} = $2;
  26. $hash{saying} = $4;
  27. return \%hash;
  28. }
  29. return;
  30. }
  31. sub actionline
  32. {
  33. my ($self, $line, $lines) = @_;
  34. my %hash;
  35. if ($line =~ /$self->{actionline}/o && $3 eq $self->{cfg}->{channel}) {
  36. $self->{debug}->("[$lines] Action: $1 $2 $3 $4");
  37. $hash{hour} = $1;
  38. $hash{nick} = $2;
  39. $hash{saying} = $4;
  40. return \%hash;
  41. }
  42. return;
  43. }
  44. sub thirdline
  45. {
  46. my ($self, $line, $lines) = @_;
  47. my %hash;
  48. if ($line =~ /$self->{thirdline}/o) {
  49. $self->{debug}->("[$lines] ***: $1 $2 $3");
  50. $hash{hour} = $1;
  51. $hash{min} = $2;
  52. $hash{nick} = $3;
  53. if ($3 =~ /^(\S+) was kicked from (\S+) by (\S+) .+/) {
  54. if ($2 eq $self->{cfg}->{channel}) {
  55. $hash{nick} = $1;
  56. $hash{kicker} = $3;
  57. }
  58. } elsif ($3 =~ /^([^\/]+)\/(\S+) changes topic to \"(.+)\"[^\"]*$/) {
  59. if ($2 eq $self->{cfg}->{channel}) {
  60. $hash{nick} = $1;
  61. $hash{newtopic} = $3;
  62. }
  63. } elsif ($3 =~ /^([^\/]+)\/(\S+) sets mode: (\S+) [^\)]+/) {
  64. if ($2 eq $self->{cfg}->{channel}) {
  65. $hash{nick} = $1;
  66. $hash{newmode} = $3;
  67. }
  68. } elsif ($3 =~ /^(\S+) has joined (\S+)/) {
  69. if ($2 eq $self->{cfg}->{channel}) {
  70. $hash{nick} = $1;
  71. $hash{newjoin} = $1;
  72. }
  73. } elsif ($3 =~ /^(\S+) is now known as (\S+)/) {
  74. $hash{nick} = $1;
  75. $hash{newnick} = $2;
  76. }
  77. return \%hash;
  78. } else {
  79. return;
  80. }
  81. }
  82. 1;