4
0

bobot.pm 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # package for bobot parsing made by Oct@zoy.org
  2. package Pisg::Parser::Format::bobot;
  3. # Documentation for the Pisg::Parser::Format modules is found in Template.pm
  4. use strict;
  5. $^W = 1;
  6. sub new
  7. {
  8. my ($type, %args) = @_;
  9. my $self = {
  10. cfg => $args{cfg},
  11. normalline => '^\[[^-]+- ([^:]+):[^\]]+\] <([^>]+)> (.*)$',
  12. actionline => '^\[[^-]+- ([^:]+):[^\]]+\] \* ([^ ]+) (.*)$',
  13. thirdline => '^\[[^-]+- ([^:]+):([^\]]+)\] \*\*\* ([^ ]+) \[[^\]]+\] (.*)$',
  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. $hash{hour} = $1;
  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}/) {
  36. $hash{hour} = $1;
  37. $hash{nick} = $2;
  38. $hash{saying} = $3;
  39. return \%hash;
  40. } else {
  41. return;
  42. }
  43. }
  44. sub thirdline
  45. {
  46. my ($self, $line, $lines) = @_;
  47. my %hash;
  48. if ($line =~ /$self->{thirdline}/) {
  49. $hash{hour} = $1;
  50. $hash{min} = $2;
  51. $hash{nick} = $3;
  52. if($4 =~ /^topic ([^ ]+) \((.*)\)$/)
  53. {
  54. $hash{newtopic}= $2;
  55. } elsif($4 =~ /^mode ([\+-]o+) (.*)$/)
  56. {
  57. $hash{newmode} = $1;
  58. $hash{nick} = $2;
  59. } elsif($4 =~/^kick ([^ ]+) .*$/)
  60. {
  61. $hash{kicker} = $hash{nick};
  62. $hash{nick} = $1;
  63. } elsif($4 =~/^join .*$/)
  64. {
  65. $hash{newjoin} = $hash{nick};
  66. }
  67. return \%hash;
  68. } else {
  69. return;
  70. }
  71. }
  72. 1;