Changeset 1026
- Timestamp:
- 08/29/09 04:42:03 (2 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
modules/abstract.tcl (modified) (1 diff)
-
modules/diagnostics.tcl (modified) (1 diff)
-
modules/output.tcl (modified) (6 diffs)
-
plugins/admin_abstract.tcl (modified) (2 diffs)
-
plugins/en/output_VAR.tcl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/abstract.tcl
r1022 r1026 621 621 } 622 622 623 # implementation-independent way to get all abstract names 624 proc bMotion_abstract_get_names { } { 625 global bMotion_abstract_contents 626 return [array names bMotion_abstract_contents] 627 } 623 628 624 629 bind time - "* * * * *" bMotion_abstract_auto_gc -
trunk/modules/diagnostics.tcl
r947 r1026 328 328 } 329 329 330 ### bMotion_diagnostic_parsing 331 # Try to build every abstract we can and make sure it parses ok 332 # This is not run automatically! 333 # This is run as an admin plugin, so it tries to output to the admin stuff 334 proc bMotion_diagnostic_parsing { } { 335 bMotion_putadmin "Counting abstracts..." 336 set all_abstracts [bMotion_abstract_get_names] 337 set all_abstracts_size [llength $all_abstracts] 338 bMotion_putadmin "Found $all_abstracts_size abstracts" 339 340 set broken [list] 341 set errors 0 342 set count_abstract 0 343 set count_lines 0 344 set i 0 345 346 foreach abstract $all_abstracts { 347 incr i 348 if {[expr $i % 10] == 0} { 349 bMotion_putadmin "Processing abstract $i: $abstract..." 350 } 351 set abstract_contents [bMotion_abstract_all $abstract] 352 bMotion_putloglev d * "Processing [llength $abstract_contents] items for abstract $abstract" 353 incr count_abstract 354 foreach content $abstract_contents { 355 incr count_lines 356 set line "" 357 set fail "" 358 catch { 359 set line [bMotion_process_macros "" $content] 360 set line [bMotionDoInterpolation $line "JamesOff" "moretext" "#diagnostics"] 361 # bit of a hack! 362 set line [bMotion_plugin_output_preprocess "#diagnostics" $line] 363 } 364 if {($line == "") || [regexp {%(?!(SETTING|ruser|r?bot|BOT|percent|channel))[^%2\| ]} $line matches moo]} { 365 incr errors 366 lappend broken "$abstract:$content\r\n -> $line" 367 } 368 } 369 } 370 371 bMotion_putadmin "Finished." 372 bMotion_putadmin "$errors errors found in $count_lines lines in $count_abstract abstracts." 373 foreach line $broken { 374 bMotion_putadmin $line 375 } 376 } 377 330 378 ### bMotion_diagnostic_auto <<<1 331 379 proc bMotion_diagnostic_auto { min hr a b c } { -
trunk/modules/output.tcl
r1022 r1026 121 121 } 122 122 123 # 124 # our magic output function 125 proc bMotionDoAction {channel nick text {moreText ""} {noTypo 0} {urgent 0} } { 126 bMotion_putloglev 5 * "bMotionDoAction($channel,$nick,$text,$moreText,$noTypo,$urgent)" 127 global bMotionInfo bMotionCache bMotionOriginalInput 128 global bMotion_output_delay bMotionSettings BMOTION_SLEEP 129 130 set bMotion_output_delay 0 131 132 #check our global toggle 133 global bMotionGlobal 134 if {$bMotionGlobal == 0} { 135 return 0 136 } 137 138 set bMotionCache($channel,last) 1 139 140 # check if we're asleep 141 if {[bMotion_setting_get "asleep"] == $BMOTION_SLEEP(ASLEEP)} { 142 return 0 143 } 144 145 if [regexp "^\[#!\].+" $channel] { 146 set channel [string tolower $channel] 147 if {![channel get $channel bmotion]} { 148 bMotion_putloglev d * "bMotion: aborting bMotionDoAction ... $channel not allowed" 149 return 0 150 } 151 } 152 153 if {[bMotion_setting_get "silence"] == 1} { 154 return 0 155 } 156 catch { 157 if {$bMotionInfo(adminSilence,$channel) == 1} { 158 return 0 159 } 160 } 161 162 switch [rand 3] { 163 0 { } 164 1 { set nick [string tolower $nick] } 165 2 { set nick "[string range $nick 0 0][string tolower [string range $nick 1 end]]" } 166 } 167 168 # Process macros 123 proc bMotion_process_macros { channel text } { 169 124 170 125 set done 0 … … 174 129 set current_pos [string first "%" $text $current_pos] 175 130 if {$current_pos == -1} { 176 # no more matches131 # no more matches 177 132 set done 1 178 133 continue … … 180 135 bMotion_putloglev d * "macro: found a % at $current_pos" 181 136 if {$current_pos < [string length $text]} { 182 # this isn't a % at the end of the line137 # this isn't a % at the end of the line 183 138 if {[string index $text [expr $current_pos + 1]] == "|"} { 184 139 set current_pos [expr $current_pos + 2] … … 192 147 set plugin [bMotion_plugin_find_output "en" "" 0 10 $macro] 193 148 if {[llength $plugin] == 1} { 194 # call plugin149 # call plugin 195 150 bMotion_putloglev d * "macro: found matching plugin for macro [lindex $plugin 0]" 196 151 set result "" … … 235 190 incr current_pos 236 191 } 192 193 return $text 194 } 195 196 # 197 # our magic output function 198 proc bMotionDoAction {channel nick text {moreText ""} {noTypo 0} {urgent 0} } { 199 bMotion_putloglev 5 * "bMotionDoAction($channel,$nick,$text,$moreText,$noTypo,$urgent)" 200 global bMotionInfo bMotionCache bMotionOriginalInput 201 global bMotion_output_delay bMotionSettings BMOTION_SLEEP 202 203 set bMotion_output_delay 0 204 205 #check our global toggle 206 global bMotionGlobal 207 if {$bMotionGlobal == 0} { 208 return 0 209 } 210 211 set bMotionCache($channel,last) 1 212 213 # check if we're asleep 214 if {[bMotion_setting_get "asleep"] == $BMOTION_SLEEP(ASLEEP)} { 215 return 0 216 } 217 218 if [regexp "^\[#!\].+" $channel] { 219 set channel [string tolower $channel] 220 if {![channel get $channel bmotion]} { 221 bMotion_putloglev d * "bMotion: aborting bMotionDoAction ... $channel not allowed" 222 return 0 223 } 224 } 225 226 if {[bMotion_setting_get "silence"] == 1} { 227 return 0 228 } 229 catch { 230 if {$bMotionInfo(adminSilence,$channel) == 1} { 231 return 0 232 } 233 } 234 235 switch [rand 3] { 236 0 { } 237 1 { set nick [string tolower $nick] } 238 2 { set nick "[string range $nick 0 0][string tolower [string range $nick 1 end]]" } 239 } 240 241 # Process macros 242 243 set text [bMotion_process_macros $channel $text] 237 244 238 245 # Run the plugins :D … … 482 489 } 483 490 484 regsub -all "% %" $line "%percent" line491 regsub -all "%" $line "%percent" line 485 492 486 493 return $line -
trunk/plugins/admin_abstract.tcl
r862 r1026 78 78 bMotion_abstract_flush 79 79 bMotion_putadmin "Flushing all abstracts to disk..." 80 return 0 81 } 82 83 if [regexp -nocase "diagnose" $arg] { 84 bMotion_diagnostic_parsing 80 85 return 0 81 86 } … … 161 166 bMotion_putadmin " .bmotion abstract filter apply <abstract>" 162 167 bMotion_putadmin " For an abstract to be filtered now" 168 bMotion_putadmin " .bmotion abstract diagnose" 169 bMotion_putadmin " Test all abstracts for parsability and report any broken ones" 163 170 return 0 164 171 } -
trunk/plugins/en/output_VAR.tcl
r1022 r1026 118 118 119 119 # check if what we swapped in gave us a %noun 120 if [string match "*%noun*" $line] { 121 set line [bMotionInsertString $line "%noun" "%VAR{sillyThings}"] 122 } 120 set line [string map { "%noun" "%VAR{sillyThings}" } $line] 123 121 } 124 122
Note: See TracChangeset
for help on using the changeset viewer.
