cims.tcl 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909
  1. # CIMS: Community IRC Messaging Service
  2. # CIMS formerly known as MNET (Message Network)
  3. # Copyright (C) 2004 Paul-Dieter Klumpp
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18. namespace eval ::cims {
  19. set configs_file "scripts/cims/cims_conf.tcl"
  20. #your notes:
  21. # - Requirements:
  22. # -> eggdrop bot version >= 1.6.17
  23. # -> using TCL version >= 8.3
  24. # -> TCLLib version >= 1.6
  25. # -> TCLXML version >= 2.6
  26. #my notes:
  27. # ?- aliasing of channels!
  28. # ?- alternative configs! backupconf..
  29. # ?- xml:dom!
  30. # ?- better http get implementation!
  31. # ?- korrekte Statistiken der User usw?
  32. # ?- wordbanning?
  33. # Now, hands away pls :) except you know what you are doing.
  34. ######
  35. #package prefer stable
  36. # we need a nice tcl version
  37. package require Tcl 8.3
  38. # it's an eggdrop script, right? :)
  39. package require eggdrop 1.6
  40. # we need the tclxml package.. at least 2.6 i think
  41. package require xml
  42. # tclxml needs uri of tcllib.. at least 1.1 i think
  43. package require uri
  44. # include my/our little eggdrop utilities and helper library. ;-) Putils!
  45. if {[file isfile "scripts/cims/putils.tcl"] == 1} {
  46. source "scripts/cims/putils.tcl"
  47. }
  48. ############ XML CONFIGURATION PARSING FOLLOWS!! WTF! :) #########
  49. variable layout
  50. variable mnet_networks
  51. variable mnet_bots
  52. variable mnet_channels
  53. variable mnet_freqs
  54. variable mnet_bans
  55. variable mnet_colors
  56. variable mnet_colors_optional
  57. variable mnet_reached_users
  58. variable mnet_reached_userlist
  59. variable mnet_reached_chans
  60. variable mnet_http_config
  61. variable mnet_local_config
  62. variable mnet_histories
  63. variable mnet_netconfig_timer
  64. variable currentNetworkDesc
  65. variable currentNetworkSig
  66. variable startNetworkInstance
  67. variable currentBot
  68. variable currentOwner
  69. variable startBotInstance
  70. variable currentFreqName
  71. variable currentFreqPrefix
  72. variable currentFreqHelpmsg
  73. variable currentFreqDesc
  74. variable startFrequencyInstance
  75. global botnet-nick
  76. set layout(local_reply) "::cims:: Message sent to @@chan_cnt@@ channels, reaching @@user_cnt@@ unique users."
  77. set layout(local_reply) "::cims:: Message sent to @@chan_cnt@@ channels, reaching @@user_cnt@@ unique users."
  78. set layout(local_reply) "::cims:: Sent to @@chan_cnt@@ channels, @@user_cnt@@ unique users."
  79. set layout(user_banned) "::cims:: You're not allowed to send messages. Reason: @@reason@@"
  80. # list
  81. set mnet_local_config ""
  82. unset mnet_local_config
  83. # list
  84. set mnet_http_config ""
  85. unset mnet_http_config
  86. set mnet_cfg_reload_interval 0
  87. # list
  88. #set mnet_freqs_onoff "lala lala"
  89. #unset mnet_freqs_onoff
  90. }
  91. proc ::cims::clean_netconfig {} {
  92. variable mnet_bots
  93. variable mnet_channels
  94. variable mnet_freqs
  95. variable mnet_bans
  96. variable mnet_colors
  97. variable mnet_networks
  98. # secure deletion of all config-arrays..
  99. if {[array exists mnet_bots]} {
  100. array unset mnet_bots
  101. }
  102. if {[array exists mnet_channels]} {
  103. array unset mnet_channels
  104. }
  105. if {[array exists mnet_freqs]} {
  106. array unset mnet_freqs
  107. }
  108. if {[array exists mnet_bans]} {
  109. array unset mnet_bans
  110. }
  111. #if {[array exists mnet_freqs_onoff]} {
  112. # array unset mnet_freqs_onoff
  113. #}
  114. if {[array exists mnet_colors]} {
  115. array unset mnet_colors
  116. }
  117. if {[array exists mnet_colors_optional]} {
  118. array unset mnet_colors_optional
  119. }
  120. # list
  121. set mnet_networks ""
  122. unset mnet_networks
  123. # list
  124. set mnet_freqs "lala lala"
  125. unset mnet_freqs
  126. set mnet_bans "lala lala"
  127. unset mnet_bans
  128. # list FIXME (this kills the history upon every .mnet_reload ... :( .. not good)
  129. if {[array exists mnet_histories]} {
  130. array unset mnet_histories
  131. }
  132. set mnet_histories ""
  133. unset mnet_histories
  134. }
  135. proc ::cims::initvars {} {
  136. variable currentNetworkDesc
  137. variable currentNetworkSig
  138. variable startNetworkInstance
  139. variable currentBot
  140. variable currentOwner
  141. variable startBotInstance
  142. variable startFrequencyInstance
  143. variable mnet_networks
  144. variable mnet_freqs
  145. variable mnet_bans
  146. variable mnet_networks_by_prefix
  147. global botnet-nick
  148. set currentNetwork ""
  149. set currentSig ""
  150. set startNetworkInstance ""
  151. set currentBot ""
  152. set currentOwner ""
  153. set startBotInstance ""
  154. set startFrequencyInstance ""
  155. }
  156. ::cims::initvars
  157. proc ::cims::xmlElementStart {tagname attlist args} {
  158. variable mnet_networks
  159. variable mnet_bots
  160. variable mnet_channels
  161. variable mnet_freqs
  162. variable mnet_bans
  163. variable mnet_colors
  164. variable mnet_colors_optional
  165. variable mnet_freqs_onoff
  166. variable currentNetworkDesc
  167. variable currentNetworkSig
  168. variable startNetworkInstance
  169. variable currentBot
  170. variable currentOwner
  171. variable startBotInstance
  172. variable currentFreqName
  173. variable currentFreqPrefix
  174. variable currentFreqHelpmsg
  175. variable currentFreqDesc
  176. variable startFrequencyInstance
  177. global botnet-nick
  178. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  179. # putlog "::cims:: attr: '$attlist' arg: '$args'"
  180. # getting NETWORK NAME
  181. if {"$tagname" == "mnet"} {
  182. set currentNetworkDesc ""
  183. set currentNetworkSig ""
  184. foreach {key value} $attlist {
  185. if {"$key" == "sig"} {
  186. set currentNetworkSig $value
  187. }
  188. if {"$key" == "desc"} {
  189. set currentNetworkDesc $value
  190. }
  191. if {"$currentNetworkSig" != ""} {
  192. if {"$currentNetworkDesc" != ""} {
  193. putlog "yo: $currentNetworkSig $currentNetworkDesc"
  194. lappend mnet_networks "$currentNetworkSig" "$currentNetworkDesc"
  195. set startNetworkInstance 1
  196. }
  197. }
  198. }
  199. }
  200. # getting botinfos...
  201. if {"$startNetworkInstance" == "1"} {
  202. if {"$tagname" == "bot"} {
  203. set currentBot ""
  204. set currentOwner ""
  205. foreach {key value} $attlist {
  206. if {"$key" == "nick"} {
  207. set currentBot [::cims::proper_botnick $value]
  208. }
  209. if {"$key" == "owner"} {
  210. set currentOwner $value
  211. }
  212. }
  213. if {"$currentBot" != ""} {
  214. if {"$currentOwner" != ""} {
  215. # currentbot auf 9 zeichen runter.. lowercase
  216. # botnick ebenso
  217. lappend mnet_bots($currentNetworkSig) "$currentBot"
  218. putlog "::cims:: cfg: reached botcfg for: $currentBot - and my name is: $proper_botnick"
  219. if {"$currentBot" == "$proper_botnick"} {
  220. putlog "::cims:: Oh yes, I, ${botnet-nick}, am listed for the network $currentNetworkSig by using '$currentBot'!"
  221. set startBotInstance 1
  222. }
  223. }
  224. }
  225. }
  226. # end of $tagname == "bot"
  227. if {"$startBotInstance" == "1"} {
  228. if {"$tagname" == "ch"} {
  229. foreach {key value} $attlist {
  230. if {"$key" == "name"} {
  231. putlog "test: ${value}"
  232. lappend mnet_channels($currentNetworkSig,$currentBot) [::cims::proper_channelname ${value}]
  233. putlog "::cims:: cfg: my channels for $currentNetworkSig $mnet_channels($currentNetworkSig,$currentBot)"
  234. }
  235. }
  236. }
  237. # end of $tagname == "ch"
  238. }
  239. # end of a bot...
  240. if {"$tagname" == "frequency"} {
  241. set currentFreqName ""
  242. set currentFreqPrefix ""
  243. set currentFreqHelpmsg ""
  244. set currentFreqDesc ""
  245. set currentDelay "120"
  246. foreach {key value} $attlist {
  247. if {"$key" == "name"} {
  248. set currentFreqName $value
  249. }
  250. if {"$key" == "prefix"} {
  251. set currentFreqPrefix $value
  252. }
  253. if {"$key" == "helpmsg"} {
  254. set currentFreqHelpmsg $value
  255. }
  256. if {"$key" == "desc"} {
  257. set currentFreqDesc $value
  258. }
  259. if {"$key" == "delay"} {
  260. set currentDelay $value
  261. }
  262. }
  263. if {"$currentFreqName" != ""} {
  264. if {"$currentFreqPrefix" != ""} {
  265. if {"$currentFreqHelpmsg" != ""} {
  266. if {"$currentFreqDesc" != ""} {
  267. putlog "::cims:: i, ${botnet-nick}, serve the frequency: $currentFreqName ($currentFreqPrefix) of $currentNetworkSig!"
  268. set startFrequencyInstance 1
  269. lappend mnet_freqs($currentNetworkSig) "$currentNetworkSig" "$currentFreqName" "$currentFreqPrefix" "$currentFreqHelpmsg" "$currentFreqDesc" "$currentDelay"
  270. }
  271. }
  272. }
  273. }
  274. # end of: alle attribs vorhanden fr eine valide frequenz
  275. }
  276. # end of $tagname == "frequency"
  277. # in element Frequency, there are bans as children.
  278. if {"$startFrequencyInstance" == "1"} {
  279. if {"$tagname" == "ban"} {
  280. set currentBanHostmask ""
  281. set currentBanReason ""
  282. foreach {key value} $attlist {
  283. if {"$key" == "hostmask"} {
  284. set currentBanHostmask $value
  285. }
  286. if {"$key" == "reason"} {
  287. set currentBanReason $value
  288. }
  289. }
  290. if {"$currentBanHostmask" != ""} {
  291. if {"$currentBanReason" != ""} {
  292. putlog "::cims:: adding ban to frequency: $currentNetworkSig, $currentFreqPrefix, $currentBanHostmask, reason: $currentBanReason"
  293. lappend mnet_bans($currentNetworkSig,$currentFreqPrefix) "$currentBanHostmask" "$currentBanReason"
  294. }
  295. }
  296. }
  297. }
  298. if {"$tagname" == "color"} {
  299. set currentColor ""
  300. set currentColorOptional ""
  301. foreach {key value} $attlist {
  302. if {"$key" == "id"} {
  303. set currentColor $value
  304. putlog "::cims:: gone into colors! $value"
  305. }
  306. if {"$key" == "optional"} {
  307. set currentColorOptional $value
  308. putlog "::cims:: color optional? $value"
  309. }
  310. }
  311. if {"$currentColor" != ""} {
  312. set mnet_colors($currentNetworkSig) $currentColor
  313. putlog "::cims:: the color-id for $currentNetworkSig is: $currentColor"
  314. } else {
  315. # make NO color if no color-id or tag has been given:
  316. set mnet_colors($currentNetworkSig) none
  317. }
  318. if {"$currentColorOptional" != ""} {
  319. set mnet_colors_optional($currentNetworkSig) $currentColorOptional
  320. putlog "::cims:: the color is optional: $currentColorOptional"
  321. } else {
  322. set mnet_colors_optional($currentNetworkSig) 0
  323. putlog "::cims:: the color is NOT optional and will be forced."
  324. }
  325. }
  326. }
  327. }
  328. proc ::cims::xmlElementEnd {tagname} {
  329. variable mnet_networks
  330. variable mnet_bots
  331. variable mnet_channels
  332. variable currentNetworkDesc
  333. variable currentNetworkSig
  334. variable startNetworkInstance
  335. variable startBotInstance
  336. variable startFrequencyInstance
  337. variable currentBot
  338. variable currentOwner
  339. if {"$tagname" == "mnet"} {
  340. set startNetworkInstance 0
  341. set currentNetworkDesc ""
  342. set currentNetworkSig ""
  343. }
  344. if {"$tagname" == "bot"} {
  345. set startBotInstance 0
  346. }
  347. if {"$tagname" == "frequency"} {
  348. set startFrequencyInstance 0
  349. }
  350. }
  351. proc ::cims::xmlCdata {data} {
  352. # putlog "::cims:: data found: $data"
  353. return 1
  354. }
  355. proc ::cims::xmlHandleError {errorcode errormsg} {
  356. putlog "::cims:: some error occured: errcode $errorcode: $errormsg"
  357. }
  358. proc ::cims::xmlDefaultCmd {data} {
  359. putlog "::cims:: i don't know this element: $data"
  360. return 1
  361. }
  362. ##################################################################
  363. namespace eval ::cims {
  364. ## some internal variables for messaging and stuff :) not your business after all.
  365. set mnet(version) "cims!1.15many_plugins"
  366. set mnet_max_history 8
  367. set mnet_reached_users(dummy) "0"
  368. set mnet_reached_chans(dummy) "0"
  369. ##
  370. }
  371. proc ::cims::get_data {n} {
  372. if {[string range $n 0 0] == "\{"} {
  373. set n "\\$n"
  374. }
  375. return $n
  376. }
  377. proc ::cims::proper_botnick {botnick} {
  378. set temp [string tolower $botnick]
  379. # abfrage ob zu lang, dann fixen
  380. # putlog "::cims:: $botnick lowercase: $temp"
  381. if {[string length $botnick] > 9} {
  382. set temp [string range $temp 0 8 ]
  383. # putlog "::cims:: botnickname $botnick too long: capping to: $temp"
  384. }
  385. return $temp
  386. }
  387. proc ::cims::proper_channelname {channelname} {
  388. # channel names ARE NOT and SHOULD NOT BE CASE SENSITIVE!
  389. set temp [string tolower $channelname]
  390. set temp [::cims::umlauts $temp]
  391. # putlog "::cims:: $channelname lowercase: $temp"
  392. return $temp
  393. }
  394. proc ::cims::put_local_netmessage {network name chan rec_nickname rec_channel rec_text} {
  395. variable mnet_colors
  396. variable mnet_colors_optional
  397. variable mnet_colors_onoff
  398. # validating incoming vars..
  399. set chan [::cims::proper_channelname $chan]
  400. # unescaping vars .. this is an output procedure! remember?
  401. set rec_nickname [join $rec_nickname]
  402. set rec_channel [join $rec_channel]
  403. set rec_text [join $rec_text]
  404. if {$mnet_colors($network) == "none"} {
  405. # if no color id was found...
  406. set color_string ""
  407. } else {
  408. # if there was a color id...
  409. if {$mnet_colors_optional($network) == 1} {
  410. # check for the channel if activated..
  411. if {$mnet_colors_onoff($name,$chan) == 1} {
  412. set color_string "\003$mnet_colors($network)"
  413. set bold_string "\002"
  414. set bold_string_end "\002"
  415. } else {
  416. set color_string ""
  417. set bold_string ""
  418. set bold_string_end ""
  419. }
  420. } else {
  421. # if not optional then force colors.. whatever :)
  422. set color_string "\003$mnet_colors($network)"
  423. set bold_string "\002"
  424. set bold_string_end "\002"
  425. }
  426. }
  427. putserv "PRIVMSG $chan :${bold_string}${name}${bold_string_end} ${color_string}${rec_nickname} - ${rec_channel} : ${rec_text}"
  428. putlog "::cims:: + local message from $rec_nickname @ $rec_channel to $chan : $rec_text"
  429. }
  430. proc get_httpfile {host file port} {
  431. global botnet-nick
  432. putlog "get_httpfile::debug host: $host file: $file port: $port"
  433. if {[catch {set sock [socket $host $port] } sockerror]} {
  434. putlog "get_httpfile:: sockerror: $sockerror"
  435. return 0
  436. } else {
  437. puts $sock "GET $file HTTP/1.0"
  438. puts $sock "User-Agent: Mozilla/5.0 (compatible; ${botnet-nick}; mnet.tcl)"
  439. puts $sock "Host: $host"
  440. puts $sock "Connection: close"
  441. puts $sock ""
  442. flush $sock
  443. set header_done 0
  444. set data ""
  445. # get some strings out of the http stream.. better write them in a var.. normally.
  446. while {[eof $sock] != 1} {
  447. set bl [gets $sock]
  448. # putlog "test: $bl"
  449. if {[string match "" $bl]} {
  450. set header_done 1
  451. }
  452. if {$header_done == 1} {
  453. set data "$data\n$bl"
  454. }
  455. }
  456. close $sock
  457. return $data
  458. }
  459. }
  460. proc get_localfile {file} {
  461. set data ""
  462. if {[file isfile "$file"] == 1} {
  463. set fh [open "$file" "r"]
  464. while {![eof $fh]} {
  465. set line [gets $fh]
  466. append data $line
  467. }
  468. return $data
  469. } else {
  470. putlog "::cims:: Local configfile $file not found. Ignoring."
  471. }
  472. }
  473. #::cims::write_arraytofile "scripts/cims/$botnick.cims" "mnet_freqs_onoff"
  474. proc ::cims::write_arraytofile {file arrayname} {
  475. variable $arrayname
  476. set array_string [array get $arrayname]
  477. #putlog "array_string: $array_string"
  478. set fh [open "$file" "w"]
  479. puts $fh $array_string
  480. close $fh
  481. }
  482. #::cims::read_arrayfromfile "scripts/cims/$botnick.cims" "mnet_freqs_onoff"
  483. proc ::cims::read_arrayfromfile {file arrayname} {
  484. variable $arrayname
  485. set fh [open "$file" "r"]
  486. array set $arrayname [gets $fh]
  487. close $fh
  488. }
  489. proc ::cims::dummy {} {
  490. return 0
  491. }
  492. #not used..
  493. proc ::cims::kill_delaytimer {prefix chan} {
  494. variable mnet_delay
  495. set mnet_delay($prefix,$chan) 0
  496. putlog "Sending in $chan allowed again, since the timer expired"
  497. }
  498. proc ::cims::put_bot {botnetnick data} {
  499. set testlink [islinked $botnetnick]
  500. if {$testlink == 1} {
  501. putlog "::cims:: put_bot: + a message delivered to $botnetnick."
  502. if {[string length $data] > 335} {
  503. #::putils::filelog "scripts/cims/cims.log" "alldata put_bot to $botnetnick: $data"
  504. ::putils::put_bot $botnetnick $data
  505. } else {
  506. putbot $botnetnick $data
  507. }
  508. } else {
  509. putlog "::cims:: put_bot: + a message couldn't be delivered. Bot $botnetnick is not linked"
  510. }
  511. }
  512. proc ::cims::chanstat_users {chan users} {
  513. set ch_users [chanlist $chan]
  514. set ch_users_count [llength $ch_users]
  515. set users [expr $users + $ch_users_count]
  516. return $users
  517. }
  518. # this proc makes ::cims::chanstat_users obsolete! hmm.. but we leave it for some time. compatibility stuff!
  519. proc ::cims::chanstat_userlist {chan unique_userlist} {
  520. set ch_userlist [chanlist ${chan}]
  521. set unique_userlist [lsort -unique [join [concat [split $unique_userlist] [split $ch_userlist]]]]
  522. #putlog "uulist: $unique_userlist"
  523. return $unique_userlist
  524. }
  525. proc ::cims::history_queue {bucket nickname channel rec_text} {
  526. #::cims::history_queue $network,$name "$timestamp $rec_nickname $rec_channel $rec_text"
  527. variable mnet_histories
  528. variable mnet_max_history
  529. #putlog "::cims:: HISTORY $nickname $channel $rec_text"
  530. set timestamp [clock format [clock seconds] -format "%H:%M:%S"]
  531. #putlog "tstamp: $timestamp"
  532. # no clean:text needed .. already done sometime before.
  533. set input_history "$timestamp / $nickname - $channel : $rec_text"
  534. # putlog "tst: $timestamp nick: $nickname chan: $channel txt: $rec_text"
  535. set list_length 0
  536. if {[info exists mnet_histories($bucket)] == 1} {
  537. set list_length [llength $mnet_histories($bucket)]
  538. putlog "listlength of mnet_histories($bucket) before: $list_length"
  539. }
  540. if {$list_length >= $mnet_max_history} {
  541. # $mnet_max_history 10 - 9
  542. # 5= 1 4
  543. #10= 1 9
  544. # wenn man von 10 auf 5 wechselt: 6 9
  545. set mnet_histories($bucket) [lrange $mnet_histories($bucket) [expr $list_length - $mnet_max_history + 1] [expr $list_length - 1]]
  546. # putlog "grosser oder gleich 10: str: $input"
  547. }
  548. lappend mnet_histories($bucket) $input_history
  549. #set list_length [llength $mnet_histories($bucket)]
  550. #putlog "listlength of mnet_histories($bucket) now: $list_length"
  551. # define your own logging
  552. if {[info procs ::cims::history_logger] == "::cims::history_logger"} {
  553. ::cims::history_logger $bucket $nickname $channel $rec_text
  554. } else {
  555. putlog "::cims:: procedure ::cims::history_logger hasn't been defined. Do it, if you want logging."
  556. }
  557. }
  558. ## procs which are executed remotely follow:
  559. proc ::cims::receive_message {rec_botnick cmd rec_data} {
  560. variable mnet
  561. variable mnet_channels
  562. variable mnet_freqs_onoff
  563. variable mnet_bots
  564. variable mnet_histories
  565. global botnet-nick
  566. #putlog "rec_data string: '$rec_data'"
  567. # escape it to be a list FIRST.. and for output later, let the list JOIN together to a string again!
  568. #set rec_data [split $rec_data]
  569. putlog "rec_data list: '$rec_data'"
  570. set tmp_network [join [lindex $rec_data 0]]
  571. set tmp_name [join [lindex $rec_data 1]]
  572. #putlog "tmp_net: '$tmp_network'"
  573. #putlog "tmp_nam: '$tmp_name'"
  574. set network [::putils::kill_spaces $tmp_network]
  575. #putlog "network: '$network'"
  576. set name [::putils::kill_spaces $tmp_name]
  577. #putlog "name: '$name'"
  578. set rec_nickname [join [lindex $rec_data 2]]
  579. #putlog "rec_nickname: '$rec_nickname'"
  580. set rec_channel [::putils::kill_spaces [join [lindex $rec_data 3]]]
  581. #set rec_text [::cims::clean_txt [join [lrange [split $rec_data] 4 end]]]
  582. set rec_text [join [lrange $rec_data 4 end]]
  583. #putlog "rec_text: '$rec_text'"
  584. set allowed [::cims::allowed_netbot $network ${rec_botnick}]
  585. if {$allowed == 0} {
  586. return 0
  587. }
  588. # now the bot is declared as a known bot.
  589. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  590. putlog "::cims:: + Relaying Message from: $rec_nickname @ $rec_botnick @ $rec_channel: $rec_text"
  591. set unique_userlist ""
  592. set users 0
  593. set count_channels 0
  594. ::cims::history_queue $network,$name $rec_nickname $rec_channel $rec_text
  595. # plugin... if you want it to do other stuff with a received netbot message as well.
  596. if {[info procs ::cims::message_from_netbot_to_plugin] == "::cims::message_from_netbot_to_plugin"} {
  597. ::cims::message_from_netbot_to_plugin $rec_botnick $network $name $rec_channel $rec_nickname $rec_text
  598. }
  599. # send message to all local channels, and count stats:
  600. foreach {chan} $mnet_channels($network,$proper_botnick) {
  601. if {[::cims::botonchannel $chan] == "1"} {
  602. # erster disable/enable check
  603. if {$mnet_freqs_onoff($name,$chan) == 1} {
  604. incr count_channels
  605. set users [::cims::chanstat_users $chan $users]
  606. set unique_userlist [::cims::chanstat_userlist $chan $unique_userlist]
  607. putlog "::cims:: * Remote counting, $chan "
  608. ::cims::put_local_netmessage $network $name $chan $rec_nickname $rec_channel $rec_text
  609. } else {
  610. putlog "::cims:: + $chan has disabled $name output"
  611. }
  612. } else {
  613. putlog "::cims:: + Can't relay a message to '$chan' since I am not there."
  614. }
  615. }
  616. # building a fake userlist of 500 people for debugging:
  617. # for {set x 0} {$x < 500} {incr x} {
  618. # set unique_userlist [lsort -unique [concat $unique_userlist [::putils::randomRangeString 6]]]
  619. # }
  620. #putlog "::cims:: unique_userlist is [llength $unique_userlist] long"
  621. # it is an eggdrop limitation/bug that it is not allowed to send large botnet messages via putbot.
  622. # it truncates our payload after 388 chars. in fact the payload is 401 chars.
  623. #
  624. # we need a workaround! fixme! tcldcc.c:
  625. #
  626. #static int tcl_putbot STDVAR
  627. #{
  628. #int i;
  629. #char msg[401];
  630. #...
  631. #}
  632. # ANSWER! SEND THE REPLY of counts to the originating bot.
  633. ::cims::put_bot $rec_botnick "mnet_answer $network $name $rec_channel $users $count_channels $unique_userlist"
  634. return 0
  635. }
  636. proc ::cims::receive_answer {rec_botnick cmd rec_data} {
  637. variable mnet
  638. variable mnet_reached_users
  639. variable mnet_reached_userlist
  640. variable mnet_reached_chans
  641. global botnet-nick
  642. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  643. set long [string length $rec_data]
  644. putlog "::cims:: * on receive_answer from $rec_botnick length: $long"
  645. # we receive a STRING in rec_data! convert into list!
  646. set rec_data [split $rec_data]
  647. # work with list (lindex, lrange) and put together to a STRING again with JOIN.
  648. set network [join [lindex $rec_data 0]]
  649. set name [join [lindex $rec_data 1]]
  650. set chan [join [lindex $rec_data 2]]
  651. # rec_usercount is obsolete
  652. set rec_usercount [join [lindex $rec_data 3]]
  653. set rec_chancount [join [lindex $rec_data 4]]
  654. set rec_userlist [join [lrange $rec_data 5 end]]
  655. # override obsolete rec_usercount from above.
  656. set rec_usercount [llength $rec_userlist]
  657. # get this bots results to our namespaced variable:
  658. # FIXME: make simple userstats more accurate by sending nicknames back..
  659. # done: userstats should be counted in a correct variablename .. according to network and frequency
  660. # if you don't pay attention to it, a conflict between two broadcasts counting users may appear.
  661. # $mnet_reached_chans($name,$chan) <- $mnet_reached_users($name,$chan)
  662. set mnet_reached_users($name,$chan) [expr $mnet_reached_users($name,$chan) + $rec_usercount]
  663. set mnet_reached_chans($name,$chan) [expr $mnet_reached_chans($name,$chan) + $rec_chancount]
  664. set mnet_reached_userlist($name,$chan) [lsort -unique [join [concat [split $mnet_reached_userlist($name,$chan)] [split $rec_userlist]]]]
  665. putlog "::cims:: * near end receive_answer from $rec_botnick"
  666. putlog "::cims:: * $rec_botnick told me he sent its message to $rec_usercount unique people in $rec_chancount channels for $network frequency $name!"
  667. #putlog "::cims:: * Users reached since $name call: $mnet_reached_users($name,$chan) in channels: $mnet_reached_chans($name,$chan)"
  668. }
  669. proc ::cims::clean_txt {text} {
  670. # putlog "filter_A: ${text}"
  671. # regsub -all "\\" $text "\\\\" text
  672. # fixes many whitespace between words down to one space between words
  673. regsub -all "\\s+" $text " " text
  674. # filtering out all colorcodes (works well)
  675. regsub -all "\003\[0-9\]\{1,2\},\[0-9\]\{1,2\}" $text "" text
  676. regsub -all "\003\[0-9\]\{1,2\}" $text "" text
  677. regsub -all "\003" $text "" text
  678. # filtering out BOLD text
  679. regsub -all "\002" $text "" text
  680. # underline gets filtered too. (since +c on quakenet would suppress it ...)
  681. regsub -all "\037" $text "" text
  682. # replacing like !!!!!!!!!!!!! with !!!!! (5 letters)
  683. # s/(.?)\1{4,}/\1\1\1\1\1/g;
  684. # - max 5 same chars in a row
  685. regsub -all -nocase -expanded {(.)\1\1\1\1+} $text {\1\1\1\1\1} text
  686. # putlog "test: $text"
  687. set text [string trim $text]
  688. # putlog "filter_B: ${text}"
  689. return $text
  690. }
  691. proc ::cims::umlauts {text} {
  692. # A REAL STRANGE BUG WORKAROUND WITH UMLAUTS
  693. regsub -all "Ä" ${text} "Ä" text
  694. regsub -all "Ü" ${text} "Ü" text
  695. regsub -all "Ö" ${text} "Ö" text
  696. regsub -all "ä" ${text} "ä" text
  697. regsub -all "ü" ${text} "ü" text
  698. regsub -all "ö" ${text} "ö" text
  699. return ${text}
  700. }
  701. proc ::cims::botonchannel {chan} {
  702. # safe "bot-knows-the-channel-and-is-in-there"-function
  703. if {[validchan $chan] == 1 && [botonchan $chan] == 1} {
  704. return 1
  705. } else {
  706. return 0
  707. }
  708. }
  709. # allowcheck for public commands..
  710. proc ::cims::allowed_channel {network name prefix nick mask chan} {
  711. variable mnet
  712. variable mnet_channels
  713. variable mnet_bots
  714. variable mnet_freqs
  715. variable mnet_networks_by_prefix
  716. variable mnet_colors
  717. global botnick botnet-nick lastbind
  718. # validating incoming vars
  719. set chan [::cims::proper_channelname $chan]
  720. putlog "::cims:: = a command for ($prefix) triggered by $nick ($mask) in $chan"
  721. # the command must be from a channel of "ownchannels"
  722. putlog "::cims:: = trying if $chan is allowed in network: $network"
  723. set found 0
  724. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  725. foreach _trigger_chan $mnet_channels($network,$proper_botnick) {
  726. #putlog "::cims:: = test: $_trigger_chan vs $chan"
  727. if {[string compare -nocase $_trigger_chan $chan] == 0} {
  728. putlog "::cims:: = channel: $_trigger_chan is allowed in network: $network"
  729. set found 1
  730. } else {
  731. # putlog "::cims:: = not in list: $chan"
  732. }
  733. }
  734. if {$found == 0} {
  735. putlog "::cims:: = triggering $prefix of network $network in $chan is not allowed (in my point of view)"
  736. return 0
  737. }
  738. set snd_nick [::cims::get_data $nick]
  739. if {![isop $nick $chan]} {
  740. putlog "::cims:: = allowed in $chan, but $nick is no op"
  741. ::putils::put_nick $nick "Sorry $nick, you need to be op."
  742. return 0
  743. }
  744. if {$nick == $botnick} {
  745. # no recursion :)
  746. return 0
  747. }
  748. # got through all checks .. so it's an OK channel
  749. return 1
  750. }
  751. # checks if the user is allowed, returns 1 if OK.
  752. # checks against the xml config of the banned ones.
  753. proc ::cims::allowed_user {network name prefix nick mask chan} {
  754. variable layout
  755. variable mnet_channels
  756. variable mnet_bots
  757. variable mnet_bans
  758. variable mnet_networks_by_prefix
  759. variable mnet_colors
  760. global botnick botnet-nick lastbind
  761. # validating incoming vars
  762. set chan [::cims::proper_channelname $chan]
  763. # does mnet_bans even exist? it's optional after all.
  764. if {[info exists mnet_bans($network,$prefix)] == 1} {
  765. putlog "::cims:: = a command for ($prefix) triggered by $nick ($mask) in $chan"
  766. # the command must be from a channel of "ownchannels"
  767. putlog "::cims:: = trying if $nick ($mask) banned from frequency: $network,$prefix"
  768. set found 0
  769. foreach {hostmask reason} $mnet_bans($network,$prefix) {
  770. if {[string match [string tolower $hostmask] [string tolower $mask]]} {
  771. putlog "::cims:: = allowed_user: $nick ($mask) is not allowed in network ($network) by hostmask ($hostmask) for reason: $reason"
  772. set found 1
  773. } else {
  774. # putlog "::cims:: = not in list: $chan"
  775. }
  776. }
  777. if {$found == 1} {
  778. # tell the user his ban. :)
  779. set output [::cims::sarvar $layout(user_banned)]
  780. ::putils::put_nick $nick $output
  781. return 0
  782. }
  783. }
  784. # got through all checks .. so user is not in banlist
  785. return 1
  786. }
  787. # allowcheck for bots sending netmessages
  788. proc ::cims::allowed_netbot {network netbot} {
  789. variable mnet
  790. variable mnet_bots
  791. global botnick botnet-nick lastbind
  792. putlog "::cims:: = a netbot $netbot sending message... allowed?"
  793. # the command must be from a channel of "ownchannels"
  794. set found 0
  795. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  796. set proper_netbot [::cims::proper_botnick $netbot]
  797. foreach {_netbotnick} $mnet_bots($network) {
  798. if {$_netbotnick == $proper_netbot} {
  799. putlog "::cims:: = netbot: $proper_netbot is allowed in network: $network"
  800. set found 1
  801. } else {
  802. # putlog "::cims:: = netbot: ...."
  803. }
  804. }
  805. if {$found == 0} {
  806. putlog "::cims:: = $proper_netbot of network $network sent me something - but it is not allowed in my network: $network"
  807. return 0
  808. }
  809. if {$netbot == ${botnet-nick}} {
  810. # if myself (for some reason) then don't do anything... no recursion :)
  811. return 0
  812. }
  813. # got through all checks .. so it's an OK netbot for a given network
  814. return 1
  815. }
  816. # enter variables into placeholders of that pre-defined string "layout(local_reply)"
  817. proc ::cims::sarvar {layout_string} {
  818. set the_list [regexp -inline -all {@@(.+?)@@} $layout_string]
  819. foreach {thing thong} $the_list {
  820. #putlog "thing: $thing"
  821. #putlog "thong: $thong"
  822. # delete upvar link, if it existed.
  823. if {[info exists replacer]} {
  824. unset replacer
  825. }
  826. # find the variable that is available in the previous context and use this now..
  827. upvar $thong replacer
  828. if {[info exists replacer]} {
  829. if {"$replacer" != ""} {
  830. #putlog "hum: $replacer"
  831. regsub -all "$thing" $layout_string "$replacer" layout_string
  832. }
  833. }
  834. }
  835. return $layout_string
  836. }
  837. proc ::cims::timeout_reply_from_local_for_netbots {name chan} {
  838. variable mnet
  839. variable mnet_reached_users
  840. variable mnet_reached_userlist
  841. variable mnet_reached_chans
  842. variable layout
  843. global botnet-nick
  844. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  845. # clean $name and $chan
  846. set name [::putils::kill_spaces $name]
  847. set chan [::putils::kill_spaces $chan]
  848. # easify variables
  849. set userlist $mnet_reached_userlist($name,$chan)
  850. set user_cnt [llength $userlist]
  851. set mnet_reached_users($name,$chan) $user_cnt
  852. set chan_cnt $mnet_reached_chans($name,$chan)
  853. # inzwischen dürfte auch die antwort gekommen sein.. also jetzt mnet_reached_* auswerten nach timeout..
  854. # make stats channel-dependent
  855. #putlog "::cims:: * userlist is finally: $userlist "
  856. putlog "::cims:: * After ALL: Count_Users: $user_cnt Count_Channels: $mnet_reached_chans($name,$chan)"
  857. # Give me some reply.
  858. ::putils::filelog "scripts/cims/${proper_botnick}.log" "$name from $chan reached $user_cnt users: $userlist"
  859. # enter variables into placeholders of that pre-defined string "layout(local_reply)"
  860. set output [::cims::sarvar $layout(local_reply)]
  861. # plugin before the final answer... if you want it to do other stuff as well.
  862. if {[info procs ::cims::timeout_reply_from_local_for_netbots_plugin] == "::cims::timeout_reply_from_local_for_netbots_plugin"} {
  863. ::cims::timeout_reply_from_local_for_netbots_plugin $name $chan
  864. }
  865. ::putils::put_local_msg ${chan} $output
  866. }
  867. ### public reachable commands
  868. proc ::cims::history_frequency {nick mask hand chan text} {
  869. # proc triggered by specified $prefix_history
  870. variable mnet
  871. variable mnet_channels
  872. variable mnet_bots
  873. variable mnet_networks_by_prefix
  874. variable mnet_colors
  875. variable mnet_freqs
  876. variable mnet_freqs_onoff
  877. variable mnet_histories
  878. variable mnet_max_history
  879. global botnick lastbind
  880. set com $lastbind
  881. # validating incoming vars
  882. set chan [::cims::proper_channelname $chan]
  883. # cutting .prefix_history down to .prefix
  884. set prefix [string range $com 0 [expr [string first _ $com] -1]]
  885. #putlog "::cims:: the prefix is $prefix"
  886. set network [join [lindex $mnet_networks_by_prefix($prefix) 0]]
  887. set name [join [lindex $mnet_networks_by_prefix($prefix) 1]]
  888. set help [join [lindex $mnet_networks_by_prefix($prefix) 2]]
  889. set desc [join [lindex $mnet_networks_by_prefix($prefix) 3]]
  890. putlog "network: $network"
  891. set allowed [::cims::allowed_channel $network $name $prefix $nick $mask $chan]
  892. if {$allowed == 0} {
  893. return 0
  894. }
  895. # now generally allowed.
  896. putlog "mnet_history: $com triggered by $nick in $chan"
  897. if {[info exists mnet_histories($network,$name)] == 1} {
  898. set list_length [llength $mnet_histories($network,$name)]
  899. if {$list_length >= 1} {
  900. set msg "::cims:: last $mnet_max_history messages of $network $name:"
  901. ::putils::put_nick $nick $msg
  902. set x_count 0
  903. foreach {msg} $mnet_histories($network,$name) {
  904. incr x_count
  905. set backwards_x [expr $list_length - $x_count]
  906. set msg [lindex $mnet_histories($network,$name) $backwards_x]
  907. ::putils::put_nick $nick "($x_count/$list_length) $msg"
  908. }
  909. }
  910. } else {
  911. ::putils::put_nick $nick "::cims:: no accumulated history for $network $name"
  912. }
  913. }
  914. proc ::cims::enable_frequency {nick mask hand chan text} {
  915. # proc triggered by specified $prefix_enable
  916. variable mnet
  917. variable mnet_channels
  918. variable mnet_bots
  919. variable mnet_networks_by_prefix
  920. variable mnet_colors
  921. variable mnet_freqs
  922. variable mnet_freqs_onoff
  923. global botnick lastbind botnet-nick
  924. set com $lastbind
  925. # validating incoming vars
  926. set chan [::cims::proper_channelname $chan]
  927. # cutting .prefix_enable down to .prefix
  928. set prefix [string range $com 0 [expr [string first _ $com] -1]]
  929. #putlog "::cims:: the prefix is $prefix"
  930. set network [join [lindex $mnet_networks_by_prefix($prefix) 0]]
  931. set name [join [lindex $mnet_networks_by_prefix($prefix) 1]]
  932. set help [join [lindex $mnet_networks_by_prefix($prefix) 2]]
  933. set desc [join [lindex $mnet_networks_by_prefix($prefix) 3]]
  934. #putlog "network: $network"
  935. set allowed [::cims::allowed_channel $network $name $prefix $nick $mask $chan]
  936. if {$allowed == 0} {
  937. return 0
  938. }
  939. # now generally allowed.
  940. putlog "mnet_freq_status: before $mnet_freqs_onoff($name,$chan)"
  941. set mnet_freqs_onoff($name,$chan) 1
  942. putlog "mnet_freq_status: now $mnet_freqs_onoff($name,$chan)"
  943. ::putils::put_local_msg $chan "::cims:: $name _output_ enabled for $chan"
  944. }
  945. proc ::cims::disable_frequency {nick mask hand chan text} {
  946. # proc triggered by specified $prefix_enable
  947. variable mnet
  948. variable mnet_channels
  949. variable mnet_bots
  950. variable mnet_networks_by_prefix
  951. variable mnet_colors
  952. variable mnet_freqs
  953. variable mnet_freqs_onoff
  954. global botnick lastbind
  955. set com $lastbind
  956. # validating incoming vars
  957. set chan [::cims::proper_channelname $chan]
  958. # cutting .prefix_enable down to .prefix
  959. set prefix [string range $com 0 [expr [string first _ $com] -1]]
  960. putlog "::cims:: the prefix is $prefix"
  961. set network [join [lindex $mnet_networks_by_prefix($prefix) 0]]
  962. set name [join [lindex $mnet_networks_by_prefix($prefix) 1]]
  963. set help [join [lindex $mnet_networks_by_prefix($prefix) 2]]
  964. set desc [join [lindex $mnet_networks_by_prefix($prefix) 3]]
  965. #putlog "network: $network"
  966. set allowed [::cims::allowed_channel $network $name $prefix $nick $mask $chan]
  967. if {$allowed == 0} {
  968. return 0
  969. }
  970. # now generally allowed.
  971. putlog "mnet_freq_status: before $mnet_freqs_onoff($name,$chan)"
  972. set mnet_freqs_onoff($name,$chan) 0
  973. putlog "mnet_freq_status: now $mnet_freqs_onoff($name,$chan)"
  974. ::putils::put_local_msg $chan "::cims:: $name _output_ disabled for $chan"
  975. }
  976. proc ::cims::toggle_frequency {nick mask hand chan text} {
  977. # proc triggered by specified $prefix_toggle
  978. variable mnet
  979. variable mnet_channels
  980. variable mnet_bots
  981. variable mnet_networks_by_prefix
  982. variable mnet_colors
  983. variable mnet_freqs
  984. variable mnet_freqs_onoff
  985. global botnick lastbind
  986. set com $lastbind
  987. # validating incoming vars
  988. set chan [::cims::proper_channelname $chan]
  989. # cutting .prefix_enable down to .prefix
  990. set prefix [string range $com 0 [expr [string first _ $com] -1]]
  991. # putlog "::cims:: the prefix is $prefix"
  992. set network [join [lindex $mnet_networks_by_prefix($prefix) 0]]
  993. set name [join [lindex $mnet_networks_by_prefix($prefix) 1]]
  994. set help [join [lindex $mnet_networks_by_prefix($prefix) 2]]
  995. set desc [join [lindex $mnet_networks_by_prefix($prefix) 3]]
  996. # putlog "network: $network"
  997. set allowed [::cims::allowed_channel $network $name $prefix $nick $mask $chan]
  998. if {$allowed == 0} {
  999. return 0
  1000. }
  1001. # now generally allowed.
  1002. putlog "mnet_freq_status: toggle $mnet_freqs_onoff($name,$chan)"
  1003. if {$mnet_freqs_onoff($name,$chan) == 1} {
  1004. set mnet_freqs_onoff($name,$chan) 0
  1005. ::putils::put_local_msg $chan "::cims:: toggling ${name} _output_, now disabled for ${chan}"
  1006. } else {
  1007. set mnet_freqs_onoff($name,$chan) 1
  1008. ::putils::put_local_msg $chan "::cims:: toggling ${name} _output_, now enabled for ${chan}"
  1009. }
  1010. putlog "mnet_freq_status: toggle now $mnet_freqs_onoff($name,$chan)"
  1011. # frequency toggled .. :)
  1012. }
  1013. #::cims::enable_color
  1014. proc ::cims::enable_color {nick mask hand chan text} {
  1015. # proc triggered by specified $prefix_enable
  1016. variable mnet
  1017. variable mnet_channels
  1018. variable mnet_bots
  1019. variable mnet_networks_by_prefix
  1020. variable mnet_colors_optional
  1021. variable mnet_colors_onoff
  1022. global botnick lastbind
  1023. set com $lastbind
  1024. # validating incoming vars
  1025. set chan [::cims::proper_channelname $chan]
  1026. # cutting .prefix_enable down to .prefix
  1027. set prefix [string range $com 0 [expr [string first _ $com] -1]]
  1028. #putlog "::cims:: the prefix is $prefix"
  1029. set network [join [lindex $mnet_networks_by_prefix($prefix) 0]]
  1030. set name [join [lindex $mnet_networks_by_prefix($prefix) 1]]
  1031. set help [join [lindex $mnet_networks_by_prefix($prefix) 2]]
  1032. set desc [join [lindex $mnet_networks_by_prefix($prefix) 3]]
  1033. #putlog "network: $network"
  1034. set allowed [::cims::allowed_channel $network $name $prefix $nick $mask $chan]
  1035. if {$allowed == 0} {
  1036. return 0
  1037. }
  1038. # now generally allowed.
  1039. if {$mnet_colors_optional($network) != 1} {
  1040. return 0
  1041. }
  1042. putlog "mnet_color_status: before $mnet_colors_onoff($name,$chan)"
  1043. set mnet_colors_onoff($name,$chan) 1
  1044. putlog "mnet_color_status: now $mnet_colors_onoff($name,$chan)"
  1045. ::putils::put_local_msg $chan "::cims:: $name _coloroutput_ enabled for $chan"
  1046. }
  1047. #::cims::disable_color
  1048. proc ::cims::disable_color {nick mask hand chan text} {
  1049. # proc triggered by specified $prefix_enable
  1050. variable mnet
  1051. variable mnet_channels
  1052. variable mnet_bots
  1053. variable mnet_networks_by_prefix
  1054. variable mnet_colors_optional
  1055. variable mnet_colors_onoff
  1056. global botnick lastbind
  1057. set com $lastbind
  1058. # validating incoming vars
  1059. set chan [::cims::proper_channelname $chan]
  1060. # cutting .prefix_enable down to .prefix
  1061. set prefix [string range $com 0 [expr [string first _ $com] -1]]
  1062. #putlog "::cims:: the prefix is $prefix"
  1063. set network [join [lindex $mnet_networks_by_prefix($prefix) 0]]
  1064. set name [join [lindex $mnet_networks_by_prefix($prefix) 1]]
  1065. set help [join [lindex $mnet_networks_by_prefix($prefix) 2]]
  1066. set desc [join [lindex $mnet_networks_by_prefix($prefix) 3]]
  1067. #putlog "network: $network"
  1068. set allowed [::cims::allowed_channel $network $name $prefix $nick $mask $chan]
  1069. if {$allowed == 0} {
  1070. return 0
  1071. }
  1072. # now generally allowed.
  1073. if {$mnet_colors_optional($network) != 1} {
  1074. return 0
  1075. }
  1076. putlog "mnet_color_status: before $mnet_colors_onoff($name,$chan)"
  1077. set mnet_colors_onoff($name,$chan) 0
  1078. putlog "mnet_color_status: now $mnet_colors_onoff($name,$chan)"
  1079. ::putils::put_local_msg $chan "::cims:: $name _coloroutput_ disabled for $chan"
  1080. }
  1081. #::cims::toggle_color
  1082. proc ::cims::toggle_color {nick mask hand chan text} {
  1083. # proc triggered by specified $prefix_toggle
  1084. variable mnet
  1085. variable mnet_channels
  1086. variable mnet_bots
  1087. variable mnet_networks_by_prefix
  1088. variable mnet_colors_optional
  1089. variable mnet_colors_onoff
  1090. global botnick lastbind
  1091. set com $lastbind
  1092. # validating incoming vars
  1093. set chan [::cims::proper_channelname $chan]
  1094. # cutting .prefix_enable down to .prefix
  1095. set prefix [string range $com 0 [expr [string first _ $com] -1]]
  1096. # putlog "::cims:: the prefix is $prefix"
  1097. set network [join [lindex $mnet_networks_by_prefix($prefix) 0]]
  1098. set name [join [lindex $mnet_networks_by_prefix($prefix) 1]]
  1099. set help [join [lindex $mnet_networks_by_prefix($prefix) 2]]
  1100. set desc [join [lindex $mnet_networks_by_prefix($prefix) 3]]
  1101. # putlog "network: $network"
  1102. set allowed [::cims::allowed_channel $network $name $prefix $nick $mask $chan]
  1103. if {$allowed == 0} {
  1104. return 0
  1105. }
  1106. # now generally allowed.
  1107. if {$mnet_colors_optional($network) != 1} {
  1108. return 0
  1109. }
  1110. putlog "mnet_color_status: toggle $mnet_colors_onoff($name,$chan)"
  1111. if {$mnet_colors_onoff($name,$chan) == 1} {
  1112. set mnet_colors_onoff($name,$chan) 0
  1113. ::putils::put_local_msg $chan "::cims:: toggling ${name} _coloroutput_, now disabled for ${chan}"
  1114. } else {
  1115. set mnet_colors_onoff($name,$chan) 1
  1116. ::putils::put_local_msg $chan "::cims:: toggling ${name} _coloroutput_, now enabled for ${chan}"
  1117. }
  1118. putlog "mnet_color_status: toggle now $mnet_colors_onoff($name,$chan)"
  1119. # color for a channel toggled .. :)
  1120. }
  1121. #::cims::toggle_color
  1122. proc ::cims::status_frequency {nick mask hand chan text} {
  1123. # proc triggered by specified $prefix_toggle
  1124. variable mnet
  1125. variable mnet_channels
  1126. variable mnet_bots
  1127. variable mnet_networks_by_prefix
  1128. variable mnet_colors_optional
  1129. variable mnet_colors_onoff
  1130. variable mnet_freqs_onoff
  1131. variable mnet_reached_users
  1132. variable mnet_reached_chans
  1133. global botnick lastbind
  1134. set com $lastbind
  1135. # validating incoming vars
  1136. set chan [::cims::proper_channelname $chan]
  1137. # cutting .prefix_enable down to .prefix
  1138. set prefix [string range $com 0 [expr [string first _ $com] -1]]
  1139. # putlog "::cims:: the prefix is $prefix"
  1140. set network [join [lindex $mnet_networks_by_prefix($prefix) 0]]
  1141. set name [join [lindex $mnet_networks_by_prefix($prefix) 1]]
  1142. set help [join [lindex $mnet_networks_by_prefix($prefix) 2]]
  1143. set desc [join [lindex $mnet_networks_by_prefix($prefix) 3]]
  1144. # putlog "network: $network"
  1145. set allowed [::cims::allowed_channel $network $name $prefix $nick $mask $chan]
  1146. if {$allowed == 0} {
  1147. return 0
  1148. }
  1149. # now generally allowed.
  1150. ## get status for this frequency.
  1151. set status_message "$chan $name: "
  1152. if {$mnet_freqs_onoff($name,$chan) == 1} {
  1153. append status_message "Frequency output is on. "
  1154. } else {
  1155. append status_message "Frequency output is off. "
  1156. }
  1157. if {$mnet_colors_optional($network) == 1} {
  1158. if {$mnet_colors_onoff($name,$chan) == 1} {
  1159. append status_message "Colors are turned on. "
  1160. } else {
  1161. append status_message "Colors are turned off. "
  1162. }
  1163. } else {
  1164. append status_message "Message-colors are forced. "
  1165. }
  1166. if {[info exists mnet_reached_users($name,$chan)]} {
  1167. if {[info exists mnet_reached_chans($name,$chan)]} {
  1168. append status_message "Your last message reached $mnet_reached_users($name,$chan) unique users in $mnet_reached_chans($name,$chan) channels. "
  1169. }
  1170. }
  1171. ::putils::put_local_msg $chan "$status_message"
  1172. }
  1173. # checks timers of channels ... if not found, then ok with "0" secs left.. if found then return $secsleft
  1174. proc ::cims::check_spam_protection {prefix chan} {
  1175. variable mnet_delay
  1176. # validating incoming vars
  1177. set chan [::cims::proper_channelname $chan]
  1178. # check for pending timers.. spam-protection
  1179. set timerlist [utimers]
  1180. set secondsLeft 0
  1181. if {![info exists mnet_delay($prefix,$chan)]} {
  1182. set mnet_delay($prefix,$chan) 0
  1183. } else {
  1184. foreach {timerinfo} $timerlist {
  1185. set secsleft [join [lindex $timerinfo 0]]
  1186. set timer_id [join [lindex $timerinfo 2]]
  1187. # putlog "sec: $secsleft tid: $timer_id"
  1188. # putlog "checking timer ($timer_id) against mdelay-id: $mnet_delay($prefix,$chan)"
  1189. if {$timer_id == $mnet_delay($prefix,$chan)} {
  1190. return $secsleft
  1191. }
  1192. }
  1193. }
  1194. return 0
  1195. }
  1196. proc ::cims::message_to_own_channels {network freqname chan nick text} {
  1197. variable mnet_channels
  1198. variable mnet_freqs_onoff
  1199. variable mnet_reached_users
  1200. variable mnet_reached_userlist
  1201. variable mnet_reached_chans
  1202. global botnet-nick
  1203. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  1204. # putlog "{botnet-nick} huar: $proper_botnick"
  1205. foreach _ownchan $mnet_channels($network,$proper_botnick) {
  1206. if {$_ownchan == $chan} {
  1207. } else {
  1208. # if not own channel! ...
  1209. if {[::cims::botonchannel $_ownchan] == "1"} {
  1210. putlog "::cims:: = i am on $_ownchan"
  1211. # second enable/disable check
  1212. if {$mnet_freqs_onoff($freqname,$_ownchan) == 1} {
  1213. # userstats local
  1214. set mnet_reached_users($freqname,$chan) [::cims::chanstat_users $_ownchan $mnet_reached_users($freqname,$chan)]
  1215. set mnet_reached_userlist($freqname,$chan) [::cims::chanstat_userlist $_ownchan $mnet_reached_userlist($freqname,$chan)]
  1216. putlog "::cims:: * Localcounting up $_ownchan users: $mnet_reached_users($freqname,$chan)"
  1217. # channel count local
  1218. incr mnet_reached_chans($freqname,$chan)
  1219. ::cims::put_local_netmessage $network $freqname $_ownchan $nick $chan $text
  1220. } else {
  1221. putlog "::cims:: + $_ownchan has disabled $freqname output"
  1222. }
  1223. } else {
  1224. putlog "::cims:: + Can't send a local message to '$_ownchan' since I am not there."
  1225. }
  1226. }
  1227. }
  1228. }
  1229. proc ::cims::message_to_netbots {network freqname chan nick text} {
  1230. variable mnet_bots
  1231. global botnet-nick
  1232. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  1233. # putlog "{botnet-nick} huar: $proper_botnick"
  1234. foreach _botnick $mnet_bots($network) {
  1235. if {$_botnick == $proper_botnick} {
  1236. } else { # if not myself!
  1237. putlog "::cims:: send: + I am about to send a message to $_botnick for $network: $freqname: $text"
  1238. # safe put_bot function..
  1239. set data "mnet_receive"
  1240. lappend data $network $freqname $nick $chan $text
  1241. putlog "data: $data"
  1242. ::cims::put_bot $_botnick $data
  1243. }
  1244. }
  1245. }
  1246. proc ::cims::message_from_local {network freqname source nick text} {
  1247. variable mnet_reached_users
  1248. variable mnet_reached_userlist
  1249. variable mnet_reached_chans
  1250. # reset stats .. because he is just freshly sending
  1251. set mnet_reached_users($freqname,$source) "0"
  1252. set mnet_reached_userlist($freqname,$source) ""
  1253. set mnet_reached_chans($freqname,$source) "0"
  1254. ::cims::history_queue $network,$freqname $nick $source $text
  1255. # send them first, we await a reply!
  1256. # single sends TO ALL REMOTE BOTS with their remote CHANNELS...
  1257. # let's see which mode for sending is used...
  1258. ::cims::message_to_netbots $network $freqname $source $nick $text
  1259. # SEND TO ALL OWN CHANNELS...
  1260. # send to all own channels, except to the channel the message originating from:
  1261. ::cims::message_to_own_channels $network $freqname $source $nick $text
  1262. # plugin sending... if you want it to do other stuff as well.
  1263. if {[info procs ::cims::message_from_local_plugin] == "::cims::message_from_local_plugin"} {
  1264. ::cims::message_from_local_plugin $network $freqname $source $nick $text
  1265. }
  1266. # notice: better would be to go into the "reply" when all known bots already answered..
  1267. # then, if a bot is missing, but it was a known bot, just use a timeout with about 5-10 seconds..
  1268. # if the bot still didn't answer, then just go into "reply".
  1269. }
  1270. proc ::cims::messaging_public_from_bind {nick mask hand chan text} {
  1271. # proc triggered by specified $prefix and calling the following (internal) one
  1272. variable mnet
  1273. variable mnet_networks_by_prefix
  1274. variable mnet_colors
  1275. variable mnet_freqs
  1276. variable mnet_delay
  1277. variable mnet_histories
  1278. global botnet-nick lastbind
  1279. # validating incoming vars
  1280. set chan [::cims::proper_channelname $chan]
  1281. set prefix $lastbind
  1282. # $mnet_networks_by_prefix($prefix) is already a list! Don't split it! But work with lindex and lrange on it! later: JOIN it to a string.
  1283. set my_network_entry $mnet_networks_by_prefix($prefix)
  1284. set network [join [lindex $my_network_entry 0]]
  1285. set freqname [join [lindex $my_network_entry 1]]
  1286. set help [join [lindex $my_network_entry 2]]
  1287. set desc [join [lindex $my_network_entry 3]]
  1288. set delay [join [lindex $my_network_entry 4]]
  1289. set allowed [::cims::allowed_channel $network $freqname $prefix $nick $mask $chan]
  1290. if {$allowed == 0} {
  1291. return 0
  1292. }
  1293. # now generally allowed.
  1294. # is user banned from sending??
  1295. set user_allowed [::cims::allowed_user $network $freqname $prefix $nick $mask $chan]
  1296. if {$user_allowed == 0} {
  1297. return 0
  1298. }
  1299. # user has not been matched against banlist. So he's allowed here.
  1300. # cleaning given strings...
  1301. set text [::cims::clean_txt $text]
  1302. # check here if we have some text or not.. :)
  1303. if {$text == "" || $text == "{}"} {
  1304. # output some help:
  1305. putlog "::cims:: = gave him some help"
  1306. ::putils::put_local_msg $chan $help
  1307. } else {
  1308. # ok, now send! (if timer allows it)
  1309. ### spamprotection
  1310. # returns the seconds that are left for this channel .. or 0 if no seconds left.
  1311. set secsleft [::cims::check_spam_protection $prefix $chan]
  1312. if {$secsleft > 0} {
  1313. putlog "::cims:: The timer of $prefix for $chan is still running. The guy has to wait ($secsleft/$delay) more seconds. I tell him."
  1314. ::putils::put_nick $nick "Sorry $nick, usage of $prefix only every $delay seconds. $secsleft seconds for $chan remaining."
  1315. # now BREAK "messaging_public_from_bind".
  1316. # NO break.. for debug :)) arf
  1317. return 0
  1318. }
  1319. # if we went through the timer check ... so it doesn't exist anymore then we set a new one:
  1320. # set a timer-id to check for again, if it's allowed or not .. delay
  1321. set mnet_delay($prefix,$chan) [utimer $delay ::cims::dummy]
  1322. ### end spamprotection
  1323. ## HE IS SENDING NOW!
  1324. ::cims::message_from_local $network $freqname $chan $nick $text
  1325. # wait here some more! (10 seconds with utimer) - to send out a reply to the channel
  1326. utimer 10 "::cims::timeout_reply_from_local_for_netbots $freqname $chan"
  1327. }
  1328. }
  1329. ### END public reachable commands
  1330. proc ::cims::binds {} {
  1331. variable currentNetworkDesc
  1332. variable currentNetworkSig
  1333. variable startNetworkInstance
  1334. variable currentBot
  1335. variable currentOwner
  1336. variable startBotInstance
  1337. variable mnet_networks
  1338. variable mnet_freqs
  1339. variable mnet_networks_by_prefix
  1340. variable mnet_channels
  1341. variable mnet_freqs_onoff
  1342. variable mnet_colors_onoff
  1343. global botnet-nick
  1344. set proper_botnick [::cims::proper_botnick ${botnet-nick}]
  1345. # binding of irc commands ... only works well if a config was loaded..
  1346. foreach {network desc} $mnet_networks {
  1347. # putlog "test: network is $network"
  1348. # putlog "test: networkdesc is $desc"
  1349. foreach {network name prefix help desc msgdelay} $mnet_freqs($network) {
  1350. putlog "network: $network"
  1351. putlog "freqname: $name"
  1352. putlog "prefix: $prefix"
  1353. putlog "help: $help"
  1354. putlog "desc: $desc"
  1355. putlog "msgdelay: $msgdelay"
  1356. set mnet_networks_by_prefix($prefix) "{$network} {$name} {$help} {$desc} {$msgdelay}"
  1357. # setting variables on init.
  1358. foreach {channel} $mnet_channels($network,$proper_botnick) {
  1359. # catch like php isset() - but catch returns 0 if OK!
  1360. set channel [::cims::proper_channelname $channel]
  1361. if {[catch {set mnet_freqs_onoff($name,$channel)}] == 1} {
  1362. set mnet_freqs_onoff($name,$channel) 1
  1363. putlog "::cims:: initially enabling $name for channel: $channel"
  1364. } else {
  1365. putlog "::cims:: $name for $channel is already on output: $mnet_freqs_onoff($name,$channel)"
  1366. }
  1367. # catch like php isset() - but catch returns 0 if OK!
  1368. if {[catch {set mnet_colors_onoff($name,$channel)}] == 1} {
  1369. set mnet_colors_onoff($name,$channel) 0
  1370. putlog "::cims:: initially disabling colors for $name for channel (if not forced): $channel"
  1371. } else {
  1372. putlog "::cims:: coloroutput of $name for $channel is already on (if not forced): $mnet_colors_onoff($name,$channel)"
  1373. }
  1374. }
  1375. bind pub - ${prefix} ::cims::messaging_public_from_bind
  1376. # $network $name $prefix $help $desc
  1377. bind pub - ${prefix}_enable ::cims::enable_frequency
  1378. bind pub - ${prefix}_disable ::cims::disable_frequency
  1379. bind pub - ${prefix}_toggle ::cims::toggle_frequency
  1380. bind pub - ${prefix}_enable_colors ::cims::enable_color
  1381. bind pub - ${prefix}_disable_colors ::cims::disable_color
  1382. bind pub - ${prefix}_toggle_colors ::cims::toggle_color
  1383. # with typos..
  1384. bind pub - ${prefix}_enable_color ::cims::enable_color
  1385. bind pub - ${prefix}_disable_color ::cims::disable_color
  1386. bind pub - ${prefix}_toggle_color ::cims::toggle_color
  1387. bind pub - ${prefix}_history ::cims::history_frequency
  1388. bind pub - ${prefix}_status ::cims::status_frequency
  1389. bind pub - .mnet_status ::cims::dummy
  1390. # FIXME: make some more commands available to have control over the messages
  1391. # - "_stats"?
  1392. }
  1393. }
  1394. }
  1395. bind bot - mnet_receive ::cims::receive_message
  1396. bind bot - mnet_answer ::cims::receive_answer
  1397. bind dcc m cims_reload ::cims::dcc_configload
  1398. proc ::cims::conf_parsing {} {
  1399. variable mnet_config
  1400. variable mnet_num_configs
  1401. set parser [xml::parser \
  1402. -elementstartcommand ::cims::xmlElementStart \
  1403. -elementendcommand ::cims::xmlElementEnd \
  1404. -defaultcommand ::cims::xmlDefaultCmd \
  1405. -characterdatacommand ::cims::xmlCdata \
  1406. ]
  1407. # -errorcommand xmlHandleError
  1408. for {set y 1} {$y <= $mnet_num_configs} {incr y} {
  1409. set configfile $mnet_config($y)
  1410. # putlog "HRM?: $configfile"
  1411. $parser parse "$configfile"
  1412. }
  1413. }
  1414. proc ::cims::dcc_configload {dummy1 dummy2 dummy3} {
  1415. # wrapper command for ::cims::netconfigload
  1416. putlog "::cims:: = reloading configs..."
  1417. ::cims::clean_netconfig
  1418. ::cims::netconfigload
  1419. }
  1420. proc ::cims::netconfigload {} {
  1421. variable mnet_http_config
  1422. variable mnet_local_config
  1423. variable mnet_config
  1424. variable mnet_num_configs
  1425. putlog "debug:: $mnet_http_config"
  1426. # possible methods to load a config are: get_httpfile and get_localfile
  1427. # get_httpfile
  1428. # get_localfile RELATIVE_PATH_AND_FILE
  1429. set x 0
  1430. if {[info exists mnet_http_config]} {
  1431. foreach {host httpfile port} $mnet_http_config {
  1432. # FIXME config validating.. is the file received correctly? or do
  1433. # we only have a 404 error message there? ... bad thing still.
  1434. incr x
  1435. set mnet_config($x) [get_httpfile $host $httpfile $port]
  1436. }
  1437. }
  1438. if {[info exists mnet_local_config]} {
  1439. foreach {localfile} $mnet_local_config {
  1440. # FIXME config validating.. could we open the file?
  1441. # is the file a correct config?
  1442. incr x
  1443. set mnet_config($x) [get_localfile $localfile]
  1444. }
  1445. }
  1446. # $x is now at its highest count.
  1447. set mnet_num_configs $x
  1448. if {$x > 0} {
  1449. utimer 5 ::cims::conf_parsing
  1450. utimer 10 ::cims::binds
  1451. } else {
  1452. putlog "::cims:: no configurations loaded."
  1453. }
  1454. }
  1455. # looping this one
  1456. proc ::cims::interval_conf {} {
  1457. variable mnet_cfg_reload_interval
  1458. variable mnet_configtimer_set
  1459. variable mnet_netconfig_timer
  1460. # putlog "::cims:: interval conf! $mnet_configtimer_set huh?"
  1461. if {$mnet_configtimer_set == 1} {
  1462. putlog "::cims:: starting intervalled configload ($mnet_cfg_reload_interval minutes)"
  1463. ::cims::clean_netconfig
  1464. ::cims::netconfigload
  1465. set mnet_netconfig_timer [timer $mnet_cfg_reload_interval ::cims::interval_conf]
  1466. } else {
  1467. putlog "::cims:: was about to make a automatic configload again, but it has been disabled recently."
  1468. }
  1469. }
  1470. namespace eval ::cims {
  1471. ############# CONFIG SECTION ##############
  1472. ### the real config section is supposed to be here...
  1473. if {[info exists configs_file]} {
  1474. if {[file isfile "$configs_file"] == 1} {
  1475. source $configs_file
  1476. putlog "::cims:: configs file '$configs_file' loaded."
  1477. }
  1478. }
  1479. ############# CONFIG SHOULD NOW BE LOADED ONTO THE MANY VARIABLES ##############
  1480. # pls hands away again: starting up just defined configs ...
  1481. putlog "::cims:: = Messaging Network ($mnet(version)) loaded"
  1482. putlog "::cims:: = as master, reload current net-configs with .cims_reload"
  1483. putlog "::cims:: = do .rehash and .cims_reload if you defined a new net-config."
  1484. if {$mnet_cfg_reload_interval >= 90} {
  1485. if {![info exists mnet_netconfig_timer]} {
  1486. set mnet_configtimer_set 1
  1487. ::cims::interval_conf
  1488. # this one loops
  1489. }
  1490. } else {
  1491. if {[info exists mnet_netconfig_timer]} {
  1492. set mnet_configtimer_set 0
  1493. killtimer $mnet_netconfig_timer
  1494. unset mnet_netconfig_timer
  1495. }
  1496. set mnet_cfg_reload_interval 0
  1497. ::cims::clean_netconfig
  1498. ::cims::netconfigload
  1499. }
  1500. }