# putils namespace eval ::putils { ## some internal variables for messaging and stuff :) not your business after all. set putils(version) "0.3" putlog "::putils:: paul utils for eggdrop bots in tcl $putils(version) loading..." } # gets botnick, truncates it and lowercases it. proc ::putils::proper_botnick {botnick} { set temp [string tolower $botnick] # abfrage ob zu lang, dann fixen # 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" } return $temp } 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" return $temp } proc ::putils::put_local_msg {chan text} { variable mnet_colors variable mnet_freqs_onoff putserv "PRIVMSG $chan :$text" putlog "::putils:: + normal message: ${chan} => '$text'" } proc ::putils::kill_spaces {text} { regsub -all "\\s+" $text "" text return $text } proc ::putils::clean_txt {text} { #putlog "filter_A: ${text}" #regsub -all "\\" $text "\\\\" text # fixes many whitespace between words down to one space between words regsub -all "\\s+" $text " " text # filtering out all colorcodes (works well) regsub -all "\003\[0-9\]\{1,2\},\[0-9\]\{1,2\}" $text "" text regsub -all "\003\[0-9\]\{1,2\}" $text "" text regsub -all "\003" $text "" text # filtering out BOLD text regsub -all "\002" $text "" text # underline gets filtered too. (since +c on quakenet would suppress it ...) regsub -all "\037" $text "" text # replacing like !!!!!!!!!!!!! with !!!!! (5 letters) # s/(.?)\1{4,}/\1\1\1\1\1/g; # - max 5 same chars in a row regsub -all -nocase -expanded {(.)\1\1\1\1+} $text {\1\1\1\1\1} text #putlog "test: $text" set text [string trim $text] # putlog "filter_B: ${text}" return $text } proc ::putils::umlauts {text} { # A REAL STRANGE BUG WORKAROUND WITH UMLAUTS regsub -all "Ä" ${text} "Ä" text regsub -all "Ü" ${text} "Ü" text regsub -all "Ö" ${text} "Ö" text regsub -all "ä" ${text} "ä" text regsub -all "ü" ${text} "ü" text regsub -all "ö" ${text} "ö" text return ${text} } # safe "bot-knows-the-channel-and-is-in-there"-function proc ::putils::botonchannel {chan} { if {[validchan $chan] == 1 && [botonchan $chan] == 1} { return 1 } else { return 0 } }