source: tags/release-0-1-0/bMotion.tcl @ 1143

Revision 846, 5.5 KB checked in by james, 5 years ago (diff)

add some feedback for settings

  • 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# init default variables
69if {$bMotion_testing == 1} {
70  putlog "... loading variables"
71}
72source "$bMotionModules/variables.tcl"
73
74# load counters
75if {$bMotion_testing == 1} {
76  putlog "... loading counters"
77}
78source "$bMotionModules/counters.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
177if {$bMotion_testing == 1} {
178  putlog "... loading plugin settings"
179}
180source "$bMotionModules/plugins_settings.tcl"
181
182### That's everything but the plugins stuff loaded. Now load extra modules
183bMotion_putloglev d * "looking for 3rd party modules..."
184set files [lsort [glob -nocomplain "$bMotionModules/extra/*.tcl"]]
185foreach f $files {
186  bMotion_putloglev 1 * "... loading extra module: $f"
187  catch {
188    source $f
189  }
190}
191
192### Done, load the plugins:
193
194
195
196#load local abstracts
197catch {
198        source "$bMotionLocal/abstracts.tcl"
199        bMotion_putloglev d * "loaded abstracts for this bot from local abstracts.tcl"
200}
201
202# load other bits
203if {$bMotion_testing == 1} {
204  putlog "... loading leet"
205}
206source "$bMotionModules/leet.tcl"
207
208# load diagnostics
209catch {
210  if {$bMotion_testing == 1} {
211    putlog "... loading self-diagnostics"
212  }
213  source "$bMotionModules/diagnostics.tcl"
214}
215
216# Ignition!
217
218bMotion_startTimers
219if {$bMotion_testing == 0} {
220        bMotion_diagnostic_utimers
221        bMotion_diagnostic_timers
222
223  putlog "\002bMotion $bMotionVersion AI online\002 :D"
224}
225
226set bMotion_loading 0
227set bMotion_testing 0
228
229# To hide this message from your bot's startup/rehash, edit your settings.tcl and change
230# the bMotion_show_copyright value to 0
231if {![info exists bMotion_show_copyright]} {
232        set bMotion_show_copyright 1
233}
234if {$bMotion_show_copyright == 1} {
235        putlog "bMotion is Copyright (C) 2007 James Seward. bMotion comes with ABSOLUTELY NO WARRANTY;"
236  putlog "This is free software, and you are welcome to redistribute it under certain conditions."
237  putlog "See the COPYRIGHT file for details. See bMotion.tcl to hide this message once you have read it."
238}
Note: See TracBrowser for help on using the repository browser.