virc98.pm 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package Pisg::Parser::Format::virc98;
  2. # Documentation for the Pisg::Parser::Format modules is found in Template.pm
  3. # Parser for MeGALiTH's Visual IRC 98 on IRCnet (nicks lenght 9 chars)
  4. # by HceZar hcezar@freemail.it
  5. # Fender @ IRCnet #oristano,#italymania
  6. use strict;
  7. $^W = 1;
  8. sub new
  9. {
  10. my ($type, %args) = @_;
  11. my $self = {
  12. cfg => $args{cfg},
  13. normalline => '^(\d+)\.\d+[^ ]+ [<\[](.{1,9})[\]>]\s+(.*)',
  14. actionline => '^(\d+)\.\d+[^ ]+ \* (\S+) (.*)',
  15. thirdline => '^(\d+)\.(\d+)[^ ]+.* \*\*\* (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+) (\S+)(.*)',
  16. };
  17. bless($self, $type);
  18. return $self;
  19. }
  20. sub normalline
  21. {
  22. my ($self, $line, $lines) = @_;
  23. my %hash;
  24. if ($line =~ /$self->{normalline}/o) {
  25. $hash{hour} = $1;
  26. $hash{nick} = remove_prefix($2);
  27. $hash{saying} = $3;
  28. return \%hash;
  29. } else {
  30. return;
  31. }
  32. }
  33. sub actionline
  34. {
  35. my ($self, $line, $lines) = @_;
  36. my %hash;
  37. if ($line =~ /$self->{actionline}/o) {
  38. $hash{hour} = $1;
  39. $hash{nick} = remove_prefix($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}/o) {
  51. $hash{hour} = $1;
  52. $hash{min} = $2;
  53. if (($4.$5) eq 'haskicked') {
  54. $hash{kicker} = $3;
  55. $hash{nick} = $6;
  56. } elsif ($4.$5.$6.$7 eq 'haschangedthetopic') {
  57. $hash{nick} = $3;
  58. $hash{newtopic} = "$11";
  59. } elsif (($3.$4) eq 'Modechange') {
  60. $hash{newmode} = remove_braces($5);
  61. $hash{nick} = $11;
  62. } elsif (($5.$6) eq 'hasjoined') {
  63. $hash{newjoin} = $3;
  64. $hash{nick} = $3;
  65. } elsif (($5.$6) eq 'nowknown') {
  66. $hash{newnick} = $8;
  67. $hash{nick} = $3;
  68. }
  69. return \%hash;
  70. } else {
  71. return;
  72. }
  73. }
  74. sub remove_prefix
  75. {
  76. my $str = shift;
  77. $str =~ s/^@//;
  78. $str =~ s/^\+//;
  79. return $str;
  80. }
  81. sub remove_braces
  82. {
  83. my $str = shift;
  84. $str =~ s/^\[//;
  85. return $str;
  86. }
  87. 1;