dropegg.pl 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/usr/bin/perl
  2. # Drop Egg
  3. #
  4. # This script takes a heap of daily eggdrop logs and changes them around
  5. # to look a little more mIRC-like. (So that they can be fed through PISG
  6. # and whatnot)
  7. #
  8. # Copyright 2001, Emil Mikulic. <darkmoon7@optushome.com.au>
  9. use Time::Local;
  10. $logdir = "/home/darkmoon/eggdrop/logs";
  11. $logname = "gencorp.log";
  12. $outfile = "gencorp.out";
  13. $channel = "#gencorp";
  14. open(OUTFILE, ">$outfile");
  15. foreach (`ls $logdir/$logname.*`)
  16. {
  17. chomp( $current_log = $_ );
  18. print "Sanitizing $current_log...";
  19. ($year,$mon,$day) = $current_log =~ /$logdir\/$logname\.(\d\d\d\d)(\d\d)(\d\d)/;
  20. $time = timelocal(1,0,0,$day,$mon,$year);
  21. print OUTFILE "\nSession Start: " . localtime($time) . "\n";
  22. print OUTFILE "[00:00] *** Now talking in $channel\n";
  23. foreach (`cat $current_log`)
  24. {
  25. chomp( $line = $_ );
  26. $line =~ s/\cB//g;
  27. $line =~ s/\c_//g;
  28. $line =~ s/\cO//g;
  29. $line =~ s/\cC\d+//g;
  30. # [02:25] DTails (~Dtails@co3033554-a.mckinn1.vic.optushome.com.au) joined #gencorp.
  31. # [14:48] *** shai (cmot_dblah@a1-46.melbpc.org.au) has joined #breakfastclub
  32. if (($line =~ /joined/) && !($line =~ /\</))
  33. {
  34. ($timestamp,$nick,$hostmask) = $line =~ /(\[\d\d\:\d\d\]) (\S+) \(([^)]+)\) joined/;
  35. $line = "$timestamp *** $nick ($hostmask) has joined $channel";
  36. }
  37. # [02:26] DTails (~Dtails@co3033554-a.mckinn1.vic.optushome.com.au) left irc: We're the
  38. # [14:46] *** alice (noidea@dialup-33.ap1-nas7.unite.mel.dav.net.au) Quit
  39. if (($line =~ /left irc/) && !($line =~ /\[\d\d\:\d\d\] \</))
  40. {
  41. ($timestamp,$nick,$hostmask) = $line =~ /(\[\d\d\:\d\d\]) (\S+) \(([^)]+)\) left irc/;
  42. $line = "$timestamp *** $nick ($hostmask) Quit";
  43. }
  44. if (($line =~ /got netsplit/) && !($line =~ /\[\d\d\:\d\d\] \</))
  45. {
  46. ($timestamp,$nick,$hostmask) = $line =~ /(\[\d\d\:\d\d\]) (\S+) \(([^)]+)\) got netsplit/;
  47. $line = "$timestamp *** $nick ($hostmask) Quit";
  48. }
  49. # [19:42] Action: G..... wipes away tear
  50. # [19:42] * G..... is a SED KENT
  51. if ($line =~ /\[\d\d\:\d\d\] Action/)
  52. {
  53. $line =~ s/Action\:/\*/;
  54. }
  55. # [12:06] Nick change: DTails -> DT|Work
  56. # [14:53] *** Death is now known as Memnoch
  57. if ($line =~ /\[\d\d\:\d\d\] Nick change/)
  58. {
  59. $line =~ s/(\[\d\d\:\d\d\]) Nick change\: (\S+) \-\> (\S+)/$1 *** $2 is now known as $3/;
  60. }
  61. # [11:23] #gencorp: mode change '+o ark|tv' by curtis!~curtis@co...
  62. # [11:23] *** curtis sets mode: +o ark
  63. if ($line =~ /\[\d\d\:\d\d\] \#\S+ mode change/)
  64. {
  65. ($timestamp,$mode,$setter) = $line =~
  66. /(\[\d\d\:\d\d\]) \#\S+ mode change \'([^']+)\' by ([^!]+)\!/;
  67. $line = "$timestamp *** $setter sets mode: $mode";
  68. }
  69. # [19:32] Gumpy kicked from #gencorp by curtis: flood
  70. # [18:49] *** darkmoon was kicked by dark|away (BLAM!)
  71. if ($line =~ /\[\d\d\:\d\d\] \S+ kicked from \#/)
  72. {
  73. ($timestamp,$victim,$kicker,$reason) = $line =~
  74. /(\[\d\d\:\d\d\]) (\S+) kicked from \#\S+ by ([^:]+)\: (.+)/;
  75. $line = "$timestamp *** $victim was kicked by $kicker ($reason)";
  76. }
  77. # [00:48] Topic changed on #gen by arknstone!~...: <topic>
  78. # [14:43] *** arknstone changes topic to 'this is a test'
  79. if ($line =~ /\[\d\d\:\d\d\] Topic changed/)
  80. {
  81. ($timestamp,$changer,$topic) = $line =~
  82. /(\[\d\d\:\d\d\]) Topic changed on \#\S+ by ([^!]+)\![^:]+\: (.+)/;
  83. $line = "$timestamp *** $changer changes topic to '$topic'";
  84. }
  85. if (!(($line =~ /got lost/) && !($line =~ /\[\d\d\:\d\d\] \</)))
  86. {
  87. print OUTFILE "$line\n";
  88. }
  89. }
  90. $time = timelocal(59,59,23,$day,$mon,$year);
  91. print OUTFILE "Session Close: " . localtime($time) . "\n";
  92. print "done!\n";
  93. }
  94. close(OUTFILE);