root/tags/release-0-0-8/bMotion.tcl

Revision 267, 4.9 KB (checked in by jamesoff, 5 years ago)

better logging handling

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