Changeset 1109 for trunk


Ignore:
Timestamp:
01/17/11 15:52:28 (16 months ago)
Author:
james
Message:

add initial oversleep code
tidy up a couple of things in events.tcl

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/abstracts/en/abstracts.tcl

    r1108 r1109  
    58675867} 
    58685868 
     5869bMotion_abstract_register "overslept" { 
     5870        "%VAR{swear}!%|/overslept %VAR{unsmiles}" 
     5871        "%VAR{swear}!%|slept through my alarm %VAR{unsmiles}" 
     5872        "oh %VAR{swear}, overslept%|all because i was %VAR{sillyVerbs:presentpart} too late last night" 
     5873        "%VAR{swear}, slept though my alarm" 
     5874} 
     5875 
     5876bMotion_abstract_register "oversleep_rush" { 
     5877        "/gets dressed so quickly he forgets to put on %VAR{clothes}" 
     5878        "now i don't have time for a delicious breakfast of %VAR{foods}" 
     5879        "/absent-mindedly puts on %VAR{foods} and eats $VAR{clothes} for breakfast" 
     5880} 
     5881 
     5882bMotion_abstract_register "swear" { 
     5883        "fuck" 
     5884        "shit" 
     5885        "bollocks" 
     5886        "cunt" 
     5887        "arse" 
     5888        "damn" 
     5889        "drat" 
     5890        "bugger" 
     5891        "rats" 
     5892} 
     5893 
    58695894bMotion_abstract_add_filter "_all" "\{strip\}\}" 
    58705895bMotion_abstract_add_filter "_all" "\}\{strip\}" 
  • trunk/modules/events.tcl

    r1099 r1109  
    297297                        set result 0 
    298298                        set result [$callback $nick $host $handle $channel $text] 
    299                         bMotion_putloglev d * "returned from $callback" 
     299                        bMotion_putloglev 2 * "returned from $callback" 
    300300                        set bMotionCache(lastPlugin) $callback 
    301301                        bMotion_plugin_history_add $channel "complex" $callback 
     
    366366        #tell the names we have  
    367367        #TODO: move this into a plugin? 
    368         if [regexp -nocase "${botnicks}:?,? say my names?(,? bitch)?" $text] { 
     368        if [regexp -nocase "${botnicks}:?,? (say my names?|what'?s my name)" $text] { 
    369369                if {($handle == "*") || ($handle == "")}        { 
    370370                #no handle = no saving IRL 
     
    381381                set realnames [getuser $handle XTRA irl] 
    382382                if {$realnames == ""} { 
    383                         bMotionDoAction $channel $nick "Ah you must be %%. (You have not set any IRL names.)" "" 1 
     383                        bMotionDoAction $channel $nick "Ah, you must be %%. (You have not set any IRL names.)" "" 1 
    384384                } else { 
    385385                        bMotionDoAction $channel $nick "Your IRL name(s) are:\002 %2 \002" $realnames 1 
  • trunk/modules/system.tcl

    r1108 r1109  
    10821082} 
    10831083 
     1084 
     1085# realise we overslept 
     1086proc bMotion_overslept { { onlychan "" } } { 
     1087        global bMotionSettings BMOTION_SLEEP 
     1088        if {[bMotion_setting_get "asleep"] != $BMOTION_SLEEP(OVERSLEEPING)} { 
     1089                bMotion_putloglev d * "overslept timer fired but I wasn't oversleeping" 
     1090                return 
     1091        } 
     1092 
     1093        set bMotionSettings(asleep) $BMOTION_SLEEP(AWAKE) 
     1094 
     1095        if {$onlychan == ""} { 
     1096                set chanlist $bMotionChannels 
     1097        } else { 
     1098                set chanlist [list $onlychan] 
     1099        } 
     1100 
     1101        foreach chan $chanlist { 
     1102                if {[bMotion_is_active_enough $chan]} { 
     1103                        bMotionDoAction $chan "" "%VAR{overslept}" 
     1104                } 
     1105        } 
     1106} 
     1107 
    10841108proc bMotion_wake_up { } { 
    10851109        global bMotionSettings BMOTION_SLEEP bMotionChannels 
     
    10881112        if {$bMotionSettings(asleep) == $BMOTION_SLEEP(ASLEEP)} { 
    10891113                bMotion_putloglev 3 * "considering asleep -> awake" 
     1114                if {[rand 100] > 95} { 
     1115                        putlog "bMotion: really quite tired today... think I'll stay in bed a bit longer" 
     1116                        set snooze [expr [rand 120] + 30] 
     1117                        timer $snooze bMotion_overslept 
     1118                        putlog "bMotion: going to oversleep by $snooze minutes" 
     1119                        set bMotionSettings(asleep) $BMOTION_SLEEP(OVERSLEEPING) 
     1120 
     1121                        set hour [bMotion_setting_get "bedtime_hour"] 
     1122                        set minute [bMotion_setting_get "bedtime_minute"] 
     1123                        set bMotionSettings(sleepy_nextchange) [bMotion_sleep_next_event "$hour:$minute"] 
     1124 
     1125                        return 
     1126                } 
     1127 
    10901128                if {[rand 10] > 7} { 
    10911129                        putlog "bMotion: woke up!" 
  • trunk/modules/variables.tcl

    r1008 r1109  
    9292set BMOTION_SLEEP(BEDTIME) 1 
    9393set BMOTION_SLEEP(ASLEEP) 2 
     94set BMOTION_SLEEP(OVERSLEEPING) 3 
    9495 
    9596# start off awake 
  • trunk/plugins/en/complex_hello.tcl

    r1067 r1109  
    2222 
    2323        set lastGreeted [bMotion_plugins_settings_get "complex:hello" "lastGreeted" $channel ""] 
     24 
     25        global BMOTION_SLEEP 
     26        if {[bMotion_setting_get "asleep"] == $BMOTION_SLEEP(OVERSLEEPING)} { 
     27                bMotion_overslept $channel 
     28                set bMotionInfo(away) 0 
     29                set bMotionInfo(silence) 0 
     30                return 
     31        } 
    2432 
    2533        if {$bMotionInfo(away) == 1} { 
Note: See TracChangeset for help on using the changeset viewer.