botlending forum  

Go Back   botlending forum > Eggdrop & TCL > Tcl scripting

Tcl scripting Tcl scripting related questions

Reply
 
LinkBack Thread Tools Display Modes
Old 07-11-2004, 23:50   #1 (permalink)
Senior Member
 
GoRaPiD's Avatar
 
Join Date: Jun 2004
Location: In pat cu avatarul meu
Age: 20
Posts: 256
Rep Power: 0
GoRaPiD is an unknown quantity at this point
Send a message via Yahoo to GoRaPiD
Talking Take Report

Vreau si eu un mic tcl care la take pe chan sa dea remuser la cel care face take / sa dea suspend la cel care i-a dat access / sa lase note cu aceste 2 usere
__________________
Forza RAPID ALE ALEEEEEEEEEEEEEEEEEEEEEEe

Last edited by GoRaPiD; 26-12-2004 at 02:02.
GoRaPiD is offline   Reply With Quote
Old 08-11-2004, 02:36   #2 (permalink)
Member
 
Kurupt's Avatar
 
Join Date: Jun 2004
Location: Hermannstadt
Age: 24
Posts: 108
Rep Power: 36
Kurupt will become famous soon enough
Send a message via Yahoo to Kurupt
Default poate te ajuta

Code:
# $Id: xremuser.tcl, eggdrop-1.6.x 2004 dpgc@purehype.net Exp $
bind kick - "*" xkick
setudef flag xneed
proc xkick {nick uhost hand chan vict reas} { 
  if {[string toupper $nick] != "X" || ![channel get $chan xneed]} {
	return
  }
  if {![string equal -nocase $vict $::botnick]} {
	return
  } 
  set kicker [string trim [lindex [split $reas] 0] {()}] 
  putquick "PRIVMSG X :remuser $chan $kicker"
}
putlog "XRemuser Loaded"
Stiu ca se mai poate face multe la el! Din pacate nu am timp.El singur doar o sa dea remuser la cel care i-a dat kick.
__________________
Owner of #ro-tcl
Kurupt is offline   Reply With Quote
Old 08-11-2004, 12:25   #3 (permalink)
Administrator

aka aqwzsx
 
Join Date: Jun 2004
Posts: 827
Blog Entries: 126
Rep Power: 3
UniversaliA is on a distinguished road
Default

Code:
if {[string toupper $nick] != "X" || ![channel get $chan xneed]} {
return
}
referitor la acest cod iti dau un mic extras din cartea "Practical Programming in Tcl & Tk, Third Edition" By Brent B. Welch

>>> inceput citat
Code:
if {$x == "foo"} command
expr is unreliable for string comparison.
Ironically, despite the quotes, the expression evaluator first converts items to numbers if possible, and then converts them back if it detects a case of string comparison. The conversion back is always done as a decimal number. This can lead to unexpected conversions between strings that look like hexadecimal or octal numbers. The following boolean expression is true!
Code:
if {"0xa" == "10"} {puts stdout ack! } => ack!
A safe way to compare strings is to use the string compare and equal operations. These operations work faster because the unnecessary conversions are eliminated. Like the C library strcmp function, string compare returns 0 if the strings are equal, minus 1 if the first string is lexicographically less than the second, or 1 if the first string is greater than the second:

Example 4-1 Comparing strings with string compare.

Code:
if {[string compare $s1 $s2] == 0} { # strings are equal }
The string equal command added in Tcl 8.1 makes this simpler:

Example 4-2 Comparing strings with string equal.

Code:
if {[string equal $s1 $s2]} { # strings are equal}
>>> sfirsit citat

referitor la
Code:
if {![string equal -nocase $vict $::botnick]} {
return
}
Sunt doua remarci, poti folosi functia [isbotnick $vict] & un alt citat din aceeasi carte

"The Tcl byte-code compiler generates faster code when you declare namespace and global variables. Each procedure context has its own table of variables. The table can be accessed by a direct slot index, or by a hash table lookup of the variable name. The hash table lookup is slower than the direct slot access. When you use the variable or global command, then the compiler can use a direct slot access. If you use qualified names, the compiler uses the more general hash table lookup."

& referitor la
Code:
 bind kick - "*" xkick 
...
set kicker [string trim [lindex [split $reas] 0] {()}]
Cand iai kick de la X - el da un notice ca ... u were kicked by ... Varianta de Kurupt e corecta, dar el fara analizeza toate kick-urile de pe canal - ce in cazul dat nu e nevoie, deci ar putin mai optimizat de facut bind pe notice de la X cu fraza data, si botul va analiza numai kick-urile "destinate" lui. Aceasta e doar o alternativa, ambele variante sunt corecte.
UniversaliA is offline   Reply With Quote
Old 25-12-2004, 15:33   #4 (permalink)
Member
 
caesar's Avatar
 
Join Date: Dec 2004
Location: Under a rock!
Posts: 116
Rep Power: 33
caesar will become famous soon enough
Default

Quote:
Originally Posted by Kurupt
Code:
# $Id: xremuser.tcl, eggdrop-1.6.x 2004 dpgc@purehype.net Exp $
bind kick - "*" xkick
setudef flag xneed
proc xkick {nick uhost hand chan vict reas} { 
  if {[string toupper $nick] != "X" || ![channel get $chan xneed]} {
	return
  }
  if {![string equal -nocase $vict $::botnick]} {
	return
  } 
  set kicker [string trim [lindex [split $reas] 0] {()}] 
  putquick "PRIVMSG X :remuser $chan $kicker"
}
putlog "XRemuser Loaded"
Stiu ca se mai poate face multe la el! Din pacate nu am timp.El singur doar o sa dea remuser la cel care i-a dat kick.
Ceea ce ai scris aici seamana izbitor cu ceea ce am scris eu in Xstuff Nu-i frumos sa stii. O sa te trag de urechi daca mai faci..

Code:
bind kick - "*" x:kick

proc x:kick {nick uhost hand chan vict reas} { 
  if {![isbotnick $vict] || $nick != "X"} {
    return
  }
  set kicker [string trim [lindex [split $reas] 0] {()}] 
  putserv "PRIVMSG X :access $chan $kicker -modif"
}

bind notc f "*MODIFICAT:*" x:access

proc x:access {nick uhost hand text dest} {
  if {[isbotnick [lindex [split $dest "@"] 0]]} {
    putserv "PRIVMSG GoRaPiD :$text"
  }
}
Ar trebui sa faca ce doresti mearga..
caesar is offline   Reply With Quote
Old 25-12-2004, 18:14   #5 (permalink)
Administrator

aka aqwzsx
 
Join Date: Jun 2004
Posts: 827
Blog Entries: 126
Rep Power: 3
UniversaliA is on a distinguished road
Default

Kurupt uf uf is that true ?
Caesar nice coding (am vazut toate 5 posturi) & site nice, binevenit la noi pe forum.

Doar o mica remarca care o prevad pentru Gorapid, acest script e facut pentru X cu limba ro setata la X Trebuie de verificat daca nu este raw de acelas tip, ca sa nu depinda scriptul de limba setata.
UniversaliA is offline   Reply With Quote
Old 25-12-2004, 18:17   #6 (permalink)
Senior Member
 
GoRaPiD's Avatar
 
Join Date: Jun 2004
Location: In pat cu avatarul meu
Age: 20
Posts: 256
Rep Power: 0
GoRaPiD is an unknown quantity at this point
Send a message via Yahoo to GoRaPiD
Question

aqwzsx poti pls sa-l modifici sa lase note, ca eu sa il citesc astfel /msg botnick notes parola index
Adik cum lasa botii a&a la take ?
__________________
Forza RAPID ALE ALEEEEEEEEEEEEEEEEEEEEEEe
GoRaPiD is offline   Reply With Quote
Old 25-12-2004, 20:39   #7 (permalink)
Administrator

aka aqwzsx
 
Join Date: Jun 2004
Posts: 827
Blog Entries: 126
Rep Power: 3
UniversaliA is on a distinguished road
Default

Poti face asa
Code:
putserv "PRIVMSG GoRaPiD :$text"
inlocuiesti cu
Code:
report |n take $chan $text
Si adaugi proces nou report
Code:
proc report {flag subj chan text} { 
   set chanlist [userlist $flag $chan] 
   if {$chanlist < 1} {return}
   foreach user $chanlist {sendnote $subj $user $text}
}
Deci acest procese va permite sa trimiti notes prin bot, la toti userii locali sau globali care doresti tu. Eu am scris sa trimata la locali +n. La flaguri poti specifica cat locali, atat si globalii. De exemplu la toti masterii globali si ownerii locali scrii m|n. Cuvintul take il poti skimba cu orice alt cuvint, acesta e subiectul la note.

Desigur, poti si sa nu faci procesul report aparte, dar am facut asa pentru ca sa poti reutiliza aceasta functie de mai mult ori + e mai clar asa ce face fiecare functia sendnote, scopul nu este de a da scriptul gata, dar de a arata cum s-ar putea de facut.
UniversaliA is offline   Reply With Quote
Old 25-12-2004, 22:22   #8 (permalink)
Member
 
caesar's Avatar
 
Join Date: Dec 2004
Location: Under a rock!
Posts: 116
Rep Power: 33
caesar will become famous soon enough
Default

aqwzsx : multumesc pentru remarca, fac si eu ce pot.

Orice script sau bucata de script e data ca exemplu si trebuie tratata ca atare, si nu pretind ca le stiu pe toate sau ca am dreptate intotdeauna.

Nu exista nici un raw pentru asta, e un simplu notice de la X. Doar daca te chinui sa numeri liniile sau ceva in genul, oricum nu cred ca isi are cazul sa te scarpini la urechea stanga cu mana dreapta.
caesar is offline   Reply With Quote
Old 25-12-2004, 22:28   #9 (permalink)
Administrator

aka aqwzsx
 
Join Date: Jun 2004
Posts: 827
Blog Entries: 126
Rep Power: 3
UniversaliA is on a distinguished road
Default

Remarca era pentru Gorapid, ca sa prevad floodul de intrebari de ce nu lucreaza scriptul, in loc sa caute singur raspuns Pentru ca el face asta deobicei. Da gorapid ?
UniversaliA is offline   Reply With Quote
Old 25-12-2004, 22:34   #10 (permalink)
Member
 
Kurupt's Avatar
 
Join Date: Jun 2004
Location: Hermannstadt
Age: 24
Posts: 108
Rep Power: 36
Kurupt will become famous soon enough
Send a message via Yahoo to Kurupt
Default da

da din xtuff al lui ceasar e luat bucata aceea de cod. ok o sa tin minte in viitor cand postez example din alte scripturi sa specific si autor si nu sa ma pun pe mine. ceasar tragi u de urechi k k.
__________________
Owner of #ro-tcl
Kurupt is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Star Wars Episod III : Revenge of the Sith AdrianK OFF TOPIC 5 30-05-2005 21:48


All times are GMT +3. The time now is 07:45.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.