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

Revision 546, 5.1 KB checked in by james, 8 years ago (diff)

fix path

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