| 1 | #bMotion core |
|---|
| 2 | # |
|---|
| 3 | # $Id$ |
|---|
| 4 | # |
|---|
| 5 | |
|---|
| 6 | # |
|---|
| 7 | # #5270 +(28)- [X] |
|---|
| 8 | # |
|---|
| 9 | # <Procyan> is there like 1 person on earth that knows tcl/tk and is writing all of the apps? |
|---|
| 10 | # <unSlider> procyan: no, there are a bunch of people who dont know tcl/tk but are writing apps for it anyway |
|---|
| 11 | # (www.bash.org) |
|---|
| 12 | |
|---|
| 13 | set bMotionRoot "scripts/bmotion" |
|---|
| 14 | set bMotionModules "$bMotionRoot/modules" |
|---|
| 15 | set bMotionPlugins "$bMotionRoot/plugins" |
|---|
| 16 | |
|---|
| 17 | if {![info exists bMotion_testing]} { |
|---|
| 18 | putloglev d * "bMotion: bMotion_testing is not defined, setting to 0." |
|---|
| 19 | set bMotion_testing 0 |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | source "$bMotionRoot/VERSION" |
|---|
| 23 | if {$bMotion_testing == 0} { |
|---|
| 24 | putlog "bMotion $bMotionVersion starting up..." |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | if {$bMotion_testing == 1} { |
|---|
| 28 | putlog "bMotion: INFO: Code loading in testing mode" |
|---|
| 29 | } else { |
|---|
| 30 | putloglev 1 * "bMotion: INFO: Code loading in running mode" |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | foreach letter [split "d12345678" {}] { |
|---|
| 34 | set bMotionCache($letter,lastlog) "" |
|---|
| 35 | set bMotionCache($letter,lastcount) 0 |
|---|
| 36 | } |
|---|
| 37 | |
|---|
| 38 | proc bMotion_putloglev { level star text } { |
|---|
| 39 | global bMotion_testing bMotionCache |
|---|
| 40 | regsub "bMotion:" $text "" text |
|---|
| 41 | set text2 "" |
|---|
| 42 | if {$level != "d"} { |
|---|
| 43 | set text2 [string repeat " " $level] |
|---|
| 44 | } |
|---|
| 45 | set text "bMotion:$text2 $text" |
|---|
| 46 | |
|---|
| 47 | if {$bMotion_testing == 0} { |
|---|
| 48 | if {$bMotionCache($level,lastlog) == $text} { |
|---|
| 49 | incr bMotionCache($level,lastcount) |
|---|
| 50 | return |
|---|
| 51 | } |
|---|
| 52 | if {$bMotionCache($level,lastcount) > 0} { |
|---|
| 53 | putloglev $level $star "($level)Previous message repeated $bMotionCache($level,lastcount) time(s)" |
|---|
| 54 | } |
|---|
| 55 | putloglev $level $star "($level)$text" |
|---|
| 56 | set bMotionCache($level,lastlog) $text |
|---|
| 57 | set bMotionCache($level,lastcount) 0 |
|---|
| 58 | } |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | # init default variables |
|---|
| 62 | if {$bMotion_testing == 1} { |
|---|
| 63 | putlog "... loading variables" |
|---|
| 64 | } |
|---|
| 65 | source "$bMotionModules/variables.tcl" |
|---|
| 66 | |
|---|
| 67 | #load new abstract system |
|---|
| 68 | if {$bMotion_testing == 1} { |
|---|
| 69 | putlog "... loading abstract system" |
|---|
| 70 | } |
|---|
| 71 | source "$bMotionModules/abstract.tcl" |
|---|
| 72 | |
|---|
| 73 | # load abstracts file (formerly randoms) |
|---|
| 74 | if {$bMotion_testing == 1} { |
|---|
| 75 | putlog "... loading abstracts" |
|---|
| 76 | } |
|---|
| 77 | source "$bMotionModules/abstracts.tcl" |
|---|
| 78 | |
|---|
| 79 | # load settings |
|---|
| 80 | if {$bMotion_testing == 1} { |
|---|
| 81 | putlog "... loading settings" |
|---|
| 82 | } |
|---|
| 83 | source "$bMotionModules/settings.tcl" |
|---|
| 84 | #try to load a file for this bot |
|---|
| 85 | catch { |
|---|
| 86 | if {${botnet-nick} != ""} { |
|---|
| 87 | source "$bMotionModules/settings_${botnet-nick}.tcl" |
|---|
| 88 | bMotion_putloglev d * "loaded settings for this bot from settings_${botnet-nick}.tcl" |
|---|
| 89 | } |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | #load system functions |
|---|
| 93 | if {$bMotion_testing == 1} { |
|---|
| 94 | putlog "... loading system" |
|---|
| 95 | } |
|---|
| 96 | source "$bMotionModules/system.tcl" |
|---|
| 97 | |
|---|
| 98 | # load output functions |
|---|
| 99 | if {$bMotion_testing == 1} { |
|---|
| 100 | putlog "... loading output" |
|---|
| 101 | } |
|---|
| 102 | source "$bMotionModules/output.tcl" |
|---|
| 103 | |
|---|
| 104 | # load mood functions |
|---|
| 105 | if {$bMotion_testing == 1} { |
|---|
| 106 | putlog "... loading mood" |
|---|
| 107 | } |
|---|
| 108 | source "$bMotionModules/mood.tcl" |
|---|
| 109 | |
|---|
| 110 | # load event functions |
|---|
| 111 | if {$bMotion_testing == 1} { |
|---|
| 112 | putlog "... loading events" |
|---|
| 113 | } |
|---|
| 114 | source "$bMotionModules/events.tcl" |
|---|
| 115 | |
|---|
| 116 | if {$bMotion_testing == 1} { |
|---|
| 117 | putlog "... loading events support" |
|---|
| 118 | } |
|---|
| 119 | source "$bMotionModules/events_support.tcl" |
|---|
| 120 | |
|---|
| 121 | # load interbot bits |
|---|
| 122 | if {$bMotion_testing == 1} { |
|---|
| 123 | putlog "... loading interbot" |
|---|
| 124 | } |
|---|
| 125 | source "$bMotionModules/interbot.tcl" |
|---|
| 126 | |
|---|
| 127 | # load friendship code |
|---|
| 128 | if {$bMotion_testing == 1} { |
|---|
| 129 | putlog "... loading friendship" |
|---|
| 130 | } |
|---|
| 131 | source "$bMotionModules/friendship.tcl" |
|---|
| 132 | |
|---|
| 133 | # load anti-flood code |
|---|
| 134 | if {$bMotion_testing == 1} { |
|---|
| 135 | putlog "... loading flood" |
|---|
| 136 | } |
|---|
| 137 | source "$bMotionModules/flood.tcl" |
|---|
| 138 | |
|---|
| 139 | ### That's everything but the plugins stuff loaded. Now load extra modules |
|---|
| 140 | |
|---|
| 141 | bMotion_putloglev d * "looking for 3rd party modules..." |
|---|
| 142 | set files [lsort [glob -nocomplain "$bMotionModules/extra/*.tcl"]] |
|---|
| 143 | foreach f $files { |
|---|
| 144 | bMotion_putloglev 1 * "loading module: $f" |
|---|
| 145 | catch { |
|---|
| 146 | source $f |
|---|
| 147 | } |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | ### Done, load the plugins: |
|---|
| 151 | |
|---|
| 152 | # load plugins |
|---|
| 153 | if {$bMotion_testing == 1} { |
|---|
| 154 | putlog "... loading plugins" |
|---|
| 155 | } |
|---|
| 156 | source "$bMotionModules/plugins.tcl" |
|---|
| 157 | |
|---|
| 158 | if {$bMotion_testing == 1} { |
|---|
| 159 | putlog "... loading plugin settings" |
|---|
| 160 | } |
|---|
| 161 | source "$bMotionModules/plugins_settings.tcl" |
|---|
| 162 | |
|---|
| 163 | #load local abstracts |
|---|
| 164 | catch { |
|---|
| 165 | if {${botnet-nick} != ""} { |
|---|
| 166 | source "$bMotionModules/abstracts_${botnet-nick}.tcl" |
|---|
| 167 | bMotion_putloglev d * "loaded abstracts for this bot from abstracts_${botnet-nick}.tcl" |
|---|
| 168 | } |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | # load other bits |
|---|
| 172 | if {$bMotion_testing == 1} { |
|---|
| 173 | putlog "... loading leet" |
|---|
| 174 | } |
|---|
| 175 | source "$bMotionModules/leet.tcl" |
|---|
| 176 | |
|---|
| 177 | # load diagnostics |
|---|
| 178 | catch { |
|---|
| 179 | if {$bMotion_testing == 1} { |
|---|
| 180 | putlog "... loading self-diagnostics" |
|---|
| 181 | } |
|---|
| 182 | source "$bMotionModules/diagnostics.tcl" |
|---|
| 183 | } |
|---|
| 184 | |
|---|
| 185 | # Ignition! |
|---|
| 186 | bMotion_startTimers |
|---|
| 187 | if {$bMotion_testing == 0} { |
|---|
| 188 | set bMotionCache(rehash) "" |
|---|
| 189 | putlog "\002bMotion $bMotionVersion AI online\002 :D" |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | # set this to 0 to stop showing the copyright |
|---|
| 193 | # DO NOT DISTRIBUTE THIS FILE IF THE VARIABLE IS SET TO 0 |
|---|
| 194 | set bMotion_show_copyright 1 |
|---|
| 195 | |
|---|
| 196 | if {$bMotion_show_copyright == 1} { |
|---|
| 197 | putlog "bMotion is Copyright (C) 2002 James Seward. bMotion comes with ABSOLUTELY NO WARRANTY;" |
|---|
| 198 | putlog "This is free software, and you are welcome to redistribute it under certain conditions." |
|---|
| 199 | putlog "See the COPYRIGHT file for details. You can edit bMotion.tcl to hide this message once you have read it." |
|---|
| 200 | } |
|---|