# %topic Q on|off # - on: Q setzt euer Topic, nicht der Bot. # - off: Der Bot setzt das Script selber, zB wenn ihr kein Q habt ;) # # %topic make # - Speichert euer Topic ab. # - Ihr könnt Variablen gebrauchen (zB ":text:", ":news:", ":info:", ":hp:", etc.). Wie die Variablen heißen sei euch freigestellt. # # %topic :text:/:news:/:info:/:hp:/... # - Setzt die Variablen, die ihr in eurem Topic benutzt. # # %topic set # - Setzt das neue Topic, mit allen Variablen, die ihr aber vorher Speichern müsst. Sonst sieht das neue Topic echt scheiße aus. # # # BINDINGS # bind pub nm|nm %topic topic:pub # # SETTINGS # set topic(ver) 0.84b set topic(directory) "scripts/dbase" set topic(file,vars) "topic_vars.db" setudef flag topic_Q setudef str topic if {![file isdirectory $topic(directory)]} { file mkdir $topic(directory) } if {![file exists $topic(directory)/$topic(file,vars)]} { close [open $topic(directory)/$topic(file,vars) a+] } # # T3H SCRIPT # proc topic:pub { nick host hand chan arg } { global topic set function [string tolower [lindex $arg 0]] set chan [string tolower [encrype $chan]] switch $function { q { if {[string tolower [lindex $arg 1]] == "on"} { channel set $chan +topic_Q putquick "NOTICE $nick :Done." } elseif {[string tolower [lindex $arg 1]] == "off"} { channel set $chan -topic_Q putquick "NOTICE $nick :Done." } else { putquick "NOTICE $nick :Error. Please use !topic Q on|off." } } make { set length [string length [lrange $arg 1 end]] if {$length > 250} { putquick "NOTICE $nick :Topic is too long. Max: 250 characters. You have: $length." return } channel set $chan topic [lrange [encrype $arg] 1 end] putquick "NOTICE $nick :Topic successfully saved." } set { if {[channel get $chan topic] == ""} { putquick "NOTICE $nick :No topic set. Please use \"!topic make \" first." return } set new_topic [channel get $chan topic] set file [open "$topic(directory)/$topic(file,vars)" r] while {![eof $file]} { set line [encrype [gets $file]] if {[lindex $line 0] == $chan} { set new_topic [string map "\":[lindex $line 1]:\" \"[lrange $line 2 end]\"" $new_topic] } } close $file if {[channel get $chan topic_Q]} { putquick "PRIVMSG Q :settopic [decrype $chan] [decrype $new_topic]" putquick "NOTICE $nick :Done." } else { putquick "TOPIC [decrype $chan] :[decrype $new_topic]" putquick "NOTICE $nick :Done." } } default { if {$function == ""} { return } regsub -all -- ":" $function "" function set text [lrange [encrype $arg] 1 end] set found 0 set file [open "$topic(directory)/$topic(file,vars)" r] set temp [open "$topic(directory)/topic.temp" a+] while {![eof $file]} { set line [encrype [gets $file]] if {$line != ""} { if {[lindex $line 0] == $chan && [lindex $line 1] == $function} { puts $temp "$chan $function $text" set found 1 } else { puts $temp $line } } } close $file close $temp file delete $topic(directory)/$topic(file,vars) file rename $topic(directory)/topic.temp $topic(directory)/$topic(file,vars) if {!$found} { set file [open "$topic(directory)/$topic(file,vars)" a+] puts $file "$chan $function $text" close $file } putquick "NOTICE $nick :Variable successfully saved." } } } proc encrype { text } { regsub -all -- \\\\ $text 9328 text regsub -all -- \\\] $text 2417 text regsub -all -- \\\[ $text 4411 text regsub -all -- \\\} $text 9832 text regsub -all -- \\\{ $text 4832 text regsub -all -- \\\" $text 5534 text regsub -all -- \\\; $text 8934 text return $text } proc decrype { text } { regsub -all -- 9328 $text \\ text regsub -all -- 2417 $text \] text regsub -all -- 4411 $text \[ text regsub -all -- 9832 $text \} text regsub -all -- 4832 $text \{ text regsub -all -- 5534 $text \" text regsub -all -- 8934 $text \; text return $text } putlog "Topic-Script v$topic(ver) loaded."