Show
Ignore:
Timestamp:
06/24/07 12:14:58 (19 months ago)
Author:
james
Message:

auto-learn people's genders based on actions

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/en/action_complex_failsafe.tcl

    r690 r806  
    1616 
    1717bMotion_plugin_add_action_complex "zzz-failsafe" {^(.+?)s?( at|with)? %botnicks} 100 bMotion_plugin_complex_action_failsafe "en" 
     18bMotion_plugin_add_action_complex "aaa-autogender" {[a-z]+s (his|her) } 100 bMotion_plugin_complex_action_autolearn_gender "en" 
    1819 
    1920proc bMotion_plugin_complex_action_failsafe { nick host handle channel text } { 
     
    5556} 
    5657 
     58proc bMotion_plugin_complex_action_autolearn_gender { nick host handle channel text } { 
     59        if {$handle == "*"} { 
     60                return 0 
     61        } 
     62 
     63        set gender [getuser $handle XTRA gender] 
     64        if [regexp -nocase {[a-z]+s (his|her) } $text matches pronoun] { 
     65                set pronoun [string tolower $pronoun] 
     66                if {$pronoun == "his"} { 
     67                        if {$gender != ""} { 
     68                                if {$gender == "male"} { 
     69                                        return 0 
     70                                } else { 
     71                                        bMotion_putloglev 3 * "would learn gender for $nick as male, but they're already female!" 
     72                                        return 0 
     73                                } 
     74                        } 
     75                        bMotion_putloglev d * "learning gender = male for $handle (via $nick)" 
     76                        setuser $handle XTRA gender male 
     77                        return 0 
     78                } else { 
     79                        if {$gender != ""} { 
     80                                if {$gender == "female"} { 
     81                                        return 0 
     82                                } else { 
     83                                        bMotion_putloglev 3 * "would learn gender for $nick as female, but they're already male!" 
     84                                        return 0 
     85                                } 
     86                        } 
     87                        bMotion_putloglev d * "learning gender = female for $handle (via $nick)" 
     88                        setuser $handle XTRA gender female 
     89                        return 0 
     90                } 
     91        } 
     92        return 0 
     93} 
     94 
    5795bMotion_abstract_register "failsafe_nice" 
    5896bMotion_abstract_batchadd "failsafe_nice" [list "mmm" "%VAR{smiles}" "%VAR{smiles}%|/gives %% %VAR{sillyThings}"]