mIRC6hack.pm 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. package Pisg::Parser::Format::mIRC6hack;
  2. # Documentation for the Pisg::Parser::Format modules is found in Template.pm
  3. # To use this logging format, add the following to mIRC's remote script
  4. # section:
  5. =head1 mIRC script
  6. # 2004-11-21 by coaster
  7. alias me {
  8. if ($1) {
  9. .describe $active $1-
  10. echo $color(own) -qt $active ** $me $1-
  11. }
  12. else {
  13. echo $color(info) $active * /me: insufficient parameters
  14. }
  15. }
  16. on ^*:ACTION:*:*:{
  17. echo $color(action) -lt $iif($chan,$chan,$nick) ** $nick $1-
  18. haltdef
  19. }
  20. =cut
  21. use strict;
  22. $^W = 1;
  23. sub new
  24. {
  25. my ($type, %args) = @_;
  26. my $self = {
  27. cfg => $args{cfg},
  28. normalline => '^\[(\d+):\d+:?\d*\] <([^>]+)> (.*)',
  29. actionline => '^\[(\d+):\d+:?\d*\] \*\* (\S+) (.+)',
  30. thirdline => '^\[(\d+):(\d+):?\d*\] \* (.+)'
  31. };
  32. bless($self, $type);
  33. return $self;
  34. }
  35. sub normalline
  36. {
  37. my ($self, $line, $lines) = @_;
  38. my %hash;
  39. if ($line =~ /$self->{normalline}/o) {
  40. $hash{hour} = $1;
  41. $hash{saying} = $3;
  42. ($hash{nick} = $2) =~ s/^[@%\+~&]//o; # Remove prefix
  43. return \%hash;
  44. } else {
  45. return;
  46. }
  47. }
  48. sub actionline
  49. {
  50. my ($self, $line, $lines) = @_;
  51. my %hash;
  52. if ($line =~ /$self->{actionline}/o) {
  53. $hash{hour} = $1;
  54. $hash{saying} = $3;
  55. ($hash{nick} = $2) =~ s/^[@%\+~&]//o; # Remove prefix
  56. return \%hash;
  57. } else {
  58. return;
  59. }
  60. }
  61. sub thirdline
  62. {
  63. my ($self, $line, $lines, $action) = @_;
  64. my %hash;
  65. if ($line =~ /$self->{thirdline}/o) {
  66. my @line = split(/\s/, $3);
  67. $hash{hour} = $1;
  68. $hash{min} = $2;
  69. $hash{saying} = $3;
  70. ($hash{nick} = $line[0]) =~ s/^[@%\+~&]//o; # Remove prefix
  71. if ($#line >= 4 && ($line[1].$line[2]) eq 'waskicked' && ($line[$#line] =~ /\)$/)) {
  72. $hash{kicker} = $line[4];
  73. } elsif ($#line >= 4 && ($line[1].$line[2]) eq 'werekicked' && ($line[$#line] =~ /\)$/)) {
  74. $hash{kicker} = $line[4];
  75. $hash{nick} = $self->{cfg}{maintainer};
  76. } elsif ($#line >= 4 && ($line[1] eq 'changes') && ($line[$#line] =~ /\'$/)) {
  77. $hash{newtopic} = join(' ', @line[4..$#line]);
  78. $hash{newtopic} =~ s/^'//;
  79. $hash{newtopic} =~ s/'$//;
  80. } elsif ($#line >= 3 && ($line[1].$line[2]) eq 'setsmode:') {
  81. $hash{newmode} = $line[3];
  82. } elsif ($#line == 4 && ($line[2].$line[3]) eq 'hasjoined') {
  83. $hash{newjoin} = $line[0];
  84. } elsif ($line[0] eq 'Joins:') { # Alt+O -> IRC -> Options -> Short join/parts
  85. $hash{newjoin} = $line[1];
  86. } elsif ($#line == 5 && ($line[2].$line[3]) eq 'nowknown') {
  87. $hash{newnick} = $line[5];
  88. } elsif ($action) {
  89. if (
  90. ($hash{saying} =~ /^Set by \S+ on \S+ \S+ \d+ \d+:\d+:\d+/) ||
  91. ($hash{saying} =~ /^Now talking in #\S+/) ||
  92. ($hash{saying} =~ /^Topic is \'.*\'/) ||
  93. ($hash{saying} =~ /^Disconnected/) ||
  94. ($hash{saying} =~ /^\S+ has quit IRC \(.+\)/) ||
  95. ($hash{saying} =~ /^\S+ has left \#\S+/) ||
  96. ($hash{saying} =~ /^\S+\s\S+ has left \#\S+/) ||
  97. ($hash{saying} =~ /^\S+\s\S+ Quit \S+/) ||
  98. ($hash{saying} eq "You're not channel operator") ||
  99. ($hash{nick} eq 'Attempting' && $hash{saying} =~ /^to rejoin channel/) ||
  100. ($hash{nick} eq 'Rejoined' && $hash{saying} =~ /^channel/) ||
  101. ($hash{saying} =~ /^Retrieving #\S+ info\.\.\./)
  102. ) {
  103. return 0;
  104. } else {
  105. $hash{saying} =~ s/^\Q$hash{nick}\E //;
  106. return \%hash;
  107. }
  108. } else {
  109. return;
  110. }
  111. return \%hash
  112. unless ($action);
  113. }
  114. return;
  115. }
  116. 1;