Browse Source

added periodic settings saving and startup settings loading for currently loaded networks

Paul-Dieter Klumpp 3 years ago
parent
commit
07a6806557
1 changed files with 40 additions and 2 deletions
  1. 40 2
      cims_admin.tcl

+ 40 - 2
cims_admin.tcl

@@ -184,6 +184,22 @@ proc ::cims::admin::has_channelrecord {chan} {
 	
 }
 
+
+proc ::cims::admin::trylink_admin {} {
+  global botnet-nick 
+
+  set proper_botnick [::putils::proper_botnick ${botnet-nick}]
+  set botslist [userlist b]
+
+	foreach _try_bot $botslist {
+		if {[islinked ${_try_bot}] == 0} {
+			link ${_try_bot}
+		}
+	} 
+
+	return 0
+}
+
 proc ::cims::admin::trylink {nick mask hand chan text} {
   variable admin_channels 
   global botnet-nick 
@@ -224,6 +240,14 @@ proc ::cims::admin::trylink_test {_try_bot nick} {
   }
 }
 
+proc ::cims::admin::savesettings_admin {} {
+  global botnet-nick botnick
+  namespace eval ::cims {
+    set proper_botnick [::putils::proper_botnick ${botnet-nick}]
+    ::putils::write_f_array "scripts/cims/save/${proper_botnick}_freqs" [array get mnet_freqs_onoff]
+    ::putils::write_f_array "scripts/cims/save/${proper_botnick}_colors" [array get mnet_colors_onoff]
+  }
+}
 
 proc ::cims::admin::savesettings {nick mask hand chan text} {
   variable admin_channels 
@@ -245,6 +269,14 @@ proc ::cims::admin::savesettings {nick mask hand chan text} {
   }
 }
 
+proc ::cims::admin::loadsettings_admin {} {
+  global botnet-nick botnick
+  namespace eval ::cims {
+    set proper_botnick [::putils::proper_botnick ${botnet-nick}]
+    array set mnet_freqs_onoff [::putils::read_f_array "scripts/cims/save/${proper_botnick}_freqs"]
+    array set mnet_colors_onoff [::putils::read_f_array "scripts/cims/save/${proper_botnick}_colors"]
+  }
+}
 
 proc ::cims::admin::loadsettings {nick mask hand chan text} {
   variable admin_channels 
@@ -403,7 +435,7 @@ proc ::cims::admin::main {nick mask hand chan text} {
 }
 
 
-proc ::cims::admin::bindings {} {
+proc ::cims::admin::startup {} {
   variable mnet_admin_version
   global botnet-nick
 
@@ -418,13 +450,19 @@ proc ::cims::admin::bindings {} {
   bind pub - !mnet_savesettings      ::cims::admin::savesettings
   bind pub - !mnet_loadsettings      ::cims::admin::loadsettings
   
+  ::cims::admin::loadsettings_admin
+
+  utimer 10 "::cims::admin::trylink_admin"
+  timer 1405 "::cims::admin::trylink_admin" 0
+  timer 1205 "::cims::admin::savesettings_admin" 0
 
   putlog "mnet! = mnet adminscript loaded: $mnet_admin_version"
 }
 
 namespace eval ::cims::admin {
+
   # timer weil $botnet-nick nicht sofort von eggdrop gesetzt wird
-  utimer 3 "::cims::admin::bindings"
+  utimer 3 "::cims::admin::startup"
 }