Changeset 891 for trunk

Show
Ignore:
Timestamp:
02/17/08 18:54:27 (11 months ago)
Author:
james
Message:

exciting times

Location:
trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/abstract.tcl

    r862 r891  
    344344        } 
    345345 
     346} 
     347 
     348# look to see if an abstract contains an item (warning: could be slow) 
     349proc bMotion_abstract_contains { abstract item } { 
     350        bMotion_putloglev 4 * "abstract: bMotion_abstract_contains $abstract $item" 
     351 
     352        set contents [bMotion_abstract_all $abstract] 
     353        putlog $contents 
     354 
     355        if {[llength $contents] == 0} { 
     356                return 0 
     357        } 
     358 
     359        set location [lsearch $contents $item] 
     360        if {$location > -1} { 
     361                return 1 
     362        } else { 
     363                return 0 
     364        } 
    346365} 
    347366 
  • trunk/modules/abstracts/en/abstracts.tcl

    r882 r891  
    10281028bMotion_abstract_register "lols" 
    10291029bMotion_abstract_register "lostPlot" 
    1030 bMotion_abstract_register "loveresponses" 
    10311030bMotion_abstract_register "makeItSos" 
    10321031bMotion_abstract_register "mingreplies" 
     
    11241123bMotion_abstract_batchadd "sorryoks" [list "ok" "that's ok" "alright then" "i forgive you" "/spanks %%%|%BOT\[¬VAR{rarrs}\]" "That's ok then. I suppose. Don't think this makes me like you again though" "humph" ] 
    11251124 
    1126 bMotion_abstract_batchadd "loveresponses" [list "awww thanks" "i love you too" "i wuv you too" "and i love you" "and i wuv you" "aww wuv you too" "awww *giggle*" "i love you just as much" "i want to have your babies" "/blushes" "hehe thanks" "you know, I've always loved you the most" ":*" ":x" ] 
     1125bMotion_abstract_register "loveresponses" { 
     1126        "awww thanks"  
     1127        "i love you too"  
     1128        "i wuv you too"  
     1129        "and i love you"  
     1130        "and i wuv you"  
     1131        "aww wuv you too"  
     1132        "awww *giggle*"  
     1133        "i love you just as much"  
     1134        "i want to have your babies"  
     1135        "/blushes"  
     1136        "hehe thanks"  
     1137        "you know, I've always loved you the most"  
     1138        ":*"  
     1139        ":x" 
     1140        "and i love you th%REPEAT{3:7:i}s much: <%REPEAT{10:50:-}>" 
     1141} 
     1142 
     1143bMotion_abstract_register "loveresponses_male" { 
     1144        "and i love you th%REPEAT{3:7:i}s much:%|*schwing*%|%VAR{oops}" 
     1145} 
    11271146 
    11281147bMotion_abstract_batchadd "hugs" [list "*hugs %%*" "/huggles %%" "/snuggles %%" "*snuggles %%*" "/huggles with %%" "/squeezes %%" "/snoofles %%" ] 
  • trunk/modules/friendship.tcl

    r889 r891  
    6363proc setFriendshipHandle { handle friendship } { 
    6464        if {$friendship > 100} { 
    65                 bMotion_putloglev 2 * "friendship: friendship for $nick went over 100, capping back to 90" 
     65                bMotion_putloglev 2 * "friendship: friendship for $handle went over 100, capping back to 90" 
    6666                set friendship 90 
    6767        } 
    6868 
    6969        if {$friendship < 1} { 
    70                 bMotion_putloglev 2 * "friendship: friendship for $nick went under 1, capping back to 10" 
     70                bMotion_putloglev 2 * "friendship: friendship for $handle went under 1, capping back to 10" 
    7171                set friendship 10 
    7272        } 
     
    8585                if {![validuser $nick]} { 
    8686                        bMotion_putloglev 1 * "friendship: couldn't find a handle for $nick to set friendship." 
    87                         return 50 
     87                        return 0 
    8888                } 
    8989                set handle $nick 
    9090        } 
    9191 
    92  
    93         if {$friendship > 100} { 
    94                 bMotion_putloglev 2 * "friendship: friendship for $nick went over 100, capping back to 9" 
    95                 set friendship 99 
    96         } 
    97  
    98         if {$friendship < 0} { 
    99                 bMotion_putloglev 2 * "friendship: friendship for $nick went under 0, capping back to 1" 
    100                 set friendship 1 
    101         } 
    102  
    103  
    104         catch { 
    105                 setuser $handle XTRA friend $friendship 
    106         } 
     92        setFriendshipHandle $handle $friendship 
    10793} 
    10894 
  • trunk/modules/output.tcl

    r882 r891  
    3131 
    3232proc pickRandom { list } { 
    33                 bMotion_putloglev 5 * "pickRandom ($list)" 
     33        bMotion_putloglev 5 * "pickRandom ($list)" 
    3434        return [lindex $list [rand [llength $list]]] 
    3535} 
    3636 
    3737proc getPronoun {} { 
    38                 bMotion_putloglev 5 * "getPronoun" 
     38        bMotion_putloglev 5 * "getPronoun" 
    3939        global bMotionInfo 
    4040        if {$bMotionInfo(gender) == "male"} { return "himself" } 
     
    4444 
    4545proc getHisHers {} { 
    46                 bMotion_putloglev 5 * "getHisHers" 
     46        bMotion_putloglev 5 * "getHisHers" 
    4747        global bMotionInfo 
    4848        if {$bMotionInfo(gender) == "male"} { return "his" } 
     
    5252 
    5353proc getHisHer {} { 
    54                 bMotion_putloglev 5 * "getHisHer" 
     54        bMotion_putloglev 5 * "getHisHer" 
    5555        global bMotionInfo 
    5656        if {$bMotionInfo(gender) == "male"} { return "his" } 
     
    6161 
    6262proc getHeShe {} { 
    63                 bMotion_putloglev 5 * "getHeShe" 
     63        bMotion_putloglev 5 * "getHeShe" 
    6464        global bMotionInfo 
    6565        if {$bMotionInfo(gender) == "male"} { return "he" } 
     
    7070 
    7171proc mee {channel action {urgent 0} } { 
    72                 bMotion_putloglev 5 * "mee ($channel, $action, $urgent)" 
     72        bMotion_putloglev 5 * "mee ($channel, $action, $urgent)" 
    7373        set channel [chandname2name $channel] 
    7474        if {$urgent} { 
     
    8484        bMotion_putloglev 5 * "bMotionDoAction($channel,$nick,$text,$moreText,$noTypo)" 
    8585        global bMotionInfo bMotionCache bMotionOriginalInput 
    86                 global bMotion_output_delay bMotionSettings BMOTION_SLEEP 
    87  
    88                 set bMotion_output_delay 0 
     86        global bMotion_output_delay bMotionSettings BMOTION_SLEEP 
     87 
     88        set bMotion_output_delay 0 
    8989 
    9090        set bMotionCache($channel,last) 1 
     
    9696        } 
    9797 
    98                 # check if we're asleep 
    99                 if {$bMotionSettings(asleep) == $BMOTION_SLEEP(ASLEEP)} { 
    100                                 return 0 
    101                 } 
     98        # check if we're asleep 
     99        if {$bMotionSettings(asleep) == $BMOTION_SLEEP(ASLEEP)} { 
     100        return 0 
     101        } 
    102102 
    103103        if [regexp "^\[#!\].+" $channel] { 
    104104                set channel [string tolower $channel] 
    105                                 if {![channel get $channel bmotion]} { 
     105                if {![channel get $channel bmotion]} { 
    106106                        bMotion_putloglev d * "bMotion: aborting bMotionDoAction ... $channel not allowed" 
    107107                        return 0 
     
    137137 
    138138                while {[string match "*%|*" $text]} { 
    139                                                 set origtext $text 
     139                        set origtext $text 
    140140                        set sentence [string range $text 0 [expr [string first "%|" $text] -1]] 
    141141                        if {$sentence != ""} { 
     
    148148                        } 
    149149                        set text [string range $text [expr [string first "%|" $text] + 2] end] 
    150                                                 if {$text == $origtext} { 
     150                        if {$text == $origtext} { 
    151151                                putlog "bMotion ALERT! Bailed in bMotionDoAction with $text. Lost output." 
    152152                                return 0 
     
    341341 
    342342proc bMotionInterpolation2 { line } { 
    343                 bMotion_putloglev 5 * "bMotionInterpolation2 ($line)" 
     343        bMotion_putloglev 5 * "bMotionInterpolation2 ($line)" 
    344344        #owners 
    345345        set loops 0 
     
    348348                set BOOM [string map {\\ \\\\ [ \\\[ ] \\\] \{ \\\{ \} \\\} $ \\\$ \" \\\" | \\\|} $BOOM] 
    349349 
    350                 incr loops 
    351                 if {$loops > 10} { 
    352                         putlog "bMotion: ALERT! looping too much in %OWNER code with $line" 
    353                         set line "/has a tremendous error while trying to sort something out :(" 
    354                 } 
    355                 # set line [bMotionInsertString $line "%OWNER\{$BOOM\}" [bMotionMakePossessive $BOOM]] 
    356                 regsub -nocase "%OWNER\{$BOOM\}" $line [bMotionMakePossessive $BOOM] line 
    357                 regsub -all "\\\\" $line "" line 
    358         } 
    359  
    360         set loops 0 
    361         while {[regexp -nocase "%VERB\{(.*?)\}" $line matches BOOM]} { 
    362                 incr loops 
    363                 if {$loops > 10} { 
    364                         putlog "bMotion: ALERT! looping too much in %VERB code with $line" 
    365                         set line "/has a tremendous error while trying to sort something out :(" 
    366                 } 
    367                 # set line [bMotionInsertString $line "%VERB\{$BOOM\}" [bMotionMakeVerb $BOOM]] 
    368                 regsub -nocase "%VERB\{$BOOM\}" $line [bMotionMakeVerb $BOOM] line 
    369         } 
    370  
    371         set loops 0 
    372         while {[regexp -nocase "%PLURAL\{(.*?)\}" $line matches BOOM]} { 
    373                 incr loops 
    374                 if {$loops > 10} { 
    375                         putlog "bMotion: ALERT! looping too much in %PLURAL code with $line" 
    376                         set line "/has a tremendous error while trying to sort something out :(" 
    377                 } 
    378                 # set line [bMotionInsertString $line "%PLURAL\{$BOOM\}" [bMotionMakePlural $BOOM]] 
    379                 regsub -nocase "%PLURAL\{$BOOM\}" $line [bMotionMakePlural $BOOM] line 
    380         } 
    381  
    382         set loops 0 
    383         while {[regexp -nocase "%REPEAT\{(.+?)\}" $line matches BOOM]} { 
    384                 incr loops 
    385                 if {$loops > 10} { 
    386                         putlog "bMotion: ALERT! looping too much in %REPEAT code with $line" 
    387                         set line "/has a tremendous error while trying to sort something out :(" 
    388                 } 
    389                                 set replacement [bMotionMakeRepeat $BOOM] 
    390                 regsub -nocase "%REPEAT\\{$BOOM\\}" $line $replacement line 
    391         } 
    392  
    393         return $line 
     350        incr loops 
     351        if {$loops > 10} { 
     352                putlog "bMotion: ALERT! looping too much in %OWNER code with $line" 
     353                set line "/has a tremendous error while trying to sort something out :(" 
     354        } 
     355        # set line [bMotionInsertString $line "%OWNER\{$BOOM\}" [bMotionMakePossessive $BOOM]] 
     356        regsub -nocase "%OWNER\{$BOOM\}" $line [bMotionMakePossessive $BOOM] line 
     357        regsub -all "\\\\" $line "" line 
     358} 
     359 
     360set loops 0 
     361while {[regexp -nocase "%VERB\{(.*?)\}" $line matches BOOM]} { 
     362        incr loops 
     363        if {$loops > 10} { 
     364                putlog "bMotion: ALERT! looping too much in %VERB code with $line" 
     365                set line "/has a tremendous error while trying to sort something out :(" 
     366        } 
     367        # set line [bMotionInsertString $line "%VERB\{$BOOM\}" [bMotionMakeVerb $BOOM]] 
     368        regsub -nocase "%VERB\{$BOOM\}" $line [bMotionMakeVerb $BOOM] line 
     369} 
     370 
     371set loops 0 
     372while {[regexp -nocase "%PLURAL\{(.*?)\}" $line matches BOOM]} { 
     373        incr loops 
     374        if {$loops > 10} { 
     375                putlog "bMotion: ALERT! looping too much in %PLURAL code with $line" 
     376                set line "/has a tremendous error while trying to sort something out :(" 
     377        } 
     378        # set line [bMotionInsertString $line "%PLURAL\{$BOOM\}" [bMotionMakePlural $BOOM]] 
     379        regsub -nocase "%PLURAL\{$BOOM\}" $line [bMotionMakePlural $BOOM] line 
     380} 
     381 
     382set loops 0 
     383while {[regexp -nocase "%REPEAT\{(.+?)\}" $line matches BOOM]} { 
     384        incr loops 
     385        if {$loops > 10} { 
     386                putlog "bMotion: ALERT! looping too much in %REPEAT code with $line" 
     387                set line "/has a tremendous error while trying to sort something out :(" 
     388        } 
     389        set replacement [bMotionMakeRepeat $BOOM] 
     390        regsub -nocase "%REPEAT\\{$BOOM\\}" $line $replacement line 
     391} 
     392 
     393return $line 
    394394} 
    395395 
     
    397397        bMotion_putloglev 5 * "bMotionSayLine: channel = $channel, nick = $nick, line = $line, moreText = $moreText, noTypo = $noTypo" 
    398398        global mood botnick bMotionInfo bMotionCache bMotionOriginalInput 
    399                 global bMotion_output_delay 
     399        global bMotion_output_delay 
    400400 
    401401        set line [bMotionInterpolation2 $line] 
     
    408408                set dobreak 0 
    409409                if {$botcmd == "bot"} { 
    410                         #random 
     410                #random 
    411411                        bMotion_putloglev 1 * "bMotion: %bot detected" 
    412412                        regexp {%bot\[([[:digit:]]+),(@[^,]+,)?(.+)\]} $line matches chance condition cmd 
     
    420420                        } 
    421421                } else { 
    422                         #non-random 
    423                         regexp {%BOT\[(@[^,]+,)?(.+)\]} $line matches condition cmd 
     422                #non-random 
     423                regexp {%BOT\[(@[^,]+,)?(.+)\]} $line matches condition cmd 
    424424                } 
    425425 
     
    452452 
    453453        if [regexp {%DELAY\{([0-9]+)\}} $line matches delay] { 
    454                         set bMotion_output_delay $delay 
    455                         bMotion_putloglev d * "Changing output delay to $delay" 
    456                         set line "" 
     454                set bMotion_output_delay $delay 
     455                bMotion_putloglev d * "Changing output delay to $delay" 
     456                set line "" 
    457457        } 
    458458 
     
    482482                                } 
    483483                                if {$result == ""} { 
    484                                                 return 0 
     484                                        return 0 
    485485                                } 
    486486                                set line $result 
     
    494494        } 
    495495 
    496                 if {[string index $line end] == " "} { 
    497                                 set line [string range $line 0 end-1] 
    498                 } 
     496        if {[string index $line end] == " "} { 
     497                set line [string range $line 0 end-1] 
     498        } 
    499499 
    500500        #check if this line matches the last line said on IRC 
     
    504504                return 0 
    505505        } 
    506                  
    507                 #protect this block - it'll generate an error if noone's talked yet, and then 
    508                 #we try an admin plugin 
    509                 if [info exists bMotionOriginalInput] { 
    510                                 if [string match -nocase $bMotionOriginalInput $line] { 
    511                                                 bMotion_putloglev 1 * "my output matches the trigger, dropping" 
    512                                                 return 0 
    513                                 } 
    514                 } 
    515  
    516         set line [bMotionInsertString $line "%slash" "/"] 
    517  
    518                 global bMotion_output_delay 
    519  
    520         if [regexp "^/" $line] { 
    521                 #it's an action 
    522                 mee $channel [string range $line 1 end] $urgent 
     506 
     507        #protect this block - it'll generate an error if noone's talked yet, and then 
     508        #we try an admin plugin 
     509        if [info exists bMotionOriginalInput] { 
     510        if [string match -nocase $bMotionOriginalInput $line] { 
     511        bMotion_putloglev 1 * "my output matches the trigger, dropping" 
     512        return 0 
     513        } 
     514        } 
     515 
     516set line [bMotionInsertString $line "%slash" "/"] 
     517 
     518global bMotion_output_delay 
     519 
     520if [regexp "^/" $line] { 
     521#it's an action 
     522        mee $channel [string range $line 1 end] $urgent 
     523} else { 
     524        if {$urgent} { 
     525                bMotion_queue_add_now [chandname2name $channel] $line 
    523526        } else { 
    524                 if {$urgent} { 
    525                         bMotion_queue_add_now [chandname2name $channel] $line 
    526                 } else { 
    527                         bMotion_queue_add [chandname2name $channel] $line $bMotion_output_delay 
    528                 } 
    529         } 
    530         return 0 
     527                bMotion_queue_add [chandname2name $channel] $line $bMotion_output_delay 
     528        } 
     529} 
     530return 0 
    531531} 
    532532 
    533533proc bMotionInsertString {line swapout toInsert} { 
    534                 bMotion_putloglev 5 * "bMotionInsertString ($line, $swapout, $toInsert)" 
     534        bMotion_putloglev 5 * "bMotionInsertString ($line, $swapout, $toInsert)" 
    535535        set loops 0 
    536536        set inputLine $line 
     
    548548 
    549549proc bMotionGetColenChars {} { 
    550                 bMotion_putloglev 5 * "bMotionGetColenChars" 
     550        bMotion_putloglev 5 * "bMotionGetColenChars" 
    551551        set randomChar "!£$%^*@#~" 
    552552 
     
    569569 
    570570proc makeSmiley { mood } { 
    571                 bMotion_putloglev 5 * "makeSmiley" 
     571        bMotion_putloglev 5 * "makeSmiley" 
    572572        if {$mood > 30} { 
    573573                return ":D" 
     
    592592# 
    593593proc bMotionWashNick { nick } { 
    594                 bMotion_putloglev 5 * "bMotionWashNick ($nick)" 
     594        bMotion_putloglev 5 * "bMotionWashNick ($nick)" 
    595595        #remove leading 
    596596        regsub {^[|`_\[]+} $nick "" nick 
     
    620620                set handle [finduser $host] 
    621621                if {$handle == "*"} { 
    622                         #not in bot 
     622                #not in bot 
    623623                        bMotion_putloglev 2 * "bMotion: no match, washing nick" 
    624624                        return [bMotionWashNick $nick] 
     
    633633        set realname [getuser $handle XTRA irl] 
    634634        if {$realname == ""} { 
    635                 #not set 
     635        #not set 
    636636                return [bMotionWashNick $nick] 
    637637        } 
     
    653653 
    654654        if [validuser $nick] { 
    655                 #it's a handle already 
     655        #it's a handle already 
    656656                set handle $nick 
    657657        } else { 
    658                 #try to figure it out 
     658        #try to figure it out 
    659659                set handle [nick2hand $nick] 
    660660                if {($handle == "") ||($handle == "*")} { 
    661                         #not in bot 
     661                #not in bot 
    662662                        bMotion_putloglev 2 * "bMotion: no match, using nick" 
    663663                        return $nick 
     
    670670        set realname [getuser $handle XTRA irl] 
    671671        if {$realname == ""} { 
    672                 #not set 
     672        #not set 
    673673                bMotion_putloglev 2 * "no IRL set, using nick" 
    674674                return $nick 
     
    679679 
    680680proc bMotionTransformNick { target nick {host ""} } { 
    681                 bMotion_putloglev 5 * "bMotionTransformNick($target, $nick, $host)" 
     681        bMotion_putloglev 5 * "bMotionTransformNick($target, $nick, $host)" 
    682682        set newTarget [bMotionTransformTarget $target $host] 
    683683        if {$newTarget == "me"} { 
     
    688688 
    689689proc bMotionTransformTarget { target {host ""} } { 
    690                 bMotion_putloglev 5 * "bMotionTransformTarget($target, $host)" 
     690        bMotion_putloglev 5 * "bMotionTransformTarget($target, $host)" 
    691691        global botnicks 
    692692        if {$target != "me"} { 
     
    718718#               * prev - return previously chosen user/bot 
    719719proc bMotion_choose_random_user { channel bot condition } { 
    720         bMotion_putloglev 5 * "bMotion_choose_random_user ($channel, $bot, $condition)" 
     720        bMotion_putloglev 5 * "ruser: bMotion_choose_random_user ($channel, $bot, $condition)" 
    721721        global bMotionCache 
    722722        set users [chanlist $channel] 
     
    729729                        set what [array get bMotionCache "lastruser$bot"] 
    730730                } 
    731                 bMotion_putloglev 4 * "accept: prev ($what)" 
     731                bMotion_putloglev 4 * "ruser: accept: prev ($what)" 
    732732                return [lindex $what 1] 
    733733        } 
    734734 
    735735        foreach user $users { 
    736                 bMotion_putloglev 4 * "eval user $user" 
     736                bMotion_putloglev 4 * "ruser: eval user $user" 
    737737                #is it me? 
    738                 if [isbotnick $user] { continue } 
     738                if [isbotnick $user] {  
     739                        bMotion_putloglev 4 * "ruser:  that's me" 
     740                        continue  
     741                } 
    739742 
    740743                if {[bMotion_setting_get "bitlbee"] && ($user == "root")} { 
    741                         bMotion_putloglev 4 * "  --reject: bitlbee root user" 
     744                        bMotion_putloglev 4 * "ruser:  reject: bitlbee root user" 
    742745                        continue 
    743746                } 
     
    746749                #get their handle 
    747750                set handle [nick2hand $user $channel] 
    748                 bMotion_putloglev 4 * "  handle: $handle" 
     751                bMotion_putloglev 4 * "ruser:  handle: $handle" 
    749752 
    750753                # some people don't like interacting with the bot 
    751754                if [matchattr $handle J] { 
    752                         bMotion_putloglev 4 * "  --reject: user is +J" 
     755                        bMotion_putloglev 4 * "ruser:  reject: user is +J" 
    753756                        continue 
    754757                } 
     
    756759                #unless we're looking for any old user, we'll need handle 
    757760                if {(($handle == "") || ($handle == "*")) && ($condition != "")} { 
    758                         bMotion_putloglev 4 * "  --reject: no handle" 
     761                        bMotion_putloglev 4 * "ruser:  reject: no handle" 
    759762                        continue 
    760763                } 
     
    763766                #we don't want a bot, then use nick 
    764767                if {(($handle == "") || ($handle == "*")) && ($condition == "") && ($bot == 0)} { 
    765                         bMotion_putloglev 4 * "  ++accept: $user (no handle)" 
     768                        bMotion_putloglev 4 * "ruser:  accept: $user (no handle)" 
    766769                        lappend acceptable $user 
    767770                        continue 
     
    771774                if {$bot == 1} { 
    772775                        if {![matchattr $handle b]} { 
    773                                 bMotion_putloglev 4 * "  --reject: not a bot" 
     776                                bMotion_putloglev 4 * "ruser:  reject: not a bot" 
    774777                                continue 
    775778                        } 
     
    777780                        global bMotion_interbot_otherbots 
    778781                        if {[lsearch [array names bMotion_interbot_otherbots] $handle] == -1} { 
    779                                 bMotion_putloglev 4 * "  --reject: not a bmotion bot" 
     782                                bMotion_putloglev 4 * "ruser:  reject: not a bmotion bot" 
    780783                                continue 
    781784                        } 
    782785                        #else add them 
    783786                        lappend acceptable $user 
    784