Procházet zdrojové kódy

mnet_admin now works correctly.. it seems. pls test a bit

Paul Klumpp před 13 roky
rodič
revize
6952600bb3
4 změnil soubory, kde provedl 189 přidání a 153 odebrání
  1. 30 48
      cims.tcl
  2. 110 79
      mnet_admin.tcl
  3. 34 17
      putils.tcl
  4. 15 9
      qs_net.tcl

+ 30 - 48
cims.tcl

@@ -49,7 +49,10 @@ namespace eval ::cims {
   # tclxml needs uri of tcllib.. at least 1.1 i think
   package require uri
 
-
+  # include my/our little eggdrop utilities and helper library. ;-) Putils!
+  if {[file isfile "scripts/cims/putils.tcl"] == 1} {
+    source "scripts/cims/putils.tcl"
+  }
 
   ############ XML CONFIGURATION PARSING FOLLOWS!! WTF! :) #########
   variable mnet_networks
@@ -417,7 +420,7 @@ proc ::cims::xmlDefaultCmd {data} {
 
 namespace eval ::cims {
   ## some internal variables for messaging and stuff :) not your business after all.
-  set mnet(version) "mnet 1.012namespaced"
+  set mnet(version) "mnet 1.013putils"
 
   set mnet_max_history 8
 
@@ -503,15 +506,6 @@ proc ::cims::put_local_netmessage {network name chan rec_nickname rec_channel re
 }
 
 
-proc ::cims::put_local_msg {chan text} {
-  variable mnet_colors 
-  variable mnet_freqs_onoff
-
-	putserv "PRIVMSG $chan :$text"
-	putlog "::cims:: + normal message: ${chan} => '$text'"
-
-}
-
 
 proc get_httpfile {host file port} {
 	global botnet-nick
@@ -563,10 +557,6 @@ proc get_localfile {file} {
 }
 
 
-proc ::cims::put_nick {nick msg} { 
-	putserv "NOTICE $nick :$msg" 
-}
-
 
 proc ::cims::dummy {} {
 	return 0
@@ -666,16 +656,16 @@ proc ::cims::receive_message {rec_botnick cmd rec_data} {
 	#putlog "tmp_net: '$tmp_network'"
 	#putlog "tmp_nam: '$tmp_name'"
 	
-	set network [::cims::kill_spaces $tmp_network]
+	set network [::putils::kill_spaces $tmp_network]
 	#putlog  "network: '$network'"
 	
-	set name  [::cims::kill_spaces $tmp_name]
+	set name  [::putils::kill_spaces $tmp_name]
 	#putlog  "name: '$name'"
 	
-	set rec_nickname [::cims::kill_spaces [join [lindex $rec_data 2]]]
-	#set rec_nickname [::cims::kill_spaces clean_txt [join [lrange [split $rec_data] 4 end]]]
+	set rec_nickname [::putils::kill_spaces [join [lindex $rec_data 2]]]
+	#set rec_nickname [::putils::kill_spaces clean_txt [join [lrange [split $rec_data] 4 end]]]
 
-	set rec_channel  [::cims::kill_spaces [join [lindex $rec_data 3]]]
+	set rec_channel  [::putils::kill_spaces [join [lindex $rec_data 3]]]
 
 	#set rec_text [::cims::clean_txt [join [lrange [split $rec_data] 4 end]]]
 
@@ -758,15 +748,7 @@ proc ::cims::receive_answer {rec_botnick cmd rec_data} {
 	
 }
 
-proc ::cims::clean_braces {text} {
-	regsub -all "{" $text "" text
-	regsub -all "}" $text "" text
-	return $text
-}
-proc ::cims::kill_spaces {text} {
-	regsub -all "\\s+" $text "" text 
-	return $text
-}
+
 proc ::cims::clean_txt {text} {
 
 #	putlog "filter_A: ${text}"
@@ -863,7 +845,7 @@ proc ::cims::allowed_channel {network name prefix nick mask chan} {
 
 	if {![isop $nick $chan]} {
 		putlog "::cims:: = allowed in $chan, but $nick is no op"
-		::cims::put_nick $nick "Sorry $nick, you need to be op."
+		::putils::put_nick $nick "Sorry $nick, you need to be op."
 		return 0
 	}
 	if {$nick == $botnick} {
@@ -908,7 +890,7 @@ proc ::cims::allowed_user {network name prefix nick mask chan} {
 		}
 		if {$found == 1} {
 			# tell the user his ban. :)
-			::cims::put_nick $nick "::cims:: Not allowed to send messages. Reason: $reason"
+			::putils::put_nick $nick "::cims:: Not allowed to send messages. Reason: $reason"
 			return 0
 		}
 	}
@@ -963,8 +945,8 @@ proc ::cims::reply_timeout {name chan} {
   variable mnet_reached_chans
 	
 	# clean $name and $chan
-	set name [::cims::kill_spaces $name]
-	set chan [::cims::kill_spaces $chan]
+	set name [::putils::kill_spaces $name]
+	set chan [::putils::kill_spaces $chan]
 	
 	# easify variables
 	set users $mnet_reached_users($name,$chan)
@@ -977,7 +959,7 @@ proc ::cims::reply_timeout {name chan} {
 	putlog "::cims:: * After ALL: Count_Users: $mnet_reached_users($name,$chan) Count_Channels: $mnet_reached_chans($name,$chan)"
 	
 	# Give me some reply.
-	::cims::put_local_msg ${chan} "::cims:: Message sent to $users users in $chans channels."
+	::putils::put_local_msg ${chan} "::cims:: Message sent to $users users in $chans channels."
 }
 
 
@@ -1020,7 +1002,7 @@ proc ::cims::history_frequency {nick mask hand chan text} {
 		set list_length [llength $mnet_histories($network,$name)]
 		if {$list_length >= 1} {
 			set msg "::cims:: last $mnet_max_history messages of $network $name:"
-			::cims::put_nick $nick $msg
+			::putils::put_nick $nick $msg
 
 		
 			set x_count 0
@@ -1028,12 +1010,12 @@ proc ::cims::history_frequency {nick mask hand chan text} {
 				incr x_count
 				set backwards_x [expr $list_length - $x_count]
 				set msg [lindex $mnet_histories($network,$name) $backwards_x]
-				::cims::put_nick $nick "($x_count/$list_length) $msg"
+				::putils::put_nick $nick "($x_count/$list_length) $msg"
 		
 			}
 		} 
 	} else {
-		::cims::put_nick $nick "::cims:: no accumulated history for $network $name"
+		::putils::put_nick $nick "::cims:: no accumulated history for $network $name"
 	}
 }
 
@@ -1075,7 +1057,7 @@ proc ::cims::enable_frequency {nick mask hand chan text} {
 	set mnet_freqs_onoff($name,$chan) 1
 	putlog "mnet_freq_status: now $mnet_freqs_onoff($name,$chan)"
 	
-	::cims::put_local_msg $chan "::cims:: $name _output_ enabled for $chan"
+	::putils::put_local_msg $chan "::cims:: $name _output_ enabled for $chan"
 	
 }
 
@@ -1116,7 +1098,7 @@ proc ::cims::disable_frequency {nick mask hand chan text} {
 	set mnet_freqs_onoff($name,$chan) 0
 	putlog "mnet_freq_status: now $mnet_freqs_onoff($name,$chan)"
 	
-	::cims::put_local_msg $chan "::cims:: $name _output_ disabled for $chan"
+	::putils::put_local_msg $chan "::cims:: $name _output_ disabled for $chan"
 	
 }
 
@@ -1153,10 +1135,10 @@ proc ::cims::toggle_frequency {nick mask hand chan text} {
 	putlog "mnet_freq_status: toggle $mnet_freqs_onoff($name,$chan)"
 	if {$mnet_freqs_onoff($name,$chan) == 1} {
 		set mnet_freqs_onoff($name,$chan) 0
-		::cims::put_local_msg $chan "::cims:: toggling ${name} _output_, now disabled for ${chan}"
+		::putils::put_local_msg $chan "::cims:: toggling ${name} _output_, now disabled for ${chan}"
 	} else {
 		set mnet_freqs_onoff($name,$chan) 1
-		::cims::put_local_msg $chan "::cims:: toggling ${name} _output_, now enabled for ${chan}"
+		::putils::put_local_msg $chan "::cims:: toggling ${name} _output_, now enabled for ${chan}"
 	}
 	putlog "mnet_freq_status: toggle now $mnet_freqs_onoff($name,$chan)"
 	
@@ -1199,7 +1181,7 @@ proc ::cims::enable_color {nick mask hand chan text} {
 	set mnet_colors_onoff($name,$chan) 1
 	putlog "mnet_color_status: now $mnet_colors_onoff($name,$chan)"
 	
-	::cims::put_local_msg $chan "::cims:: $name _coloroutput_ enabled for $chan"
+	::putils::put_local_msg $chan "::cims:: $name _coloroutput_ enabled for $chan"
 }
 
 #::cims::disable_color
@@ -1241,7 +1223,7 @@ proc ::cims::disable_color {nick mask hand chan text} {
 	set mnet_colors_onoff($name,$chan) 0
 	putlog "mnet_color_status: now $mnet_colors_onoff($name,$chan)"
 	
-	::cims::put_local_msg $chan "::cims:: $name _coloroutput_ disabled for $chan"
+	::putils::put_local_msg $chan "::cims:: $name _coloroutput_ disabled for $chan"
 }
 
 
@@ -1285,10 +1267,10 @@ proc ::cims::toggle_color {nick mask hand chan text} {
 	putlog "mnet_color_status: toggle $mnet_colors_onoff($name,$chan)"
 	if {$mnet_colors_onoff($name,$chan) == 1} {
 		set mnet_colors_onoff($name,$chan) 0
-		::cims::put_local_msg $chan "::cims:: toggling ${name} _coloroutput_, now disabled for ${chan}"
+		::putils::put_local_msg $chan "::cims:: toggling ${name} _coloroutput_, now disabled for ${chan}"
 	} else {
 		set mnet_colors_onoff($name,$chan) 1
-		::cims::put_local_msg $chan "::cims:: toggling ${name} _coloroutput_, now enabled for ${chan}"
+		::putils::put_local_msg $chan "::cims:: toggling ${name} _coloroutput_, now enabled for ${chan}"
 	}
 	putlog "mnet_color_status: toggle now $mnet_colors_onoff($name,$chan)"
 	
@@ -1355,7 +1337,7 @@ proc ::cims::status_frequency {nick mask hand chan text} {
 	}
 
 	
-	::cims::put_local_msg $chan "$status_message"
+	::putils::put_local_msg $chan "$status_message"
 
 
 }
@@ -1444,7 +1426,7 @@ proc ::cims::messaging_public {nick mask hand chan text} {
 	
 		# output some help:
 		putlog  "::cims:: = gave him some help"
-		::cims::put_local_msg $chan $help
+		::putils::put_local_msg $chan $help
 
 	} else {
 		# ok, now send! (if timer allows it)
@@ -1454,7 +1436,7 @@ proc ::cims::messaging_public {nick mask hand chan text} {
 		set secsleft [::cims::check_spam_protection $prefix $chan]
 		if {$secsleft > 0} { 
 			putlog "::cims:: The timer of $prefix for $chan is still running. The guy has to wait ($secsleft/$delay) more seconds. I tell him."
-			::cims::put_nick $nick "Sorry $nick, usage of $prefix only every $delay seconds. $secsleft seconds for $chan remaining."
+			::putils::put_nick $nick "Sorry $nick, usage of $prefix only every $delay seconds. $secsleft seconds for $chan remaining."
 			# now BREAK "messaging_public".
 			# NO break.. for debug :)) arf
 			return 0

+ 110 - 79
mnet_admin.tcl

@@ -1,4 +1,5 @@
-# MNET (Message Network) - Networked Broadcasting of Messages over IRC for Communities
+# CIMS: Community IRC Messaging Service
+# CIMS formerly known as MNET (Message Network)
 # Administration Script
 # Copyright (C) 2004 Paul-Dieter Klumpp
 #
@@ -16,14 +17,22 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
+namespace eval ::cims::admin {
+  variable admin_channels {"#messagenet" "#quad.dev" "#qwnet"}
+  variable mnet_admin_version "Mnet!1.013namespaced"
+
+  # include my/our little eggdrop utilities and helper library. ;-) Putils!
+  if {[file isfile "scripts/cims/putils.tcl"] == 1} {
+    source "scripts/cims/putils.tcl"
+  }
+
+}
 
-set admin_channels {"#messagenet" "#quad.dev" "#qwnet"}
-set mnet_admin_version "Mnet!1.012trylink"
 
 
 # allowcheck for admin commands..
-proc mnet:admin_allowed_channel {nick mask hand chan admin_channels} {
-	global botnick botnet-nick lastbind 
+proc ::cims::admin::allowed_channel {nick mask hand chan admin_channels} {
+  global botnick botnet-nick lastbind 
 
 
 	putlog "mnet! = an admin command triggered triggered by $nick ($mask) in $chan"
@@ -32,7 +41,7 @@ proc mnet:admin_allowed_channel {nick mask hand chan admin_channels} {
 	
 	putlog "mnet! = trying if $chan is an admin-channel"
 	set found 0
-	set proper_botnick [mnet:proper_botnick ${botnet-nick}]
+	set proper_botnick [::putils::proper_botnick ${botnet-nick}]
 	foreach _try_chan $admin_channels {
 		if {[string compare -nocase ${chan} ${_try_chan}] == 0} {
 			putlog "mnet! = channel: ${chan} is allowed to administrate mnet on this bot"
@@ -48,7 +57,7 @@ proc mnet:admin_allowed_channel {nick mask hand chan admin_channels} {
 	 
 	if {![isop ${nick} ${chan}]} {
 		putlog "mnet! = allowed in ${chan}, but $nick is no op"
-		mnet:put_nick ${nick} "Sorry $nick, you are not an administrator here."
+		::putils::put_nick ${nick} "Sorry $nick, you are not an administrator here."
 		return 0
 	}
 	if {${nick} == ${botnick}} {
@@ -61,53 +70,58 @@ proc mnet:admin_allowed_channel {nick mask hand chan admin_channels} {
 	return 1
 }
 
-proc mnet:admin_check_addchannel {nick channel} {
+proc ::cims::admin::check_addchannel {nick channel} {
 
 	if {[botonchan ${channel}] == 1} {
-		mnet:put_nick ${nick} "Mnet! I added myself to the channel ${channel}"
+		::putils::put_nick ${nick} "Mnet! I added myself to the channel ${channel}"
 		putlog "Mnet! I added myself to the channel ${channel}"
 	} else {
-		mnet:put_nick ${nick} "Mnet! I tried to add myself to the channel ${value} - but failed! Pls check."
+		::putils::put_nick ${nick} "Mnet! I tried to add myself to the channel ${value} - but failed! Pls check."
 		putlog "Mnet! I tried to add myself to the channel ${value} - but failed! Pls check."
 	}
 }
 
-proc mnet:admin_rehash {nick mask hand chan text} {
-	global admin_channels botnet-nick
+proc ::cims::admin::rehash {nick mask hand chan text} {
+  variable admin_channels 
+  global botnet-nick
 	
-	set proper_botnick [mnet:proper_botnick ${botnet-nick}]
+	set proper_botnick [::putils::proper_botnick ${botnet-nick}]
 	
-	set allowed [mnet:admin_allowed_channel $nick $mask $hand $chan $admin_channels]
+	set allowed [::cims::admin::allowed_channel $nick $mask $hand $chan $admin_channels]
 	if {$allowed == 0} {
 		return 0
 	}
 	
 	# rehash the bot... be sure the scripts are coded correctly!! or the bot will DIE!
 	rehash
-	mnet:put_nick ${nick} "Mnet! \"${proper_botnick}\" has rehashed and thus reloaded the mnet.tcl"
+	::putils::put_nick ${nick} "Mnet! \"${proper_botnick}\" has rehashed and thus reloaded the mnet.tcl"
 
 }
 
-proc mnet:admin_version {nick mask hand chan text} {
-	global admin_channels botnet-nick mnet_admin_version mnet
+proc ::cims::admin::version {nick mask hand chan text} {
+  variable admin_channels 
+  variable mnet_admin_version 
+  
+  global botnet-nick 
 	
-	set proper_botnick [mnet:proper_botnick ${botnet-nick}]
+	set proper_botnick [::putils::proper_botnick ${botnet-nick}]
 	
-	set allowed [mnet:admin_allowed_channel $nick $mask $hand $chan $admin_channels]
+	set allowed [::cims::admin::allowed_channel $nick $mask $hand $chan $admin_channels]
 	if {$allowed == 0} {
 		return 0
 	}
 	
 	# tells version
-	mnet:put_nick ${nick} "Mnet! \"${proper_botnick}\" Admin: $mnet_admin_version and Mnet is: $mnet(version)"
+	::putils::put_nick ${nick} "Mnet! \"${proper_botnick}\" Admin: $mnet_admin_version and Mnet is: $::cims::mnet(version)"
 }
 
-proc mnet:admin_channelinfo {nick mask hand chan text} {
-	global admin_channels botnet-nick
+proc ::cims::admin::channelinfo {nick mask hand chan text} {
+  variable admin_channels 
+  global botnet-nick
 	
-	set proper_botnick [mnet:proper_botnick ${botnet-nick}]
+	set proper_botnick [::putils::proper_botnick ${botnet-nick}]
 
-	set allowed [mnet:admin_allowed_channel $nick $mask $hand $chan $admin_channels]
+	set allowed [::cims::admin::allowed_channel $nick $mask $hand $chan $admin_channels]
 	if {$allowed == 0} {
 		return 0
 	}
@@ -135,10 +149,10 @@ proc mnet:admin_channelinfo {nick mask hand chan text} {
 		}
  	}
 	
-	mnet:put_nick ${nick} "Mnet! \"${proper_botnick}\" has  \002${chan_count}\002  channels: ${output}"
+	::putils::put_nick ${nick} "Mnet! \"${proper_botnick}\" has  \002${chan_count}\002  channels: ${output}"
 }
 
-proc mnet:admin_have_channelrecord {chan} {
+proc ::cims::admin::has_channelrecord {chan} {
 	
 	set channel_records [channels]
 	foreach _try_chan $channel_records {
@@ -155,46 +169,54 @@ proc mnet:admin_have_channelrecord {chan} {
 	
 }
 
-proc mnet:admin_trylink {nick mask hand chan text} {
-	global admin_channels botnet-nick mnet_admin_version mnet
+proc ::cims::admin::trylink {nick mask hand chan text} {
+  variable admin_channels 
+  variable mnet_admin_version 
+  variable mnet
+  global botnet-nick 
 
-	set proper_botnick [mnet:proper_botnick ${botnet-nick}]
+	set proper_botnick [::putils::proper_botnick ${botnet-nick}]
 	set botslist [userlist b]
 
 	foreach _try_bot $botslist {
 		if {[islinked ${_try_bot}] == 0} {
 			set _try [link ${_try_bot}]
 			if {$_try == 1} {
-				mnet:put_nick ${nick} "Mnet! \"${proper_botnick}\" tries to link to \"${_try_bot}\""
-				utimer 5 "mnet:admin_trylink_test ${_try_bot} ${nick}"
+				::putils::put_nick ${nick} "Mnet! \"${proper_botnick}\" tries to link to \"${_try_bot}\""
+				utimer 5 "::cims::admin::trylink_test ${_try_bot} ${nick}"
 			}
 		} else {
-			mnet:put_nick ${nick} "Mnet! \"${proper_botnick}\" \00303already linked\003 to \"${_try_bot}\" - good."
+			::putils::put_nick ${nick} "Mnet! \"${proper_botnick}\" \00303already linked\003 to \"${_try_bot}\" - good."
 		}
 	} 
 
 	return 0
 }
 
-proc mnet:admin_trylink_test {_try_bot nick} {
-	global admin_channels botnet-nick mnet_admin_version mnet
+proc ::cims::admin::trylink_test {_try_bot nick} {
+  variable admin_channels 
+  variable mnet_admin_version 
+  variable mnet
+  global botnet-nick 
 
-	set proper_botnick [mnet:proper_botnick ${botnet-nick}]
+	set proper_botnick [::putils::proper_botnick ${botnet-nick}]
 
 	if {[islinked ${_try_bot}] == 1} {
-		mnet:put_nick ${nick} "Mnet! \"${proper_botnick}\" \00309succeeded\003 to link to \"${_try_bot}\"! :)"
+		::putils::put_nick ${nick} "Mnet! \"${proper_botnick}\" \00309succeeded\003 to link to \"${_try_bot}\"! :)"
 	} else {
-		mnet:put_nick ${nick} "Mnet! \"${proper_botnick}\" \00304FAILED\003 to link to \"${_try_bot}\"! :("
+		::putils::put_nick ${nick} "Mnet! \"${proper_botnick}\" \00304FAILED\003 to link to \"${_try_bot}\"! :("
 	}
 }
 
 
-proc mnet:admin_reload {nick mask hand chan text} {
-    global admin_channels botnet-nick
+proc ::cims::admin::reload {nick mask hand chan text} {
+  variable admin_channels 
+  global botnet-nick
 
-    set proper_botnick [mnet:proper_botnick ${botnet-nick}]
 
-    set allowed [mnet:admin_allowed_channel $nick $mask $hand $chan $admin_channels]
+    set proper_botnick [::putils::proper_botnick ${botnet-nick}]
+
+    set allowed [::cims::admin::allowed_channel $nick $mask $hand $chan $admin_channels]
     if {$allowed == 0} {
         return 0
     }
@@ -203,16 +225,19 @@ proc mnet:admin_reload {nick mask hand chan text} {
     # reload config... be sure this script works or the bot will DIE!
     putlog "mnet! = reloading configs by admin"
     mnet:dcc_configload ${cmd} ${cmd} ${cmd}
-    mnet:put_nick ${nick} "Mnet! \"${proper_botnick}\" Configs reload triggered."
+    ::putils::put_nick ${nick} "Mnet! \"${proper_botnick}\" Configs reload triggered."
 
 }
 
-proc mnet:admin {nick mask hand chan text} {
-	global admin_channels botnet-nick mnet_admin_version mnet
+proc ::cims::admin::main {nick mask hand chan text} {
+  variable admin_channels 
+  variable mnet_admin_version 
+  variable mnet
+  global botnet-nick 
 	
-	set proper_botnick [mnet:proper_botnick ${botnet-nick}]
+	set proper_botnick [::putils::proper_botnick ${botnet-nick}]
 
-	set allowed [mnet:admin_allowed_channel $nick $mask $hand $chan $admin_channels]
+	set allowed [::cims::admin::allowed_channel $nick $mask $hand $chan $admin_channels]
 	if {$allowed == 0} {
 		return 0
 	}
@@ -229,19 +254,19 @@ proc mnet:admin {nick mask hand chan text} {
 		# check $value ... if there
 		if {${value} != ""} {
 			# get channelrecord: ${value} if we don't have the record already:
-			if {[mnet:admin_have_channelrecord ${value}] == 0} {
+			if {[::cims::admin::has_channelrecord ${value}] == 0} {
 				channel add ${value}
 				# save it
 				savechannels
 				
 				# did it work?
-				utimer 10 "mnet:admin_check_addchannel ${nick} ${value}"
+				utimer 10 "::cims::admin::check_addchannel ${nick} ${value}"
 			} else {
-				mnet:put_nick ${nick} "Mnet! Can't add again - I already have the channel ${value}"
+				::putils::put_nick ${nick} "Mnet! Can't add again - I already have the channel ${value}"
 				putlog "Mnet! Can't add again - I already have the channel ${value}"
 			}
 		} else {
-			mnet:put_nick ${nick} "Mnet! Can't add: no channel given"
+			::putils::put_nick ${nick} "Mnet! Can't add: no channel given"
 		}
 
 		
@@ -252,18 +277,18 @@ proc mnet:admin {nick mask hand chan text} {
 		# check $value ... if there
 		if {${value} != ""} {
 			# remove ${value} from bot, if we have a record for it.
-			if {[mnet:admin_have_channelrecord ${value}] == 1} {
+			if {[::cims::admin::has_channelrecord ${value}] == 1} {
 				channel remove ${value}
 				savechannels
 				
-				mnet:put_nick ${nick} "Mnet! I removed the channelrecord: ${value}"
+				::putils::put_nick ${nick} "Mnet! I removed the channelrecord: ${value}"
 				putlog "Mnet! I removed the channelrecord: ${value}"
 			} else {
-				mnet:put_nick ${nick} "Mnet! Can't remove - I don't have that channelrecord: ${value}"
+				::putils::put_nick ${nick} "Mnet! Can't remove - I don't have that channelrecord: ${value}"
 				putlog "Mnet! Can't remove - I don't have that channelrecord: ${value}"
 			}
 		} else {
-			mnet:put_nick ${nick} "Mnet! Can't remove: no channel given"
+			::putils::put_nick ${nick} "Mnet! Can't remove: no channel given"
 		}
 		
 		return 0
@@ -271,59 +296,65 @@ proc mnet:admin {nick mask hand chan text} {
 
 	if {${cmd} == "reload"} {
 		# reload network configs, pointing to procedure
-		mnet:admin_reload $nick $mask $hand $chan $text
+		::cims::admin::reload $nick $mask $hand $chan $text
 		return 0
 	}
 
 	if {${cmd} == "channels"} {
 		# tell channel infos, pointing to procedure
-		mnet:admin_channelinfo $nick $mask $hand $chan $text
+		::cims::admin::channelinfo $nick $mask $hand $chan $text
 		return 0
 	}
 
 	if {${cmd} == "rehash"} {
 		# rehash
-		mnet:admin_rehash $nick $mask $hand $chan $text
+		::cims::admin::rehash $nick $mask $hand $chan $text
 		return 0
 	}
 
 	if {${cmd} == "version"} {
 		# tells version
-		mnet:admin_version $nick $mask $hand $chan $text
+		::cims::admin::version $nick $mask $hand $chan $text
 		return 0
 	}
 
 		
 	# none of the above worked .. so we are here:
-	mnet:put_nick ${nick} "mnet! possible commands are: add remove reload channels rehash version"
-	mnet:put_nick ${nick} "mnet! use either \002!mnet_botnetnickname <command>\002 to admin a single bot or just \002!mnet_<command>\002 to admin ALL bots that listen to your words here."
-	mnet:put_nick ${nick} "add #channelname       || bot joins a channel"
-	mnet:put_nick ${nick} "remove #channelname    || bot parts a channel"
-	mnet:put_nick ${nick} "reload                 || reloads the mnet_configs" 
-	mnet:put_nick ${nick} "channels               || tells some channel-infos"
-	mnet:put_nick ${nick} "rehash                 || rehashes the bot, reloads all botscripts"
-	mnet:put_nick ${nick} "version                || tells version"
+	::putils::put_nick ${nick} "mnet! possible commands are: add remove reload channels rehash version"
+	::putils::put_nick ${nick} "mnet! use either \002!mnet_botnetnickname <command>\002 to admin a single bot or just \002!mnet_<command>\002 to admin ALL bots that listen to your words here."
+	::putils::put_nick ${nick} "add #channelname       || bot joins a channel"
+	::putils::put_nick ${nick} "remove #channelname    || bot parts a channel"
+	::putils::put_nick ${nick} "reload                 || reloads the mnet_configs" 
+	::putils::put_nick ${nick} "channels               || tells some channel-infos"
+	::putils::put_nick ${nick} "rehash                 || rehashes the bot, reloads all botscripts"
+	::putils::put_nick ${nick} "version                || tells version"
 	
 
 	
 }
 
-# timer weil $botnet-nick nicht sofort von eggdrop gesetzt wird
-utimer 3 "mnet:admin_bindings"
 
-proc mnet:admin_bindings {} {
-	global botnet-nick
-	set proper_botnick [mnet:proper_botnick ${botnet-nick}]
-	
-	bind pub - !mnet_${proper_botnick} mnet:admin
-	bind pub - !mnet_reload            mnet:admin_reload
-	bind pub - !mnet_channels          mnet:admin_channelinfo
-	bind pub - !mnet_rehash            mnet:admin_rehash
-	bind pub - !mnet_version           mnet:admin_version
-	bind pub - !mnet_trylink           mnet:admin_trylink
+proc ::cims::admin::bindings {} {
+  variable mnet_admin_version
+  global botnet-nick
 
+  set proper_botnick [::putils::proper_botnick ${botnet-nick}]
+
+  bind pub - !mnet_${proper_botnick} ::cims::admin::main
+  bind pub - !mnet_reload            ::cims::admin::reload
+  bind pub - !mnet_channels          ::cims::admin::channelinfo
+  bind pub - !mnet_rehash            ::cims::admin::rehash
+  bind pub - !mnet_version           ::cims::admin::version
+  bind pub - !mnet_trylink           ::cims::admin::trylink
+
+  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"
+}
+
+
 
-putlog "mnet! = mnet adminscript loaded: $mnet_admin_version"
 

+ 34 - 17
putils.tcl

@@ -4,20 +4,29 @@
 
 namespace eval ::putils {
   ## some internal variables for messaging and stuff :) not your business after all.
+
+  # if putils-variable (thus, putils!) is already loaded, then .. well .. load again, but, this time, quietly. ;-)
+  if {![info exists putils]} {
+    putlog "::putils:: paul utils for eggdrop bots in tcl $putils(version) loading..."
+  }
+  
+  # set again .. perhaps we changed version while in development ;) - even while putils was already loaded.
   set putils(version) "0.3"
-  putlog "::putils:: paul utils for eggdrop bots in tcl $putils(version) loading..."
 }
 
 
-# gets botnick, truncates it and lowercases it.
+### this "library" supplies the following procedures:
+
+# gets botnick, truncates it and lowercases it. If input-value of a botnick was 
+# already correct, then it won't change anything. ;)
 proc ::putils::proper_botnick {botnick} {
 
   set temp [string tolower $botnick]
   # abfrage ob zu lang, dann fixen
-  #	putlog "::putils:: $botnick lowercase: $temp"
+  # putlog "::putils:: $botnick lowercase: $temp"
   if {[string length $botnick] > 9} {
     set temp [string range $temp 0 8 ]
-    #		putlog "::putils:: botnickname $botnick too long: capping to: $temp"
+    # putlog "::putils:: botnickname $botnick too long: capping to: $temp"
   }
   return $temp
 
@@ -25,22 +34,25 @@ proc ::putils::proper_botnick {botnick} {
 
 
 proc ::putils::proper_channelname {channelname} {
-	# channel names ARE NOT and SHOULD NOT BE CASE SENSITIVE!
-	set temp [string tolower $channelname]
-	set temp [::putils::umlauts $temp]
-#	putlog "::putils:: $channelname lowercase: $temp"
+  # channel names ARE NOT and SHOULD NOT BE CASE SENSITIVE!
+  set temp [string tolower $channelname]
+  set temp [::putils::umlauts $temp]
+  # putlog "::putils:: $channelname lowercase: $temp"
 
-	return $temp
+  return $temp
 }
 
-
+# puts out a normal channel message.
 proc ::putils::put_local_msg {chan text} {
-  variable mnet_colors 
-  variable mnet_freqs_onoff
+  
+  putserv "PRIVMSG $chan :$text"
+  putlog "::putils:: + normal message: ${chan} => '$text'"
 
-	putserv "PRIVMSG $chan :$text"
-	putlog "::putils:: + normal message: ${chan} => '$text'"
+}
 
+# puts a NOTICE to a specified nickname with a specified message.
+proc ::putils::put_nick {nick msg} { 
+  putserv "NOTICE $nick :$msg" 
 }
 
 
@@ -51,7 +63,8 @@ proc ::putils::kill_spaces {text} {
 
 
 
-
+# cleans the input text from all irc control codes... and even has
+# some spam-protection.
 proc ::putils::clean_txt {text} {
 
   #putlog "filter_A: ${text}"
@@ -80,11 +93,14 @@ proc ::putils::clean_txt {text} {
 
 
   set text [string trim $text]
-  #	putlog "filter_B: ${text}"
+  # putlog "filter_B: ${text}"
   return $text
 
 }
 
+# replace found umlauts with umlauts.. funny, eh? We have to do this to channel names with
+# umlauts, because of some encoding problem inside eggdrop. 
+# Afterwards, you can check for channelnames - without errors.
 proc ::putils::umlauts {text} {
   # A REAL STRANGE BUG WORKAROUND WITH UMLAUTS
   regsub -all "Ä" ${text} "Ä" text
@@ -99,7 +115,7 @@ proc ::putils::umlauts {text} {
 }
 
 
-# safe "bot-knows-the-channel-and-is-in-there"-function
+# safe "bot-knows-the-channel-and-is-in-there"-function, returns boolean
 proc ::putils::botonchannel {chan} { 
   if {[validchan $chan] == 1 && [botonchan $chan] == 1} {
     return 1
@@ -108,3 +124,4 @@ proc ::putils::botonchannel {chan} {
   }
 }
 
+return 1

+ 15 - 9
qs_net.tcl

@@ -24,7 +24,14 @@
 #     parse retrieved data
 #     output to channel where called
 
+namespace eval ::qsnet {
 
+  if {[file isfile "scripts/cims/putils.tcl"] == 1} {
+    source "scripts/cims/putils.tcl"
+  }
+
+  bind pub - !qw ::qsnet::feed_get_qw_and_display
+}
 
 namespace eval ::rss-synd {
         variable rss
@@ -59,7 +66,7 @@ namespace eval ::rss-synd {
 
 
 
-proc ::cims::feed_get_qw_and_display {nick mask hand chan text} {
+proc ::qsnet::feed_get_qw_and_display {nick mask hand chan text} {
 
   # ist im channel erlaubt?
   # ist abfrageintervall eingehalten?
@@ -81,8 +88,8 @@ proc ::cims::feed_get_qw_and_display {nick mask hand chan text} {
   set tmp_cmd   [lindex ${text} 0]
   set tmp_value [lindex ${text} 1]
 
-  set cmd  [string tolower [mnet:kill_spaces ${tmp_cmd}]]
-  set value [string tolower [mnet:kill_spaces ${tmp_value}]]
+  set cmd  [string tolower [::putils::kill_spaces ${tmp_cmd}]]
+  set value [string tolower [::putils::kill_spaces ${tmp_value}]]
 
 
   if {${cmd} == "fp"} {
@@ -92,19 +99,19 @@ proc ::cims::feed_get_qw_and_display {nick mask hand chan text} {
       if {[string length ${value}] > "1"} {
 	set rofg [::rss-synd::feed_get $value]
 	if {$rofg == 666} {
-	  mnet:put_local_msg ${chan} "Mnet! Player not found on any qw server."
+	  ::putils::put_local_msg ${chan} "Mnet! Player not found on any qw server."
 	}
       } else {
-	mnet:put_local_msg ${chan} "Mnet! Searchvalue has to be longer than 1 character."
+	::putils::put_local_msg ${chan} "Mnet! Searchvalue has to be longer than 1 character."
       }
     } else {
-	mnet:put_local_msg ${chan} "Mnet! No searchvalue given.."
+	::putils::put_local_msg ${chan} "Mnet! No searchvalue given.."
     }
     return 0
   }
 
-  mnet:put_local_msg ${chan} "Possible !qw commands are:"
-  mnet:put_local_msg ${chan} "'!qw fp xyz' to find a player named xyz"
+  ::putils::put_local_msg ${chan} "Possible !qw commands are:"
+  ::putils::put_local_msg ${chan} "'!qw fp xyz' to find a player named xyz"
 
 }
 
@@ -351,7 +358,6 @@ proc ::rss-synd::init {args} {
 
         bind evnt -|- prerehash [namespace current]::deinit
         #bind time -|- {* * * * *} [namespace current]::feed_get
-        bind pub - !qw ::cims::feed_get_qw_and_display
         bind pubm -|- {* *} [namespace current]::trigger
         bind msgm -|- {*} [namespace current]::trigger