source: branches/sqlite/bMotion.tcl @ 1143

Revision 713, 5.4 KB checked in by james, 6 years ago (diff)

use +bmotion chanmode instead of randomChannels setting
some small code cleanups

  • 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        set bMotion_loaded_settings 1
89}
90
91#try to load a file for this bot
92catch {
93  if {${botnet-nick} != ""} {
94    source "$bMotionModules/settings_${botnet-nick}.tcl"
95    bMotion_putloglev d * "loaded settings for this bot from settings_${botnet-nick}.tcl"
96                set bMotion_loaded_settings 1
97  }
98}
99
100#try to load from the local dir
101if [file exists "$bMotionLocal/settings.tcl"] {
102        source "$bMotionLocal/settings.tcl"
103        bMotion_putloglev d * "loaded local settings from $bMotionLocal/settings.tcl"
104        set bMotion_loaded_settings 1
105}
106
107if {$bMotion_loaded_settings == 0} {
108        putlog "bMotion: FATAL! Could not load from any settings file! bMotion is not going to work! :("
109}
110
111#load system functions
112if {$bMotion_testing == 1} {
113  putlog "... loading system"
114}
115source "$bMotionModules/system.tcl"
116
117#load new abstract system
118if {$bMotion_testing == 1} {
119  putlog "... loading abstract system"
120}
121source "$bMotionModules/abstract.tcl"
122
123# load output functions
124if {$bMotion_testing == 1} {
125  putlog "... loading output"
126}
127source "$bMotionModules/output.tcl"
128
129# load event functions
130if {$bMotion_testing == 1} {
131  putlog "... loading events"
132}
133source "$bMotionModules/events.tcl"
134
135if {$bMotion_testing == 1} {
136  putlog "... loading events support"
137}
138source "$bMotionModules/events_support.tcl"
139
140# load interbot bits
141if {$bMotion_testing == 1} {
142  putlog "... loading interbot"
143}
144source "$bMotionModules/interbot.tcl"
145
146# load friendship code
147if {$bMotion_testing == 1} {
148  putlog "... loading friendship"
149}
150source "$bMotionModules/friendship.tcl"
151
152# load anti-flood code
153if {$bMotion_testing == 1} {
154  putlog "... loading flood"
155}
156source "$bMotionModules/flood.tcl"
157
158# load queue code
159if {$bMotion_testing == 1} {
160  putlog "... loading queue"
161}
162source "$bMotionModules/queue.tcl"
163
164# load plugins
165if {$bMotion_testing == 1} {
166  putlog "... loading plugins"
167}
168source "$bMotionModules/plugins.tcl"
169
170# load mood functions
171if {$bMotion_testing == 1} {
172  putlog "... loading mood"
173}
174source "$bMotionModules/mood.tcl"
175
176if {$bMotion_testing == 1} {
177  putlog "... loading plugin settings"
178}
179source "$bMotionModules/plugins_settings.tcl"
180
181### That's everything but the plugins stuff loaded. Now load extra modules
182bMotion_putloglev d * "looking for 3rd party modules..."
183set files [lsort [glob -nocomplain "$bMotionModules/extra/*.tcl"]]
184foreach f $files {
185  bMotion_putloglev 1 * "... loading extra module: $f"
186  catch {
187    source $f
188  }
189}
190
191### Done, load the plugins:
192
193
194
195#load local abstracts
196catch {
197        source "$bMotionLocal/abstracts.tcl"
198        bMotion_putloglev d * "loaded abstracts for this bot from local abstracts.tcl"
199}
200
201# load other bits
202if {$bMotion_testing == 1} {
203  putlog "... loading leet"
204}
205source "$bMotionModules/leet.tcl"
206
207# load diagnostics
208catch {
209  if {$bMotion_testing == 1} {
210    putlog "... loading self-diagnostics"
211  }
212  source "$bMotionModules/diagnostics.tcl"
213}
214
215# Ignition!
216
217bMotion_startTimers
218if {$bMotion_testing == 0} {
219  putlog "\002bMotion $bMotionVersion AI online\002 :D"
220
221        bMotion_diagnostic_utimers
222        bMotion_diagnostic_timers
223}
224
225set bMotion_loading 0
226set bMotion_testing 0
227
228
229# set this to 0 to stop showing the copyright
230# DO NOT DISTRIBUTE THIS FILE IF THE VARIABLE IS SET TO 0
231set bMotion_show_copyright 1
232
233if {$bMotion_show_copyright == 1} {
234  putlog "bMotion is Copyright (C) 2002 James Seward. bMotion comes with ABSOLUTELY NO WARRANTY;"
235  putlog "This is free software, and you are welcome to redistribute it under certain conditions."
236  putlog "See the COPYRIGHT file for details. You can edit bMotion.tcl to hide this message once you have read it."
237}
Note: See TracBrowser for help on using the repository browser.