![]() |
|
|||||||
| Tcl scripting Tcl scripting related questions |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Junior Member
Join Date: Jul 2004
Posts: 3
Rep Power: 0 ![]() |
#This is the action.tcl that allows to add a public command for the bot to /me :)
#Copyright dutz 2004 <<>> inspired by yx_96_local_v.tcl a&a copyright .. All rights reserved #You can add or modify message by adding or modifing the lines :) example : #Let say you want to modify the command slap ... you just need to modify this line : puthelp #"PRIVMSG $chan :\001ACTION #after this line you see loveste pe \002$target\002 cu ciocanul .... and #you modify ..that .. in to whatever you want..let`s say \002$target\002 cu barosu` :) and thats #all:P #now lets say you wanna add your new shit ... justa add a line after this text that will look #like this : example: #you wanna add "flood command" .. you just need yo add a line like this: routine:addcom flood # pub:flood 1020 504 |v 1 #and then ... after that line .. you must add this : #proc pub:flood {hand chan args x mix} { # set target [lindex $args 0] # if {$args == ""} { # puthelp "PRIVMSG $chan :USAGE: flood <nick>" # return 1 } # puthelp "PRIVMSG $chan :\001ACTION your message " # return "$target" } routine:addcom slap pub:slap 1020 504 |v 1 routine:addcom fute pub:fute 1020 504 |v 1 routine:addcom pupa pub:pupa 1019 505 |v 1 proc pub:slap {hand chan args x mix} { set target [lindex $args 0] if {$args == ""} { puthelp "PRIVMSG $chan :USAGE: slap <nick>" return 1 } puthelp "PRIVMSG $chan :\001ACTION loveste pe \002$target\002 cu ciocanul peste degetul mic de la picior\001" return "$target" } proc pub:fute {hand chan args x mix} { set target [lindex $args 0] if {$args == ""} { puthelp "PRIVMSG $chan :USAGE: fute <nick>" return 1 } puthelp "PRIVMSG $chan :\001ACTION Il fute tare de tot pe \002$target\002 exact in ga0z!\001" return "$target" } proc pub:pupa {hand chan args x mix} { set target [lindex $args 0] if {$args == ""} { puthelp "PRIVMSG $chan : USAGE: kiss <nick>" return 1 } puthelp "PRIVMSG $chan :\001ACTION pupa duuuulce pe \002$target\002 pe botic :D \001" return "$target" } am asa ceva...pus intrun tcl....intrebarea mea e.... cum fac ca asta sa fie o comanda publica? sa o poata accesa oricine ? |
|
|
|
|
#2 (permalink) |
|
Administrator
aka aqwzsx |
Code:
routine:addcom slap pub:slap 1020 504 |v 1 routine:addcom fute pub:fute 1020 504 |v 1 routine:addcom pupa pub:pupa 1019 505 |v 1 Code:
routine:addcom slap pub:slap 1020 504 |s 1 routine:addcom fute pub:fute 1020 504 |s 1 routine:addcom pupa pub:pupa 1019 505 |s 1
|
|
|
|
|
#4 (permalink) |
|
Administrator
aka aqwzsx |
Nu merge. Ca sa mearga stergi
Code:
routine:addcom slap pub:slap 1020 504 |v 1 routine:addcom fute pub:fute 1020 504 |v 1 routine:addcom pupa pub:pupa 1019 505 |v 1 Code:
bind pub -|- .slap pub:slap bind pub -|- .fuck pub:fute bind pub -|- .kiss pub:pupa Code:
{hand chan args x mix}
Code:
{nick uhost hand chan args}
Code:
bind pub -|- .slap pub:slap
bind pub -|- .fuck pub:fuck
bind pub -|- .kiss pub:kiss
proc pub:slap {nick uhost hand chan args} {
set target [lindex $args 0]
if {$args == ""} {
puthelp "PRIVMSG $chan :USAGE: slap <nick>"
return 1 }
puthelp "PRIVMSG $chan :\001ACTION loveste pe \002$target\002 cu ciocanul peste degetul mic de la picior\001"
return "$target" }
proc pub:fute {nick uhost hand chan args} {
set target [lindex $args 0]
if {$args == ""} {
puthelp "PRIVMSG $chan :USAGE: fute <nick>"
return 1 }
puthelp "PRIVMSG $chan :\001ACTION Il fute tare de tot pe \002$target\002 exact in ga0z!\001"
return "$target" }
proc pub:pupa {nick uhost hand chan args} {
set target [lindex $args 0]
if {$args == ""} {
puthelp "PRIVMSG $chan : USAGE: kiss <nick>"
return 1 }
puthelp "PRIVMSG $chan :\001ACTION pupa duuuulce pe \002$target\002 pe botic :D \001"
return "$target" }
Last edited by UniversaliA; 15-08-2004 at 18:53. |
|
|
|
|
#5 (permalink) |
|
Senior Member
|
Code:
routine:addcom slap pub:slap 1020 504 |v 1
routine:addcom fute pub:fute 1020 504 |v 1
routine:addcom pupa pub:pupa 1019 505 |v 1
proc pub:slap {hand chan args x mix} {
set target [lindex $args 0]
if {$args == ""} {
puthelp "PRIVMSG $chan :USAGE: slap <nick>"
return 1 }
puthelp "PRIVMSG $chan :\001ACTION loveste pe \002$target\002 cu ciocanul peste degetul mic de la picior\001"
return "$target" }
proc pub:fute {hand chan args x mix} {
set target [lindex $args 0]
if {$args == ""} {
puthelp "PRIVMSG $chan :USAGE: fute <nick>"
return 1 }
puthelp "PRIVMSG $chan :\001ACTION Il fute tare de tot pe \002$target\002 exact in ga0z!\001"
return "$target" }
proc pub:pupa {hand chan args x mix} {
set target [lindex $args 0]
if {$args == ""} {
puthelp "PRIVMSG $chan : USAGE: kiss <nick>"
return 1 }
puthelp "PRIVMSG $chan :\001ACTION pupa duuuulce pe \002$target\002 pe botic :D \001"
return "$target" }
__________________
Forza RAPID ALE ALEEEEEEEEEEEEEEEEEEEEEEe |
|
|
|
|
#6 (permalink) |
|
Junior Member
Join Date: Jun 2004
Posts: 8
Rep Power: 0 ![]() |
aqwzsx cu ce ai zis tu acolo merge dar merge cu orice nick daca da cineva !slap <orice nick> si acel nick nu exista botul tot zice * @TheBot loveste pe <orice nick> cu ciocanul peste degetul mic de la picior ... cum fac sa zica doar daca nickul acela este pe canal iar daca nu este sa zica ca nu este acel nick pe canal ?
__________________
THE ONE THAT WAS, THE ONE THAT IS, THE ONE THAT WILL BE ! |
|
|
|
|
#8 (permalink) |
|
Member
Join Date: Jun 2004
Location: In the NeXuS
Posts: 160
Rep Power: 37 ![]() |
ceva de dat cu capul
![]() line adaugata la chanset Code:
[regexp {^(desc|url|mail)$} $mode] } { pub:setts $hand $chan $args $x $mix ;return } elseif {
Code:
routine:addcom url pub:url 0000 000 |s 1
routine:addcom mail pub:mail 0000 000 |s 1
routine:addcom desc pub:desc 0000 000 |s 1
proc setts:load {} {
global setts
catch {unset setts}
if {![file exists "setts.dat"]} {
set outfile [open "setts.dat" w]
close $outfile
}
set infile [open "setts.dat" r]
set buffer [read $infile]
close $infile
set buffer [split $buffer "\n"]
foreach line $buffer {
if {$line != ""} {
set dline [split $line "|"]
set dchan [string tolower [lindex $dline 0]]
set dcmd [lindex $dline 1]
set dinfo [lindex $dline 2]
set setts($dchan,$dcmd) $dinfo
}
}
return 1
}
proc setts:save {} {
global setts
set outfile [open "setts.dat" w]
foreach item [array names setts *,*] {
set dchan [lindex [split $item ","] 0]
set dcmd [lindex [split $item ","] 1]
set dinfo $setts($item)
if {($dchan != "") && ($dcmd != "") && ($dinfo != "")} {
puts $outfile "$dchan|$dcmd|$dinfo"
}
}
close $outfile
return 1
}
proc setts:iswhat {what chan} {
global setts
return [info exists setts([string tolower $chan],$what)]
}
proc setts:add {what info chan} {
global setts
if {[setts:iswhat $what $chan]} { return 0 }
set setts([string tolower $chan],$what) "$info"
return 1
}
proc setts:del {what chan} {
global setts
if {![setts:iswhat $what $chan]} { return 0 }
catch {unset setts([string tolower $chan],$what)}
return 1
}
proc pub:setts {hand chan args x mix} {
global setts
set nick [lindex $hand 0]
set cmd [string tolower [lindex [split $args] 0]]
set chan [string tolower $chan]
set what [lindex $args 0]
set info [join [lrange $args 1 end]]
if {!($what == "") && !($info == "") && !($info == "reset")} { set res [setts:add $what "$info" $chan];tell $x 1198 "$what $info"; setts:save ;return} elseif {
!($what == "") && ($info == "reset")} {set res [setts:del $what $chan];tell $x 1197 $what;setts:save;return} elseif {
($what == "")} {return}
}
setts:load
proc pub:url {hand chan args x mix} {
global setts
catch {unset setts}
if {![file exists "setts.dat"]} {
set outfile [open "setts.dat" w]
close $outfile
}
set infile [open "setts.dat" r]
set buffer [read $infile]
close $infile
set buffer [split $buffer "\n"]
foreach line $buffer {
if {($line != "") && [string match *$chan|url* $line]} {
set dline [split $line "|"]
set dchan [string tolower [lindex $dline 0]]
set dcmd [lindex $dline 1]
set dinfo [lindex $dline 2]
set setts($dchan,$dcmd) $dinfo
}
}
if {[info exists dinfo]} {tell $x 1196 "$dinfo"} else {return}}
proc pub:mail {hand chan args x mix} {
global setts
catch {unset setts}
if {![file exists "setts.dat"]} {
set outfile [open "setts.dat" w]
close $outfile
}
set infile [open "setts.dat" r]
set buffer [read $infile]
close $infile
set buffer [split $buffer "\n"]
foreach line $buffer {
if {($line != "") && [string match *$chan|mail* $line]} {
set dline [split $line "|"]
set dchan [string tolower [lindex $dline 0]]
set dcmd [lindex $dline 1]
set dinfo [lindex $dline 2]
set setts($dchan,$dcmd) $dinfo
}
}
if {[info exists dinfo]} {tell $x 1195 "$dinfo"} else {return}}
proc pub:desc {hand chan args x mix} {
global setts
catch {unset setts}
if {![file exists "setts.dat"]} {
set outfile [open "setts.dat" w]
close $outfile
}
set infile [open "setts.dat" r]
set buffer [read $infile]
close $infile
set buffer [split $buffer "\n"]
foreach line $buffer {
if {($line != "") && [string match *$chan|desc* $line]} {
set dline [split $line "|"]
set dchan [string tolower [lindex $dline 0]]
set dcmd [lindex $dline 1]
set dinfo [lindex $dline 2]
set setts($dchan,$dcmd) $dinfo
}
}
if {[info exists dinfo]} {tell $x 1194 "$dinfo"} else {return}}
functioneaza partial, dupa un timp daca pune alte setari pt alte canale le sterge pe cele de dinainte nu doar pe canalul respectiv...... daca aveti ceva idei, nu va abtineti sa le ziceti
|
|
|
|
|
#9 (permalink) |
|
Administrator
aka aqwzsx |
1. Pentru a citi un fisier si a scrie in fisier citesti http://forum.botlending.com/showthread.php?t=2. Nu ezita sa folosesti search pe forum
![]() 2. In scriptul care folosesti tu, deja sunt procese difinite pentru a seta proprietati de canal si care salveaza aceste proprietati, in plus tu poti face aceasta alternativ cu procesul default eggdop: setudef <str> <name> care e optimizat la maxim. (In orice caz, e foarte bine ca incerci sa creezi propriile solutii, aici numai castigi in experienta & cunostinte, dar uneori nu merita sa inventezi din nou bicicleta :P) 3. Referitor la erorile din acest script, de la inceput o sa evedentiez generalitatile si algoritmica si dupa aceea va fi analizat fiecare proces in parte.
ai difinit procesul pe urma in undeva in script la initiat cu simpla comanda setts:load. Ca pe urma fiecare data cand folosesti comanda url/desc/mail - sa dai unset. In plus cand dai rehash ? acest proces e executat din nou si din nou in van, si variabile care sunt in fisier mai vechi vor fi scrise deasupra la cele noi din memorie. Deci, mai bine ar fi sa-l initiezi asa: if {![info exists setts]} {setts:load}. Respectiv acuma in caz de rehash, daca array setts deja exista - nu are rost sa initiezi acest proces. if {![file exists "setts.dat"]} {} nu ar fi mai bine inloc de setts.dat sa setezi o variabila globala ? sa poti seta orice denumire de script oricand doresti tu ? b) proc setts:save {} {} ai inventat din nou bicicleta. Sunt doua modalitati mai optimale de a face aceasta: Code:
set fp [open setts.datw] puts $fp[list array set setts [array get setts]] close $fp A doua modalitate e de a scrie un nou proces de exemplu read:settings si sa salvezi in urmatorul fel: Code:
set fp [open setts.datw]
puts $fp "#Channel settings etc etc "
foreach chan [string tolower [channels]] {
puts $fp "read:settings mail $chan $setts($chan,mail)"
puts $fp "read:settings url $chan $setts($chan,url)"
puts $fp "read:settings desc $chan {$setts($chan,desc)}"
}
close $fp
Code:
proc read:settings {option chan txt} {
global setts
set $setts($chan,$option) $text
}
P.S. Pentru a doua varianta ai nevoie de o rutina de automatizare la chan join & part, BOTul automat sa creieze variabilele $setts($chan,OPTION) & sa le stearga. Sau simplu poti face asa: Code:
if {[info exists setts($chan,OPTION)} {puts $fp "read:settings OPTION$chan $setts($chan,OPTION)"}
c) proc setts:iswhat {} {} SKIP d) proc setts:add {} {} SKIP e) proc setts:del {} {} Code:
if {![setts:iswhat $what $chan]} { return 0 }
catch {unset setts([string tolower $chan],$what)}
f) proc pub:setts {} {} Code:
set cmd [string tolower [lindex [split $args] 0]] set what [lindex $args 0] De fapt cmd nici nu e folosita de tine, inteleg ca te inspiri din alt script, dar te-ai intrebat de ce el asa a scris ? Ca sa-ti dai seama incearca comanda "!setts []" sau "!setts }". Articol referitor la semne speciale care dau erori & cum sa le eviti http://www.peterre.com/characters.htmlCode:
if {!($what == "") && !($info == "") && !($info == "reset")} { set res [setts:add $what "$info" $chan];tell $x 1198 "$what $info"; setts:save ;return} elseif {
!($what == "") && ($info == "reset")} {set res [setts:del $what $chan];tell $x 1197 $what;setts:save;return} elseif {
($what == "")} {return
}
Code:
{($what != "") && ($info != "") && ($info != "reset")}
presupunand ca totul ce am spus mai sus e valibil, referitor la cititul din fisier, si nu conteaza care varainta e folosita, info despre canale deja e in memoria botului & procesul ar arata cam asa: proc pub:url {hand chan args x mix} { global setts set chan [string tolower $chan] if {[info exists setts($chan,url)] && $setts($chan,url) !=""} {tell $x 1196 $setts($chan,url)} else {return "FAILED: empy"} } h) proc pub:mail {} {} SKIP e) proc pub:desc {} {} SKIP Last edited by UniversaliA; 06-11-2004 at 18:21. |
|
|
|
|
#10 (permalink) |
|
Member
Join Date: Jun 2004
Location: In the NeXuS
Posts: 160
Rep Power: 37 ![]() |
dau aici varianta generala care o folosesc eu
![]() in fisierul yx_90_local_n.tcl se adauga la proc pub:chanset (aici dar pt rules|mail|desc ......sper sa va descurcati mai departe) Code:
[regexp {^(desc|mail|rules)$} $mode] } { pub:setts $hand $chan $args $x $mix ;return } elseif {
pub:setts Code:
setudef str rules
proc pub:setts {hand chan args x mix} {
set nick [lindex $x 0]
set what [lindex $args 0]
set info [join [lrange $args 1 end]]
set rules [channel get $chan "rules"]
if {($rules == "")} {set rules ""}
if {($info == "")} {usage $x chanset; return "invalid parameters specified"} elseif {
[string match -nocase reset $info]} {tell $x 263 "$chan $what";channel set $chan $what "";return "$what REset"} {tell $x 260 "$chan $what $info";channel set $chan $what "$info";return "$chan $info"}}
Code:
routine:addcom rules pub:rules 0000 000 |s 1
proc pub:rules {hand chan args x mix} {
if {([channel get $chan "rules"] == "") && [check:n:ch $hand $chan]} {tell $x 261 "rules rules";return "rules not setup yet"} elseif {
([channel get $chan "rules"] != "")} {tell $x 262 "[channel get $chan "rules"]";return "..."} {return "none ..."}}
P.S. 1 sau 2 setari cred ca sunt in plus dar acuma le-am observat si eu, oricum asta e varianta generala care o folosesc sper ca nu am uitat nimic
Last edited by lsn; 15-12-2004 at 12:25. |
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|