root/trunk/bMotion.tcl

Revision 939, 5.4 KB (checked in by james, 6 months ago)

remove counters stuff, never really used it

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
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
14### Set some important variables
15set bMotionRoot "scripts/bmotion"
16set bMotionModules "$bMotionRoot/modules"
17set bMotionPlugins "$bMotionRoot/plugins"
18set bMotionLocal "$bMotionRoot/local"
19
20### We need to do this early on in case something breaks
21setudef flag bmotion
22
23if {![info exists bMotion_log_regexp]} {
24        set bMotion_log_regexp ""
25}
26
27if {![info exists bMotion_testing]} {
28  putloglev d * "bMotion: bMotion_testing is not defined, setting to 0."
29  set bMotion_testing 0
30}
31
32
33source "$bMotionRoot/VERSION"
34if {$bMotion_testing == 0} {
35  putlog "bMotion $bMotionVersion starting up..."
36}
37
38
39if {$bMotion_testing == 1} {
40  putlog "bMotion: INFO: Code loading in testing mode"
41  set bMotion_loading 0
42} else {
43  putloglev 1 * "bMotion: INFO: Code loading in running mode"
44  set bMotion_loading 1
45}
46
47proc bMotion_putloglev { level star text } {
48  global bMotion_testing bMotion_log_regexp
49       
50        if {$bMotion_log_regexp != ""} {
51                if {![regexp -nocase $bMotion_log_regexp $text]} {
52                        return 0
53                }
54        }
55
56  regsub "bMotion:" $text "" text
57  set text2 ""
58  if {$level != "d"} {
59    set text2 [string repeat " " $level]
60  }
61  set text "bMotion:$text2 $text"
62
63  if {$bMotion_testing == 0} {
64    putloglev $level $star "($level)$text"
65  }
66}
67
68# needed for variables
69if {$bMotion_testing == 1} {
70  putlog "... loading plugin settings"
71}
72source "$bMotionModules/plugins_settings.tcl"
73
74# init default variables
75if {$bMotion_testing == 1} {
76  putlog "... loading variables"
77}
78source "$bMotionModules/variables.tcl"
79
80# load settings
81if {$bMotion_testing == 1} {
82  putlog "... loading settings"
83}
84# try the original location first
85set bMotion_loaded_settings 0
86if [file exists "$bMotionModules/settings.tcl"] {
87        source "$bMotionModules/settings.tcl"
88        bMotion_putloglev d * "loaded settings from modules directory"
89        set bMotion_loaded_settings 1
90}
91
92#try to load a file for this bot
93catch {
94  if {${botnet-nick} != ""} {
95    source "$bMotionModules/settings_${botnet-nick}.tcl"
96    bMotion_putloglev d * "loaded settings for this bot from settings_${botnet-nick}.tcl"
97                set bMotion_loaded_settings 1
98  }
99}
100
101#try to load from the local dir
102if [file exists "$bMotionLocal/settings.tcl"] {
103        source "$bMotionLocal/settings.tcl"
104        bMotion_putloglev d * "loaded local settings from $bMotionLocal/settings.tcl"
105        set bMotion_loaded_settings 1
106}
107
108if {$bMotion_loaded_settings == 0} {
109        putlog "bMotion: FATAL! Could not load from any settings file! bMotion is not going to work! :("
110}
111
112#load system functions
113if {$bMotion_testing == 1} {
114  putlog "... loading system"
115}
116source "$bMotionModules/system.tcl"
117
118#load new abstract system
119if {$bMotion_testing == 1} {
120  putlog "... loading abstract system"
121}
122source "$bMotionModules/abstract.tcl"
123
124# load output functions
125if {$bMotion_testing == 1} {
126  putlog "... loading output"
127}
128source "$bMotionModules/output.tcl"
129
130# load event functions
131if {$bMotion_testing == 1} {
132  putlog "... loading events"
133}
134source "$bMotionModules/events.tcl"
135
136if {$bMotion_testing == 1} {
137  putlog "... loading events support"
138}
139source "$bMotionModules/events_support.tcl"
140
141# load interbot bits
142if {$bMotion_testing == 1} {
143  putlog "... loading interbot"
144}
145source "$bMotionModules/interbot.tcl"
146
147# load friendship code
148if {$bMotion_testing == 1} {
149  putlog "... loading friendship"
150}
151source "$bMotionModules/friendship.tcl"
152
153# load anti-flood code
154if {$bMotion_testing == 1} {
155  putlog "... loading flood"
156}
157source "$bMotionModules/flood.tcl"
158
159# load queue code
160if {$bMotion_testing == 1} {
161  putlog "... loading queue"
162}
163source "$bMotionModules/queue.tcl"
164
165# load plugins
166if {$bMotion_testing == 1} {
167  putlog "... loading plugins"
168}
169source "$bMotionModules/plugins.tcl"
170
171# load mood functions
172if {$bMotion_testing == 1} {
173  putlog "... loading mood"
174}
175source "$bMotionModules/mood.tcl"
176
177
178### That's everything but the plugins stuff loaded. Now load extra modules
179bMotion_putloglev d * "looking for 3rd party modules..."
180set files [lsort [glob -nocomplain "$bMotionModules/extra/*.tcl"]]
181foreach f $files {
182  bMotion_putloglev 1 * "... loading extra module: $f"
183  catch {
184    source $f
185  }
186}
187
188### Done, load the plugins:
189
190
191
192#load local abstracts
193catch {
194        source "$bMotionLocal/abstracts.tcl"
195        bMotion_putloglev d * "loaded abstracts for this bot from local abstracts.tcl"
196}
197
198# load other bits
199if {$bMotion_testing == 1} {
200  putlog "... loading leet"
201}
202source "$bMotionModules/leet.tcl"
203
204# load diagnostics
205catch {
206  if {$bMotion_testing == 1} {
207    putlog "... loading self-diagnostics"
208  }
209  source "$bMotionModules/diagnostics.tcl"
210}
211
212# Ignition!
213
214bMotion_startTimers
215if {$bMotion_testing == 0} {
216        bMotion_diagnostic_utimers
217        bMotion_diagnostic_timers
218
219  putlog "\002bMotion $bMotionVersion AI online\002 :D"
220}
221
222set bMotion_loading 0
223set bMotion_testing 0
224
225# To hide this message from your bot's startup/rehash, edit your settings.tcl and change
226# the bMotion_show_copyright value to 0
227if {![info exists bMotion_show_copyright]} {
228        set bMotion_show_copyright 1
229}
230if {$bMotion_show_copyright == 1} {
231        putlog "bMotion is Copyright (C) 2007 James Seward. bMotion comes with ABSOLUTELY NO WARRANTY;"
232  putlog "This is free software, and you are welcome to redistribute it under certain conditions."
233  putlog "See the COPYRIGHT file for details. See bMotion.tcl to hide this message once you have read it."
234}
Note: See TracBrowser for help on using the browser.