winbot.pm 2.2 KB

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