Paul Klumpp 11 år sedan
förälder
incheckning
9278f8814a
4 ändrade filer med 32 tillägg och 25 borttagningar
  1. 4 6
      cims.tcl
  2. 23 13
      cims_interconnect.tcl
  3. 3 1
      cims_interconnect_slave.tcl
  4. 2 5
      putils.tcl

+ 4 - 6
cims.tcl

@@ -789,8 +789,7 @@ proc ::cims::receive_message {rec_botnick cmd rec_data} {
   #}
 
   # ANSWER! SEND THE REPLY of counts to the originating bot.
-	#set rec_channel [list [join $rec_channel]]
-	putlog "that ONE LALAL chan: $rec_channel"
+	#putlog "that ONE LALAL chan: $rec_channel"
 
 	::cims::put_bot $rec_botnick "mnet_answer [list [list $network] [list $name] $rec_channel [list $users] [list $count_channels] $unique_userlist]"
 	return 0
@@ -807,15 +806,14 @@ proc ::cims::receive_answer {rec_botnick cmd rec_data} {
 	set long [string length $rec_data]
 	putlog "::cims:: * on receive_answer from $rec_botnick length: $long"
 
-	# we receive a STRING in rec_data! convert into list!
-	#set rec_data [split $rec_data]
-	putlog "THAT TWO RECDATA: $rec_data"
+	# we receive a LIST in rec_data! (see above "mnet_anser")
+	#putlog "THAT TWO RECDATA: $rec_data"
 
 	# work with list (lindex, lrange) and put together to a STRING again with JOIN.
 	set network [join [lindex $rec_data 0]]
 	set name    [join [lindex $rec_data 1]]
 	set chan    [join [lindex $rec_data 2]]
-  putlog "THAT TWO: $chan"
+  #putlog "THAT TWO: $chan"
 
   # rec_usercount is obsolete
 	set rec_usercount [join [lindex $rec_data 3]]

+ 23 - 13
cims_interconnect.tcl

@@ -111,23 +111,30 @@ proc ::cims::interconnect::send_from_bind {nick mask hand chan text} {
 	::cims::interconnect::send "$text"
 }
 
-proc ::cims::timeout_reply_from_ic_for_netbot {netbot network freqname source} {
+proc ::cims::interconnect::build_count_string {freqname source } {
 	set bcid $::cims::interconnect::sources($freqname,$source)
-
 	if {[info exists ::cims::interconnect::receive_count($bcid)]} {
 		set count_list $::cims::interconnect::receive_count($bcid)
 
-		set output_for_netbot "And to "
+		set output_for_netbot "And to"
 		foreach {item count} $count_list {
-			set output_for_netbot "$output_for_netbot $count ${item}, "
+			set output_for_netbot "$output_for_netbot $count ${item},"
 		}
-		set output_for_netbot "[string range $output_for_netbot 0 [expr [string length $output_for_netbot] - 2]"
+		set output_for_netbot "[string range $output_for_netbot 0 [expr [string length $output_for_netbot] - 2]]"
 		set output_for_netbot "${output_for_netbot}."
-		putlog "w000000t: $output_for_netbot"
-		# Give him a reply.
-		::cims::put_bot $netbot "mnet_interconnect_answer $network $freqname $source $output_for_netbot"
-	} 
 
+		return $output_for_netbot
+	} else {
+		return ""
+	}
+}
+
+proc ::cims::timeout_reply_from_ic_for_netbot {netbot network freqname source} {
+
+  set output_for_netbot [::cims::interconnect::build_count_string $freqname $source]
+	if {"$output_for_netbot" != ""} {
+		::cims::put_bot $netbot "mnet_interconnect_answer $network $freqname $source [list $output_for_netbot]"
+	} 
 
 }
 
@@ -223,10 +230,10 @@ proc ::cims::interconnect::add_up {bcid item count} {
 # called right before the output...
 proc ::cims::timeout_reply_from_local_for_netbots_plugin {freqname source} {
 	upvar output output
-	set bcid $::cims::interconnect::sources($freqname,$source)
 
-	if {[info exists ::cims::interconnect::receive_count($bcid)]} {
-		set output "$output $::cims::interconnect::receive_count($bcid)"
+  set add_output [::cims::interconnect::build_count_string $freqname $source]
+	if {"$add_output" != ""} {
+		set output "$output $add_output"
 	} 
 }
 
@@ -248,7 +255,10 @@ proc ::cims::interconnect::work {inputline} {
 	# this tells us, we sent a REQ_BC before. 
 
 		set broadcasts($bcid) [list "$network" "$freqname" "$source"]
+
+		# keep that last message from $freqname,$source valid for 15 seconds
 		set ::cims::interconnect::sources($freqname,$source) "$bcid"
+		utimer 15 "unset ::cims::interconnect::sources($freqname,$source)"
 
 		#putlog "bcid vars saved: $broadcasts($bcid) "
 
@@ -420,7 +430,7 @@ proc ::cims::message_from_netbot_to_plugin {netbot network freqname source nick
 	# receive answers from the other networks
 	# in the meantime, we get all the BC_RE replies and counts.
 	# Now, we should get that count and send it to originating netbot.
-	utimer 5 "::cims::timeout_reply_from_ic_for_netbot $netbot $network $freqname $source"
+	utimer 5 "::cims::timeout_reply_from_ic_for_netbot $netbot $network $freqname [list $source]"
 
 	# send an own answer to the originating netbot
 

+ 3 - 1
cims_interconnect_slave.tcl

@@ -45,8 +45,10 @@ proc ::cims::interconnect::reply_from_icmaster {rec_botnick cmd rec_data} {
 		return 0
 	}
 	# now the bot is declared as a known bot.
-
+	putlog "SOURCE: $rec_source"
 	set ::cims::interconnect::receive_count($rec_freqname,$rec_source) $rec_text
+	#keep this valid for 15 seconds
+	utimer 15 "unset ::cims::interconnect::receive_count($rec_freqname,$rec_source)"
 
 }
 

+ 2 - 5
putils.tcl

@@ -251,11 +251,8 @@ proc ::putils::rec_bot {sender_botnetnick cmd rec_data} {
 				#putlog "::putils::put_bot: cmd: $cmd procedure: $procedure"
 				# FIXME: we currently don't check for permissions...
 				if {$cmd == [join [lindex $original_data 0]]} {
-					#putlog "::putils::rec_bot: execute procedure: $procedure $sender_botnetnick [join [lindex $original_data 0]] [join [lrange $original_data 1 end]]"
-					#execute procedure
-					#$procedure $sender_botnetnick [join [lindex $original_data 0]] [list [lrange $original_data 1 end]]
-					putlog "::putils::rec_bot from $sender_botnetnick : execute procedure: $procedure $original_data"
-					putlog "ORIGINAL DATA has [llength $original_data] ELEMENTS"
+					putlog "::putils::rec_bot: ORIGINAL DATA has [llength $original_data] ELEMENTS"
+					putlog "::putils::rec_bot from $sender_botnetnick : execute procedure: $procedure $sender_botnetnick [join [lindex $original_data 0]] [lrange $original_data 1 end]"
 					$procedure $sender_botnetnick [join [lindex $original_data 0]] [lrange $original_data 1 end]
 					#any_netbot_proc  rec_bot     cmd                              payload
 				}