Selaa lähdekoodia

message length check

Paul Klumpp 11 vuotta sitten
vanhempi
commit
8c3853ec7c
2 muutettua tiedostoa jossa 42 lisäystä ja 37 poistoa
  1. 41 36
      cims.tcl
  2. 1 1
      cims_interconnect.tcl

+ 41 - 36
cims.tcl

@@ -1007,8 +1007,6 @@ proc ::cims::allowed_user {network name prefix nick mask chan} {
 	return 1
 }
 
-
-
 # allowcheck for bots sending netmessages
 proc ::cims::allowed_netbot {network netbot} {
   variable mnet
@@ -1684,45 +1682,52 @@ proc ::cims::messaging_public_from_bind {nick mask hand chan text} {
 		return 0
 	}
 	# user has not been matched against banlist. So he's allowed here.
-
 	
-	
-	# cleaning given strings...
-	set text [::cims::clean_txt $text]
-
-	# check here if we have some text or not.. :)
-	if {$text == "" || $text == "{}"} {
-	
-		# output some help:
-		putlog  "::cims:: = gave him some help"
-		::putils::put_local_msg $chan $help
+  ### spamprotection
+  # returns the seconds that are left for this channel .. or 0 if no seconds left.
+  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."
+    ::putils::put_nick $nick "Sorry $nick, usage of $prefix only every $delay seconds. $secsleft seconds for $chan remaining."
+    # now BREAK "messaging_public_from_bind".
+    # NO break.. for debug :)) arf
+    return 0
+  }
+  ### end spamprotection
+
+  ### text check protection
+  # cleaning given strings...
+  set text [::cims::clean_txt $text]
+
+  set msglen [string length $text]
+  # see if that cleaned text ist ok to send.
+  # fixme: put this into a central variable to get from somewhere (http config?)
+  set allowed_msglen 230
+  if {$msglen == 0} {
+    # output some help:
+    ::putils::put_local_msg $chan $help
+    return 0
+  } elseif {$msglen > $allowed_msglen} {
+    # output some info:
+    ::putils::put_local_msg $chan "Your message is too long, containing $msglen of $allowed_msglen characters."
+    return 0
+  } elseif {$msglen < 3} {
+    # output some info:
+    ::putils::put_local_msg $chan "Your message is too short. Minimum 3 characters."
+    return 0
+  }
+  ### end text check protection
 
-	} else {
-		# ok, now send! (if timer allows it)
-		
-		### spamprotection
-		# returns the seconds that are left for this channel .. or 0 if no seconds left.
-		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."
-			::putils::put_nick $nick "Sorry $nick, usage of $prefix only every $delay seconds. $secsleft seconds for $chan remaining."
-			# now BREAK "messaging_public_from_bind".
-			# NO break.. for debug :)) arf
-			return 0
-		}
-		# if we went through the timer check ... so it doesn't exist anymore then we set a new one:
-		# set a timer-id to check for again, if it's allowed or not .. delay
-		set mnet_delay($prefix,$chan) [utimer $delay ::cims::dummy]
-		### end spamprotection
+  # if we went through the timer check ... so it doesn't exist anymore then we set a new one:
+  # set a timer-id to check for again, if it's allowed or not .. delay
+  set mnet_delay($prefix,$chan) [utimer $delay ::cims::dummy]
 
-		## HE IS SENDING NOW!
-		::cims::message_from_local $network $freqname $chan $nick $text
+  ## HE IS SENDING NOW!
+  ::cims::message_from_local $network $freqname $chan $nick $text
 
-		# wait here some more! (10 seconds with utimer) - to send out a reply to the channel
-		utimer 10 "::cims::timeout_reply_from_local_for_netbots $freqname $chan"
+  # wait here some more! (10 seconds with utimer) - to send out a reply to the channel
+  utimer 10 "::cims::timeout_reply_from_local_for_netbots $freqname $chan"
 
-	
-	}
 
 }
 ### END public reachable commands

+ 1 - 1
cims_interconnect.tcl

@@ -397,7 +397,7 @@ proc ::cims::interconnect::pingloop {} {
 	}
 
 	if {$matched == 0 && $pipe != ""} { 
-		utimer 90 "::cims::interconnect::pingloop" 
+		utimer 160 "::cims::interconnect::pingloop" 
 	}
 
 	# start a ping