| 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 | proc bMotion_putloglev { level star text } { |
|---|
| 34 | global bMotion_testing |
|---|
| 35 | if {![string match -nocase "bMotion: *" $text]} { |
|---|
| 36 | set text "bMotion: $text" |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | if {$bMotion_testing == 0} { |
|---|
| 40 | putloglev $level $star "($level)$text" |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | # init default variables |
|---|
| 45 | if {$bMotion_testing == 1} { |
|---|
| 46 | putlog "... loading variables" |
|---|
| 47 | } |
|---|
| 48 | source "$bMotionModules/variables.tcl" |
|---|
| 49 | |
|---|
| 50 | # load abstracts file (formerly randoms) |
|---|
| 51 | if {$bMotion_testing == 1} { |
|---|
| 52 | putlog "... loading abstracts" |
|---|
| 53 | } |
|---|
| 54 | source "$bMotionModules/abstracts.tcl" |
|---|
| 55 | |
|---|
| 56 | # load settings |
|---|
| 57 | if {$bMotion_testing == 1} { |
|---|
| 58 | putlog "... loading settings" |
|---|
| 59 | } |
|---|
| 60 | source "$bMotionModules/settings.tcl" |
|---|
| 61 | #try to load a file for this bot |
|---|
| 62 | catch { |
|---|
| 63 | if {${botnet-nick} != ""} { |
|---|
| 64 | source "$bMotionModules/settings_${botnet-nick}.tcl" |
|---|
| 65 | bMotion_putloglev d * "loaded settings for this bot from settings_${botnet-nick}.tcl" |
|---|
| 66 | } |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | #load system functions |
|---|
| 70 | if {$bMotion_testing == 1} { |
|---|
| 71 | putlog "... loading system" |
|---|
| 72 | } |
|---|
| 73 | source "$bMotionModules/system.tcl" |
|---|
| 74 | |
|---|
| 75 | # load output functions |
|---|
| 76 | if {$bMotion_testing == 1} { |
|---|
| 77 | putlog "... loading output" |
|---|
| 78 | } |
|---|
| 79 | source "$bMotionModules/output.tcl" |
|---|
| 80 | |
|---|
| 81 | # load mood functions |
|---|
| 82 | if {$bMotion_testing == 1} { |
|---|
| 83 | putlog "... loading mood" |
|---|
| 84 | } |
|---|
| 85 | source "$bMotionModules/mood.tcl" |
|---|
| 86 | |
|---|
| 87 | # load event functions |
|---|
| 88 | if {$bMotion_testing == 1} { |
|---|
| 89 | putlog "... loading events" |
|---|
| 90 | } |
|---|
| 91 | source "$bMotionModules/events.tcl" |
|---|
| 92 | |
|---|
| 93 | if {$bMotion_testing == 1} { |
|---|
| 94 | putlog "... loading events support" |
|---|
| 95 | } |
|---|
| 96 | source "$bMotionModules/events_support.tcl" |
|---|
| 97 | |
|---|
| 98 | # load interbot bits |
|---|
| 99 | if {$bMotion_testing == 1} { |
|---|
| 100 | putlog "... loading interbot" |
|---|
| 101 | } |
|---|
| 102 | source "$bMotionModules/interbot.tcl" |
|---|
| 103 | |
|---|
| 104 | # load friendship code |
|---|
| 105 | if {$bMotion_testing == 1} { |
|---|
| 106 | putlog "... loading friendship" |
|---|
| 107 | } |
|---|
| 108 | source "$bMotionModules/friendship.tcl" |
|---|
| 109 | |
|---|
| 110 | # load anti-flood code |
|---|
| 111 | if {$bMotion_testing == 1} { |
|---|
| 112 | putlog "... loading flood" |
|---|
| 113 | } |
|---|
| 114 | source "$bMotionModules/flood.tcl" |
|---|
| 115 | |
|---|
| 116 | ### That's everything but the plugins stuff loaded. Now load extra modules |
|---|
| 117 | |
|---|
| 118 | bMotion_putloglev d * "looking for 3rd party modules..." |
|---|
| 119 | set files [lsort [glob -nocomplain "$bMotionModules/extra/*.tcl"]] |
|---|
| 120 | foreach f $files { |
|---|
| 121 | bMotion_putloglev 1 * "loading module: $f" |
|---|
| 122 | catch { |
|---|
| 123 | source $f |
|---|
| 124 | } |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | ### Done, load the plugins: |
|---|
| 128 | |
|---|
| 129 | # load plugins |
|---|
| 130 | if {$bMotion_testing == 1} { |
|---|
| 131 | putlog "... loading plugins" |
|---|
| 132 | } |
|---|
| 133 | source "$bMotionModules/plugins.tcl" |
|---|
| 134 | |
|---|
| 135 | if {$bMotion_testing == 1} { |
|---|
| 136 | putlog "... loading plugin settings" |
|---|
| 137 | } |
|---|
| 138 | source "$bMotionModules/plugins_settings.tcl" |
|---|
| 139 | |
|---|
| 140 | #load local abstracts |
|---|
| 141 | catch { |
|---|
| 142 | if {${botnet-nick} != ""} { |
|---|
| 143 | source "$bMotionModules/abstracts_${botnet-nick}.tcl" |
|---|
| 144 | bMotion_putloglev d * "loaded abstracts for this bot from abstracts_${botnet-nick}.tcl" |
|---|
| 145 | } |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | # load other bits |
|---|
| 149 | if {$bMotion_testing == 1} { |
|---|
| 150 | putlog "... loading leet" |
|---|
| 151 | } |
|---|
| 152 | source "$bMotionModules/leet.tcl" |
|---|
| 153 | |
|---|
| 154 | # load diagnostics |
|---|
| 155 | catch { |
|---|
| 156 | if {$bMotion_testing == 1} { |
|---|
| 157 | putlog "... loading self-diagnostics" |
|---|
| 158 | } |
|---|
| 159 | source "$bMotionModules/diagnostics.tcl" |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | # Ignition! |
|---|
| 163 | bMotion_startTimers |
|---|
| 164 | if {$bMotion_testing == 0} { |
|---|
| 165 | set bMotionCache(rehash) "" |
|---|
| 166 | putlog "\002bMotion $bMotionVersion AI online\002 :D" |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | # set this to 0 to stop showing the copyright |
|---|
| 170 | # DO NOT DISTRIBUTE THIS FILE IF THE VARIABLE IS SET TO 0 |
|---|
| 171 | set bMotion_show_copyright 1 |
|---|
| 172 | |
|---|
| 173 | if {$bMotion_show_copyright == 1} { |
|---|
| 174 | putlog "bMotion is Copyright (C) 2002 James Seward. bMotion comes with ABSOLUTELY NO WARRANTY;" |
|---|
| 175 | putlog "This is free software, and you are welcome to redistribute it under certain conditions." |
|---|
| 176 | putlog "See the COPYRIGHT file for details. You can edit bMotion.tcl to hide this message once you have read it." |
|---|
| 177 | } |
|---|