botlending forum  

Go Back   botlending forum > Eggdrop & TCL > Tcl scripting

Tcl scripting Tcl scripting related questions

Reply
 
LinkBack Thread Tools Display Modes
Old 22-08-2005, 21:23   #11 (permalink)
Administrator

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

Nu nu vom ajuta oamenii, facand pentru ei ceea, ce ei ar putea face singuri :)

Abraham Lincoln
UniversaliA is offline   Reply With Quote
Old 23-08-2005, 00:06   #12 (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

You can lead a man to knowledge, but you can't make him think!

Poti indruma un om spre cunoastere dar nu il poti face sa gandeasca!

am uitat autorul.. oricum, ideea ramane.
caesar is offline   Reply With Quote
Old 23-08-2005, 16:44   #13 (permalink)
TCB & Ratings projects Member, #Mythic representative
 
arcade's Avatar
 
Join Date: Jun 2004
Location: In fatza calculatorului!!
Age: 19
Posts: 218
Rep Power: 37
arcade is on a distinguished road
Send a message via Yahoo to arcade
Default

frumos spus
Interesanta chestia cu regusb si cu cititul commands.doc crede-ma k le-am citit si inca mai citesc la ele dar mai am pana sa reusesc sa si inteleg cum sa le fac sa se lege intr-un script. O sa modific ceea ce mi-ai scos in evidenta.
Merci
Dak mai gasesti cate ceva mi-ar prinde bine sa ma ajutati un pik
arcade is offline   Reply With Quote
Old 24-08-2005, 14:15   #14 (permalink)
TCB & Ratings projects Member, #Mythic representative
 
arcade's Avatar
 
Join Date: Jun 2004
Location: In fatza calculatorului!!
Age: 19
Posts: 218
Rep Power: 37
arcade is on a distinguished road
Send a message via Yahoo to arcade
Lightbulb In sfarsit

Gata am reusit sa ii dau de cap. Va anunt oficial k mere si va dau codul complet sa vedeti dak e ceva de modificat.
Code:
if {![info exists greetfile]} {
   set greetsetfile "greetset"
}
bind pub - !greet pub_greet
bind pub - `greet pub_greet
bind pub - .greet pub_greet
bind join - *!*@* set_greet
bind msg - greet greet_set
bind dcc - greet greet_set_dcc


proc greet:replace { nick chan line } {
  global botnick
  if {[string match "*%nick%*" $line]} { regsub -all %nick% $line $nick line }
  if {[string match "*%chan%*" $line]} { regsub -all %chan% $line $chan line }
  return $line
}


proc set_greet {nick uhost hand chan} {
  global random_greet setgreet botnick greet:replace

 if {$botnick != $nick} {
  if [channel get $chan greet] {
  if {[info exists setgreet([string tolower $chan])] && [lindex $setgreet([string tolower $chan]) 0] != ""} {
    set i $setgreet([string tolower $chan]) 
    puthelp "NOTICE $nick :[greet:replace $nick $chan $i]"

   } {

     foreach i [array names random_greet] {
        if {[lsearch -exact [string tolower [channels]] [string tolower $i]] != -1} {
            if {[lindex $random_greet([string tolower $i]) 0] != ""} {
              set greet [lindex $random_greet($i) [rand [llength $random_greet($i)]]]
                if {$chan == $i} {
                  puthelp "NOTICE $nick :$greet
                }
            }
}
        } {
            unset random_greet($i)
          }
      }
   }
 }
}

proc greet_show_pub {nick uhost hand channel arg} {
  global random_greet setgreet botnick 


  if {![matchattr $hand m|m $channel]} {
     putserv "PRIVMSG $channel :Sorry, you are not authorized to use this command."
     return 0
  }

  if {[info exists setgreet([string tolower $channel])] && [lindex $setgreet([string tolower $channel]) 0] != ""} {
    set i $setgreet([string tolower $channel]) 
       putserv "PRIVMSG $channel :\002Greet Set to:\002  $i"
       putserv "PRIVMSG $channel :Use GREET SET $channel OFF if you want to turn it off."
   
    }
    putserv "PRIVMSG $channel :Type \002/msg $botnick greet HELP\002 for help."

  return 1
}


proc greet_show {nick uhost hand arg} {
  global random_greet setgreet botnick 

  set channel [lindex $arg 0]
  if {$channel == ""} {
     putserv "PRIVMSG $nick :Usage: greet <channel>"
     return 0
  }

    if {[lsearch -exact [string tolower [channels]] [string tolower $channel]] == -1} {
     putserv "PRIVMSG $nick :I am not on ${channel}."
     return 0
  }

    if {![matchattr $hand m|m $channel]} {
     putserv "PRIVMSG $nick :Sorry, you are not authorized to use this command."
     return 0
  }

  if {[info exists setgreet([string tolower $channel])] && [lindex $setgreet([string tolower $channel]) 0] != ""} {
    set i $setgreet([string tolower $channel]) 
       putserv "PRIVMSG $nick :\002Greet Set to:\002  $i"
       putserv "PRIVMSG $nick :Use GREET SET $channel OFF if you want to turn it off."
   
    }
  

  putserv "PRIVMSG $nick :Type \002/msg $botnick greet HELP\002 for help."

  return 1
}

proc greet_show_dcc {hand idx arg} {
  global random_greet setgreet botnick 

  set channel [lindex $arg 0]
  if {$channel == ""} {
     putidx $idx "Usage: greet <channel>"
     return 0
  }

  
  if {[lsearch -exact [string tolower [channels]] [string tolower $channel]] == -1} {
     putidx $idx "I am not on ${channel}."
     return 0
  }

  if {![matchattr $hand m|m $channel]} {
     putidx $idx "Sorry, you are not authorized to use this command."
     return 0
  }

  putidx $idx "Greets for \002$channel\002:"

  if {[info exists setgreet([string tolower $channel])] && [lindex $setgreet([string tolower $channel]) 0] != ""} {
    set i $setgreet([string tolower $channel]) 
       putidx $idx "\002Greet Set to:\002  $i"
       putidx $idx "Use GREET SET $channel OFF if you want to turn it off."
       }


 
  putidx $idx "Type \002.greet HELP\002 for help."

  return 1
}

proc greet_set_pub {nick uhost hand channel arg} {
  global setgreet

  if {![matchattr $hand m|m $channel]} {
     putserv "PRIVMSG $channel :Sorry, you are not authorized to use this command."
     return 0
  }
  if {[string tolower [lindex $arg 1]] != "-off"} {
    putserv "PRIVMSG $channel :Greet set to: [lrange $arg 1 end]"
    set setgreet([string tolower $channel]) [lrange $arg 1 end]
  } {
    putserv "PRIVMSG $channel :Greet set off $channel"
    set setgreet([string tolower $channel]) [lrange "" 1 end]
  }
  
  putlog "Writing greets file..."
  greet_write
  
  return 1

}


proc greet_set {nick uhost hand arg} {
  global setgreet

  set channel [lindex $arg 1]

  if {$channel == ""} {
     putserv "PRIVMSG $nick :Usage: GREET SET <channel> <greet>"
     putserv "PRIVMSG $nick :Or:    GREET SET <channel> OFF"
     return 0
  }

  if {[lsearch -exact [string tolower [channels]] [string tolower $channel]] == -1} {
     putserv "PRIVMSG $nick :I am not on ${channel}."
     return 0
  }

  if {![matchattr $hand m|m $channel]} {
     putserv "PRIVMSG $nick :Sorry, you are not authorized to use this command."
     return 0
  }

  if {[string tolower [lindex $arg 1]] != "-off"} {
    putserv "PRIVMSG $nick :Greet set to: [lrange $arg 1 end]"
    set setgreet([string tolower $channel]) [lrange $arg 1 end]
  } {
    putserv "PRIVMSG $nick :Greet set off $channel"
    set setgreet([string tolower $channel]) [lrange "" 1 end]
  }
  
  putlog "Writing greets file..."
  greet_write
  
  return 1

}

proc greet_set_dcc {hand idx arg} {
  global setgreet

  set channel [lindex $arg 2]

  if {$channel == ""} {
     putidx $idx "Usage: GREET SET <channel> <greet>"
     putidx $idx "Or:    GREET SET <channel> OFF"
     return 0
  }

  if {[lsearch -exact [string tolower [channels]] [string tolower $channel]] == -1} {
     putidx $idx "I am not on ${channel}."
     return 0
  }

  if {![matchattr $hand m|m $channel]} {
     putidx $idx "Sorry, you are not authorized to use this command."
     return 0
  }

  if {[string tolower [lindex $arg 2]] != "-off"} {
    putidx $idx "Greet set to: [lrange $arg 1 end]"
    set setgreet([string tolower $channel]) [lrange $arg 2 end]
  } {
    putidx $idx "Greet set off $channel"
    set setgreet([string tolower $channel]) [lrange "" 2 end]
  }
  
  
  putlog "Writing greets file..."
  greet_write
  
  return 1

}
proc greet_load {} {
   global random_greet setgreet greetfile greetsetfile

   if {[info exists random_greet]} {unset random_greet}
   if {[catch {set fd [open $greetfile r]}] != 0} {return 0}
   while {![eof $fd]} {
      set inp [gets $fd]
      if {[eof $fd]} {break}
      if {[string trim $inp " "] == ""} {continue}
      set channel [lindex $inp 0]
      lappend random_greet([string tolower $channel]) [lrange $inp 1 end]
   }
   close $fd

   if {[info exists setgreet]} {unset setgreet}
   if {[catch {set fd [open $greetsetfile r]}] != 0} {return 0}
   while {![eof $fd]} {
      set inp [gets $fd]
      if {[eof $fd]} {break}
      if {[string trim $inp " "] == ""} {continue}
      set channel [lindex $inp 0]
      lappend setgreet([string tolower $channel]) [lrange $inp 1 end]
   }
   close $fd



   return 1
}

proc greet_write {} {
   global greetfile random_greet setgreet greetsetfile

   set fd [open $greetfile w]
   foreach channel [array names random_greet] {
      if {[lsearch -exact [string tolower [channels]] [string tolower $channel]] != -1} {
         if {[lindex $random_greet([string tolower $channel]) 0] != ""} {
            foreach i $random_greet([string tolower $channel]) {
               puts $fd "$channel $i"
            }
         }
      }
   }
   close $fd

   set fd [open $greetsetfile w]
   foreach channel [array names setgreet] {
      if {[lsearch -exact [string tolower [channels]] [string tolower $channel]] != -1} {
         if {[lindex $setgreet([string tolower $channel]) 0] != ""} {
            set i $setgreet([string tolower $channel]) 
               puts $fd "$channel $i"
         }
      }
   }
   close $fd

   return 1
}


proc msg_greet {nick uhost hand arg} {
  switch [string tolower [lindex $arg 0]] {
    "set"       {set r [greet_set $nick $uhost $hand $arg]}
    "help"      {set r [greet_help $nick $uhost $hand $arg]}
    default     {set r [greet_show $nick $uhost $hand $arg]}
  }
  return $r
}

proc pub_greet {nick uhost hand channel arg} {
  switch [string tolower [lindex $arg 0]] {
    "set"       {set r [greet_set_pub $nick $uhost $hand $channel $arg]}
    "help"      {set r [greet_help_pub $nick $uhost $hand $channel $arg]}
    default     {set r [greet_show_pub $nick $uhost $hand $channel $arg]}
  }
  return $r
}


proc dcc_greet {hand idx arg} {
  switch [string tolower [lindex $arg 0]] {
    "set"       {set r [greet_set_dcc $hand $idx $arg]}
    "help"      {set r [greet_help_dcc $hand $idx $arg]}
    default     {set r [greet_show_dcc $hand $idx $arg]}
  }
  return $r
}


greet_load

if {![info exists set_greet_running] && ![info exists random_greet] && ![info exists setgreet]} {
  set set_greet_running 1
}
PS: Daca gasiti greseli elementare sa nu va mire pentru ca am facut si eu ceva modificari.

Last edited by arcade; 24-08-2005 at 14:17. Reason: Am uitat sa mentionez ceva
arcade is offline   Reply With Quote
Old 24-08-2005, 16:33   #15 (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

vad ca ai uitat sa te uiti peste subst cum ti-am sugerat. :P
Nu e nevoie de *!*@* in bind join - *!*@* set_greet, merge si cu *

La greet:replace vad ca apelezi global botnick dar nu il folosesti deloc.

De if {$botnick != $nick} { ti-am mai zis odata, vad ca tot nu ai bagat la cap...
caesar is offline   Reply With Quote
Old 24-08-2005, 18:53   #16 (permalink)
TCB & Ratings projects Member, #Mythic representative
 
arcade's Avatar
 
Join Date: Jun 2004
Location: In fatza calculatorului!!
Age: 19
Posts: 218
Rep Power: 37
arcade is on a distinguished road
Send a message via Yahoo to arcade
Default

Scuze da eu am editat asta offline si nu am avut acces la forum asa k am uitat de ce ai zis u.
Cat despre subst am incercat si imi zicea ceve k nu e bun -all dupa el
Tot cu regsub a mers.
O sa mai incerc acum
arcade is offline   Reply With Quote
Old 25-08-2005, 22:58   #17 (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

Pai nu merge ca el nu are nici un -all.. vezi manualul..
caesar is offline   Reply With Quote
Old 26-08-2005, 17:13   #18 (permalink)
TCB & Ratings projects Member, #Mythic representative
 
arcade's Avatar
 
Join Date: Jun 2004
Location: In fatza calculatorului!!
Age: 19
Posts: 218
Rep Power: 37
arcade is on a distinguished road
Send a message via Yahoo to arcade
Default

Da da da m-am uitat da nu prea pricep exemplele cat despre descriere e de inteles in afara de sintaxa. Sa luam acest exemplu:
Code:
set a 44
subst {xyz {$a}}

returns ``xyz {44}'', not ``xyz {$a}'' and the script
Din exemplul asta eu inteleg k botul listeaza xyz {44}, dar eu vreau sa imi inlocuiasca xyz cu $a adica cu 44.
Cum fac?
arcade is offline   Reply With Quote
Old 26-08-2005, 21:53   #19 (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

set linie {variabila $nick si variabila $chan}
set msg [subst $linie]

-nob = -nobackslashes = nu te lasa sa bagi bold, underline, etc. chestii care au \ in ele.
- noc = -nocommand = nu te lasa sa bagi comenzi in ce inlocuieste el. De ex.

set linie set linie {variabila $nick si variabila $chan rezultat calcul [expr 1 +2]}
set msg [subst -noc $linie] o sa iti inlocuiasca $nick si $chan cu ce ai tu unde aplezi subst-ul si nu o sa iti faca calculul ala, doar o sa iti spuna calcul [expr 1 +2]. De ex.

$nick = ion si $chan = #canal .. cand face substitutia msg = variabila ion si variabila #canal rezultat calcul [expr 1 +2].. sper ca ai inteles ceva
caesar is offline   Reply With Quote
Old 27-08-2005, 12:22   #20 (permalink)
TCB & Ratings projects Member, #Mythic representative
 
arcade's Avatar
 
Join Date: Jun 2004
Location: In fatza calculatorului!!
Age: 19
Posts: 218
Rep Power: 37
arcade is on a distinguished road
Send a message via Yahoo to arcade
Default

De fapt chiar am inteles. Nu mi-a dat prin cap sa niciodata sa o folosesc asa.
O sa incerc.
arcade 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
[Correct script] Eroare Botnet [Welcome,Leave,Greet] SoLLo Tcl scripting 1 24-05-2007 19:07
[Correct script] HELP - greet :) vR|Ar Tcl scripting 5 07-04-2007 16:11
Greet AdrianK a&a light script 0 28-02-2007 23:05
Exista greet la join? BizZu #a&a 3 27-09-2005 18:29


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


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