Autore |
Messaggio |
Dark`Shneider
Utente appena iscritto
Registrato: 17/12/03 00:58 Messaggi: 1
|
|
Da TCL a SCRIPT MIRC |
|
Ho una tcl chiamata Cufs per il mio windrop, pero' vorrei applicare questa tcl anche ad un mircbot. Qualcuno e' in grado di crearmi uno script che faccia le stesse cose? Lo Posto per intero, e sarei veramente molto grato se qualcuno potesse aiutarmi, dato che e' diverso tempo che non scripto piu' su mirc e non mi ricordo praticamente piu' niente. Grazie.
p.s. ci sarebbe anche un !forget , ma e' il !remember e il suo funzionamento che mi premono... quindi ignorate pure la parte del !Forget
| |
# Completely Useless Fun Script.tcl [TM]
# Version: 2.0
#
# Zoef (zoef@zoefdehaas.nl)
# developed on Plophoofd on #openbsd.nl@IRCNet
# Original way way back by ArcAngel (arcangel@xs26.net)
#
#
# - let your bot react to userdefined keywords
# for example
# !remember cool Yeah, I like that too
# will let your bot say "Yeah, I like that too" every time
# the word 'cool' is spoken in the channel
#
putlog "Channel LSUfun v2.0 by Zoef - Loaded"
# NOTE: Make sure the files/ dir exists !!
set learnfile "files/$botnick.learn"
# remember and forget
bind pub m !remember pub:learn
# !remember <keyword> <desciption>
proc pub:learn {nick host hand chan args} {
global learnfile
set args [string trim $args "{} "]
set len [string length $args]
if {$len == 0} {
putserv "PRIVMSG $chan :*bzzzzzz* geen koelkast voor jou!"
return
}
set space [string first " " $args]
if {$space == -1} {
putserv "PRIVMSG $chan :*bzzzzzz* geen koelkast voor jou!"
return
}
set word [string trim [string range $args 0 $space] ]
set learn [string trim [string range $args $space $len] ]
set file [open $learnfile a+]
puts $file "${word}::$learn"
close $file
putserv "PRIVMSG $chan :$word... ok me la ricordero'"
}
# keep eye on chan and talk
proc pub:learned {nick host hand chan args} {
global learnfile
set found 0
set i ""
set foundstr(0) ""
set args [string trim $args "{} "]
if [file readable $learnfile] {
set file [open $learnfile RDONLY]
while {1} {
if [eof $file] break
set line [gets $file]
# Get the word. Should be: set word [ctoken $line ":"]
set len [string length $line]
set colon [string first ":" $line]
set word [string range $line 0 [expr $colon -1] ]
set line [string range $line [expr $colon +1] $len]
# Get the flags. Should be: set flags [ctoken $line ":"]
set len [string length $line]
set colon [string first ":" $line]
set flags [string range $line 0 [expr $colon -1] ]
set line [string range $line [expr $colon +1] $len]
foreach i [join $args] {
if {[string compare $i $word] == 0} {
set foundstr($found) $line;
##putserv "PRIVMSG $chan :$i == $line"
incr found
}
}
}
close $file
if { $found > 0 } {
set show [expr [rand $found]]
putserv "PRIVMSG $chan :$foundstr($show)"
unset foundstr
set found 0
return
}
} else {
return
}
}
# !forget <keyword>
proc pub:forget {nick host hand chan args} {
global learnfile
set found 0
set args [string trim $args "{} "]
if {[string length $args] == 0} {
putserv "PRIVMSG $chan :*bzzzzzzt*"
return
}
# Step one: Create a new file without the $args keyword.
if [file readable $learnfile] {
set file [open $learnfile RDONLY]
set newfile [open $learnfile.tmp w]
while {1} {
if [eof $file] break
set line [gets $file]
# Get the word. Should be: set word [ctoken $line ":"]
set len [string length $line]
set colon [string first ":" $line]
set word [string range $line 0 [expr $colon -1] ]
set line [string range $line [expr $colon] $len]
if {[string compare $args $word]} {
puts $newfile "$word$line"
} else {
incr found
}
}
close $file
close $newfile
} else {
putserv "PRIVMSG $chan :But I don't know anything!"
return
}
if {$found == 0} {
putserv "PRIVMSG $chan :*bzzt* Wat is dat, \"$args\"?"
return
}
# Step two: Rewrite the $learnfile from the new file.
set file [open $learnfile w]
set newfile [open $learnfile.tmp r]
while { 1 } {
if [eof $newfile] break
puts $file [gets $newfile]
}
close $file
close $newfile
putserv "PRIVMSG $chan :wat? \"$args\"? wat is dat?"
}
# EOF
|
|
|
Mer Dic 17, 2003 1:09 am |
|
|
|
|
Non puoi inserire nuovi argomenti Non puoi rispondere a nessun argomento Non puoi modificare i tuoi messaggi Non puoi cancellare i tuoi messaggi Non puoi votare nei sondaggi
|
|
|