Rev 728 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 728 | Rev 892 | ||
|---|---|---|---|
| Line 4... | Line 4... | ||
| 4 | 4 | ||
| 5 |
|
5 | #$outputpath = "outp/"; |
| 6 |
|
6 | #$linenrpath = "linenr.txt"; |
| 7 |
|
7 | #$contentspath = "contents.txt"; |
| 8 |
|
8 | #$currentfilepath = "currentfile.txt"; |
| 9 |
|
9 | #$logfilepath = "#hobby_small.log"; |
| 10 |
|
10 | #$contentsfileoutput = "outp/"; |
| 11 |
|
11 | #$contentsfilename = "hobby.txt"; |
| 12 | $contentsheader = "====== Log of #hobby-channel ======\n"; |
12 | $contentsheader = "====== Log of #hobby-channel ======\n"; |
| 13 |
|
13 | #$namespace = "common:irc:hobby:"; |
| 14 | 14 | ||
| 15 |
|
15 | #require "settings.pl"; |
| - | 16 | use File::Copy; |
|
| 16 | 17 | ||
| 17 | $numArgs = $#ARGV + 1; |
18 | $numArgs = $#ARGV + 1; |
| 18 | if ($numArgs == 1) { |
19 | if ($numArgs == 1) { |
| 19 | if ($ARGV[0] eq "-r") { |
20 | if ($ARGV[0] eq "-r") { |
| 20 | #reset log system |
21 | #reset log system |
| Line 40... | Line 41... | ||
| 40 | print CURRFILE ""; |
41 | print CURRFILE ""; |
| 41 | close(CURRFILE); |
42 | close(CURRFILE); |
| 42 | } |
43 | } |
| 43 | #print "exit\n"; |
44 | #print "exit\n"; |
| 44 | exit; |
45 | exit; |
| - | 46 | } |
|
| - | 47 | } |
|
| - | 48 | ||
| - | 49 | if ($numArgs == 2) { |
|
| - | 50 | if ($ARGV[0] eq "-s") { |
|
| - | 51 | require "$ARGV[1]"; |
|
| 45 | } |
52 | } |
| 46 | } |
53 | } |
| 47 | 54 | ||
| 48 | $startAtLine = 0; |
55 | $startAtLine = 0; |
| 49 | $currentfile = ""; |
56 | $currentfile = ""; |
| 50 | 57 | ||
| 51 | $fileopenerr = 0; |
58 | $fileopenerr = 0; |
| 52 | open (LINENR, "<".$linenrpath) or $fileopenerr = 1; |
59 | open (LINENR, "<".$linenrpath) or $fileopenerr = 1; |
| 53 | if ($fileopenerr == 0) { |
60 | if ($fileopenerr == 0) { |
| 54 | $startAtLine = <LINENR>; |
61 | $startAtLine = <LINENR>; |
| 55 | if ($startAtLine =~ /\D/) { |
62 | if ($startAtLine =~ /\D/) { |
| 56 | print "Not a number\n"; |
63 | print "Not a number: $startAtLine\n"; |
| 57 | exit; |
64 | exit; |
| 58 | } |
65 | } |
| 59 | close(LINENR); |
66 | close(LINENR); |
| 60 | } else { |
67 | } else { |
| 61 | print "Could not open ".$linenrpath; |
68 | print "Could not open ".$linenrpath; |
| 62 | exit; |
69 | exit; |
| 63 | } |
70 | } |
| 64 | 71 | ||
| 65 | $fileopenerr = 0; |
72 | $fileopenerr = 0; |
| Line 73... | Line 80... | ||
| 73 | close(CURRFILE); |
80 | close(CURRFILE); |
| 74 | } else { |
81 | } else { |
| 75 | print "Could not opeen ".$currentfilepath; |
82 | print "Could not opeen ".$currentfilepath; |
| 76 | if ($startAtLine != 0) { |
83 | if ($startAtLine != 0) { |
| 77 | exit; |
84 | exit; |
| 78 | } |
85 | } |
| 79 | } |
86 | } |
| 80 | 87 | ||
| 81 | $fileopenerr = 0; |
88 | $fileopenerr = 0; |
| 82 | open (LOGFILE, "<".$logfilepath) or $fileopenerr = 1; |
89 | open (LOGFILE, "<".$logfilepath) or $fileopenerr = 1; |
| 83 | if ($fileopenerr == 1) { |
90 | if ($fileopenerr == 1) { |
| Line 103... | Line 110... | ||
| 103 | while (<LOGFILE>) { |
110 | while (<LOGFILE>) { |
| 104 | #print $linecnt ." "; |
111 | #print $linecnt ." "; |
| 105 | $line = $_; |
112 | $line = $_; |
| 106 | #$store = ""; |
113 | #$store = ""; |
| 107 | if ($linecnt >= $startAtLine) { |
114 | if ($linecnt >= $startAtLine) { |
| 108 | if ($line =~ m/^Session Time:/) { |
115 | if ($line =~ m/^Session Time:/ || $line =~ m/^Session Start:/) { |
| 109 | #print $line; |
116 | #print $line; |
| 110 | $datetimenice = $line; |
117 | $datetimenice = $line; |
| 111 | $datetimenice =~ s/Session Time: //g; |
118 | $datetimenice =~ s/Session Time: //g; |
| - | 119 | $datetimenice =~ s/Session Start: //g; |
|
| 112 | $datetimenice =~ s/\n//g; |
120 | $datetimenice =~ s/\n//g; |
| 113 | $datetimenice =~ s/\r//g; |
121 | $datetimenice =~ s/\r//g; |
| 114 | 122 | ||
| 115 | $datetime = $line; |
123 | $datetime = $line; |
| 116 | $datetime =~ s/Session Time: //g; |
124 | $datetime =~ s/Session Time: //g; |
| - | 125 | $datetime =~ s/Session Start: //g; |
|
| 117 | $datetime =~ s/://g; |
126 | $datetime =~ s/://g; |
| 118 | $datetime =~ s/\n//g; |
127 | $datetime =~ s/\n//g; |
| 119 | $datetime =~ s/\r//g; |
128 | $datetime =~ s/\r//g; |
| 120 | $datetime =~ s/ /_/g; |
129 | $datetime =~ s/ /_/g; |
| 121 | $datetime = lc($datetime); |
130 | $datetime = lc($datetime); |
| 122 | 131 | ||
| 123 | if ($currentfile) { |
132 | if ($currentfile) { |
| 124 | if ($debugmode == 0) { |
133 | if ($debugmode == 0) { |
| 125 | print OUTFILE "\n\\\\\nNext page: [[".$datetime."]] \\\\ \n"; |
134 | print OUTFILE "\n\\\\\nNext page: [[".$datetime."]] \\\\ \n"; |
| 126 | print OUTFILE "Back to index: [[".$namespace."]] \\\\ \n"; |
135 | print OUTFILE "Back to index: [[".$namespace."]] \\\\ \n"; |
| - | 136 | close(OUTFILE); |
|
| 127 | 137 | ||
| - | 138 | $fileopenerr = 0; |
|
| - | 139 | copy($outputpath.$currentfile, $outputpath."yesterday.txt") or $fileopenerr = 1; |
|
| - | 140 | if ($fileopenerr == 1) { |
|
| - | 141 | print "Could not copy yesterday.txt-log"; |
|
| - | 142 | } |
|
| 128 | } |
143 | } |
| 129 | } |
144 | } |
| 130 | 145 | ||
| 131 | $currentfile = $datetime .".txt"; |
146 | $currentfile = $datetime .".txt"; |
| 132 | # skriv $datetimenice och $datetime till $contentspath |
147 | # skriv $datetimenice och $datetime till $contentspath |
| 133 | $fileopenerr = 0; |
148 | $fileopenerr = 0; |
| 134 | open (CONTENTSFILE, "<".$contentspath) or $fileopenerr = 1; |
149 | open (CONTENTSFILE, "<".$contentspath) or $fileopenerr = 1; |
| 135 | if ($fileopenerr == 0) { |
150 | if ($fileopenerr == 0) { |
| 136 | @contentsfilecontents = <CONTENTSFILE>; |
151 | @contentsfilecontents = <CONTENTSFILE>; |
| 137 | close(CONTENTSFILE); |
152 | close(CONTENTSFILE); |
| 138 | if ($debugmode == 0) { |
153 | if ($debugmode == 0) { |
| 139 | open (CONTENTSFILE, ">".$contentspath) or $fileopenerr = 1; |
154 | open (CONTENTSFILE, ">".$contentspath) or $fileopenerr = 1; |
| 140 | if ($fileopenerr == 0) { |
155 | if ($fileopenerr == 0) { |
| 141 | print CONTENTSFILE "[[$namespace$datetime|$datetimenice]] \\\\ \n"; |
156 | print CONTENTSFILE "[[$namespace$datetime|$datetimenice]] \\\\ \n"; |
| 142 | foreach (@contentsfilecontents) { |
157 | foreach (@contentsfilecontents) { |
| 143 | print CONTENTSFILE $_; |
158 | print CONTENTSFILE $_; |
| Line 161... | Line 176... | ||
| 161 | if ($debugmode == 0) { |
176 | if ($debugmode == 0) { |
| 162 | print OUTFILE "====== ".$datetimenice." ======\n"; |
177 | print OUTFILE "====== ".$datetimenice." ======\n"; |
| 163 | } |
178 | } |
| 164 | } |
179 | } |
| 165 | #print $datetime; |
180 | #print $datetime; |
| 166 | } |
181 | } |
| 167 | 182 | ||
| 168 | elsif ($currentfile) { |
183 | elsif ($currentfile) { |
| 169 | $parsedLine = $line; |
184 | $parsedLine = $line; |
| 170 | $parsedLine =~ s/\n//g; |
185 | $parsedLine =~ s/\n//g; |
| 171 | $parsedLine =~ s/\r//g; |
186 | $parsedLine =~ s/\r//g; |
| 172 | #$parsedLine = $parsedLine; |
187 | #$parsedLine = $parsedLine; |
| Line 191... | Line 206... | ||
| 191 | #$nickB = sprintf("%x", ((($nickVal & 7)**2)*2.3+5)); |
206 | #$nickB = sprintf("%x", ((($nickVal & 7)**2)*2.3+5)); |
| 192 | #$nickG = sprintf("%x", (((($nickVal >> 3) & 7)**2.3)*2+5)); |
207 | #$nickG = sprintf("%x", (((($nickVal >> 3) & 7)**2.3)*2+5)); |
| 193 | #$nickR = sprintf("%x", (((($nickVal >> 6) & 7)**2.3)*2+5)); |
208 | #$nickR = sprintf("%x", (((($nickVal >> 6) & 7)**2.3)*2+5)); |
| 194 | #if (length($nickB) == 1) { |
209 | #if (length($nickB) == 1) { |
| 195 | # $nickB = "0".$nickB; |
210 | # $nickB = "0".$nickB; |
| 196 | #} |
211 | #} |
| 197 | #if (length($nickG) == 1) { |
212 | #if (length($nickG) == 1) { |
| 198 | # $nickG = "0".$nickG; |
213 | # $nickG = "0".$nickG; |
| 199 | #} |
214 | #} |
| 200 | #if (length($nickR) == 1) { |
215 | #if (length($nickR) == 1) { |
| 201 | # $nickR = "0".$nickR; |
216 | # $nickR = "0".$nickR; |
| Line 206... | Line 221... | ||
| 206 | $parsedLine =~ s/<$nick>/<color $colors[$nickVal]><$nick><\/color>/; |
221 | $parsedLine =~ s/<$nick>/<color $colors[$nickVal]><$nick><\/color>/; |
| 207 | #print $nick." ".$nickVal."\n"; |
222 | #print $nick." ".$nickVal."\n"; |
| 208 | #print $parsedLine ."\n"; |
223 | #print $parsedLine ."\n"; |
| 209 | } |
224 | } |
| 210 | 225 | ||
| - | 226 | #$parsedLine =~ s/\/\//\//g; |
|
| - | 227 | $parsedLine =~ s/''/'/g; |
|
| - | 228 | $parsedLine =~ s/\[\[/\[/g; |
|
| - | 229 | $parsedLine =~ s/\]\]/\]/g; |
|
| - | 230 | $parsedLine =~ s/\(\(/\(/g; |
|
| - | 231 | $parsedLine =~ s/\)\)/\)/g; |
|
| - | 232 | $parsedLine =~ s/____/_/g; |
|
| - | 233 | $parsedLine =~ s/___/_/g; |
|
| - | 234 | $parsedLine =~ s/__/_/g; |
|
| - | 235 | $parsedLine =~ s/\*\*/\*/g; |
|
| - | 236 | ||
| 211 | $parsedLine =~ s/\x{e5}/å/g; |
237 | $parsedLine =~ s/\x{e5}/å/g; |
| 212 | $parsedLine =~ s/\x{e4}/ä/g; |
238 | $parsedLine =~ s/\x{e4}/ä/g; |
| 213 | $parsedLine =~ s/\x{f6}/ö/g; |
239 | $parsedLine =~ s/\x{f6}/ö/g; |
| 214 | $parsedLine =~ s/\x{c5}/Å/g; |
240 | $parsedLine =~ s/\x{c5}/Å/g; |
| 215 | $parsedLine =~ s/\x{c4}/Ä/g; |
241 | $parsedLine =~ s/\x{c4}/Ä/g; |
| Line 217... | Line 243... | ||
| 217 | 243 | ||
| 218 | $parsedLine =~ s/\[wiki\]/**[wiki]**/g; |
244 | $parsedLine =~ s/\[wiki\]/**[wiki]**/g; |
| 219 | $parsedLine =~ s/\[svn\]/**[svn]**/g; |
245 | $parsedLine =~ s/\[svn\]/**[svn]**/g; |
| 220 | 246 | ||
| 221 | $parsedLine .= " "; |
247 | $parsedLine .= " "; |
| 222 | $parsedLine =~ s/http:\/\/projekt\.auml\.se\/( |
248 | $parsedLine =~ s/http:\/\/projekt\.auml\.se\/(\S+)/[[:$1]] /g; |
| 223 | 249 | ||
| 224 | $parsedLine .= "\\\\"."\n"; |
250 | $parsedLine .= "\\\\"."\n"; |
| 225 | if ($debugmode == 0) { |
251 | if ($debugmode == 0) { |
| 226 | print OUTFILE $parsedLine; |
252 | print OUTFILE $parsedLine; |
| 227 | } |
253 | } |
| 228 | } |
254 | } |
| 229 | #print $store; |
255 | #print $store; |
| 230 | 256 | ||
| 231 | } |
257 | } |
| 232 | $linecnt++; |
258 | $linecnt++; |
| - | 259 | } |
|
| - | 260 | close(OUTFILE); |
|
| - | 261 | ||
| - | 262 | $fileopenerr = 0; |
|
| - | 263 | copy($outputpath.$currentfile, $outputpath."today.txt") or $fileopenerr = 1; |
|
| - | 264 | if ($fileopenerr == 1) { |
|
| - | 265 | print "Could not copy today.txt-log"; |
|
| 233 | } |
266 | } |
| 234 | 267 | ||
| 235 | if ($debugmode == 0) { |
268 | if ($debugmode == 0) { |
| 236 | $fileopenerr = 0; |
269 | $fileopenerr = 0; |
| 237 | open (LINENR, ">".$linenrpath) or $fileopenerr = 1; |
270 | open (LINENR, ">".$linenrpath) or $fileopenerr = 1; |
| Line 260... | Line 293... | ||
| 260 | open (NICECONTENTSFILE, ">".$contentsfileoutput.$contentsfilename) or $fileopenerr = 1; |
293 | open (NICECONTENTSFILE, ">".$contentsfileoutput.$contentsfilename) or $fileopenerr = 1; |
| 261 | if ($fileopenerr == 0) { |
294 | if ($fileopenerr == 0) { |
| 262 | @contentsfilecontents = <CONTENTSFILE>; |
295 | @contentsfilecontents = <CONTENTSFILE>; |
| 263 | print NICECONTENTSFILE $contentsheader; |
296 | print NICECONTENTSFILE $contentsheader; |
| 264 | foreach (@contentsfilecontents) { |
297 | foreach (@contentsfilecontents) { |
| 265 |
|
298 | print NICECONTENTSFILE $_; |
| 266 | } |
299 | } |
| 267 | close(NICECONTENTSFILE); |
300 | close(NICECONTENTSFILE); |
| 268 | } else { |
301 | } else { |
| 269 | print "Could not open ".$contentsfileoutput.$contentsfilename; |
302 | print "Could not open ".$contentsfileoutput.$contentsfilename; |
| 270 | exit; |
303 | exit; |
| Line 275... | Line 308... | ||
| 275 | exit; |
308 | exit; |
| 276 | } |
309 | } |
| 277 | } |
310 | } |
| 278 | 311 | ||
| 279 | #print $linecnt-1 ." - ". $line; |
312 | #print $linecnt-1 ." - ". $line; |
| 280 | - | ||
| 281 | - | ||
| 282 | - | ||
| 283 | - | ||
| 284 | - | ||
| 285 | - | ||
| 286 | - | ||