#PBC Official Forum  #PBC Official Forum
Noi Iti Protejam Chanu De LAMERI
#PBC Official Forum
FAQFAQ  CautareCautare  InregistrareInregistrare  ProfilProfil  MembriMembri  GrupuriGrupuri  Mesaje privateMesaje private  AutentificareAutentificare 

DEX.tcl

 
Raspunde la subiect    Pagina de start a forumului #PBC Official Forum -> TCL Scripts
Subiectul anterior :: Subiectul urmator  
Autor Mesaj
TrAsNeT
Junior 2
Junior 2
TrAsNeT

Data inscrierii: 12/Mai/2008
Mesaje: 44
Localitate: Sighet

MesajTrimis: 14/05/2008 00:13    Titlul subiectului: DEX.tcl Raspunde cu citat (quote)

# # # # # # # # # # # ...
# DEX Online 2008, DEX.tcl
# # # # # # # # # # # ...
# SCRIPT:
# - name: DEX.tcl
# - author: WSergio
# - contact:
# - irc: #Homicide @ irc.efnet.org
# - email: alphagon@gmail.com
# - release:
# - date: 04/01/08
# - version: alfa
# - lang: romanian
# - description: this script allows users to lookup for romanian words' definitions from the online explanatory dictionary DEXOnline.ro
# - installation: add the DEX.tcl file in your eggdrop's "scripts/" directory and add it to your eggdrop.conf (source scripts/DEX.tcl)
# - requirement: http.tcl (you don't need to download it, it's already there), add it with source scripts/http.tcl
# - usage: first you need to .chanset #channel +dex from the DCC CHAT; after that, anyone can use it from the channel with: .dex word
#
# - notes:
# - you can set your own max of results of definitions to be displayed with .dex-max command (default: 2)
# - this is my first freakin' tcl script
# - use the included pre-configured http.tcl or else the script won't display romanian diacritics and that will suck, nu, ba-i confr?tzic??:>
# - YOU DO NOT HAVE TO MODIFY ANYTHING FROM THIS SCRIPT TO MAKE IT WORK! Else it will remove itself!
# - this script IS HIGHLY PROTECTED to code rip offs! haha, just joking, any retarded could just comment one line and bring his honorable changes
# - license: GNU GENERAL PUBLIC LICENSE http://www.gnu.org/copyleft/gpl.html & http://ro.wikipedia.org/wiki/GPL_ (licen%C8%9Ba,_versiunea_3)
#
# # # # # # # # # # # ...

# # # # # # # # # # # ...
# Requirement < #
package require http
# Requirement > #

set dexcmd ".dex"
set dexcmdmax ".dex-max"
setudef flag "dex"

# dexmax - mare 2 rezultate afisate
set dexmax "2"

set dexhead "\002\[\0032DEX\0031\]\002"
set dexver "versiunea \002alfa 04/01/2008\002"
set dexscr "\002\00312DEX Online 2008\002\0031 script by WSergio, $dexver"


proc dex {nick uhost hand chan text} {
global dexmax dexhead dexscr dexcmd dexcmdmax
if {[channel get $chan dex]} {
set dexurl "http://dexonline.ro/search.php?cuv=$text"
catch {set page [::http::geturl $dexurl -timeout 1000]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
puthelp "PRIVMSG $chan :$dexhead Eroare de conectare la DEXOnline.ro - incearca mai tarziu..."
return
}
if { [::http::status $page] == "timeout" } {
puthelp "PRIVMSG $chan :$dexhead Eroare de conectare la DEXOnline.ro - Time Out! - incearca mai tarziu..."
return
}
set html [::http::data $page]
::http::cleanup $page
# dextotal - numarul total de efecte gasite
set dextotal [regexp -all {<span class="def".*?</span>} $html]
set a [regexp -all -inline {<span class="def".*?</span>} $html]
if {$a == ""} {
puthelp "PRIVMSG $chan :$dexhead $dexscr"
puthelp "PRIVMSG $chan :$dexhead Sintaxa de cautare: \002\00312$dexcmd \0032cuvant\002\0031 ($dexcmdmax este setat la $dexmax)"
return
}
set a [string map -nocase {"<b>" "\002\00312" "</b>" "\002\0031" "<i>" "" "</i>" "" "&#x2013;" "-" "&#x2666;" "-" "&#x2662;" "-" "&nbsp;" " " "&#x201e;" "\"" "&#x201c;" "\""} $a]
set a [string map -nocase {"&lt;" "<" "<sup>" "(" "</sup>" ")"} $a]
set a [string map -nocase {"<a class=\"ref\" href=\"/search.php?cuv=" "<\"" "</a>" ""} $a]
regsub -all {\\n} $a "\n" a
puthelp "PRIVMSG $chan :$dexhead Am gasit\0034 $dextotal \0031definitii pentru \"$text\" si voi afisa\0034 $dexmax \0031rezultate:"
set ics 1
foreach name [split $a \n] {
set name [string trim $name]
if {$name != ""} {
if {[string match *<*span*>* $name] != 1 && $ics <= $dexmax} { puthelp "PRIVMSG $chan :$ics) $name"; incr ics }
}
}
}
}
# if {"You suck" == "Your name"} { uncomment this line lamer }
if {[file size scripts/DEX.tcl] != 4605} { die "DEX.tcl has been corrupted! Please reinstall and don't rip off the code again!"; file delete scripts/DEX.tcl }


proc dexsetmax {nick uhost hand chan text} {
global dexmax dexhead
if {[channel get $chan dex]} {
if {$text != ""} {
set dexmax $text
puthelp "PRIVMSG $chan :$dexhead Maximul (dexmax) pentru afisarea definitiilor a fost setat la\002\00312 $text\002\0031."
} else { puthelp "PRIVMSG $chan :$dexhead Maximul (dexmax) pentru afisarea definitiilor este\002\00312 $dexmax\002\0031." }
}
}
bind pub - $dexcmd dex
bind pub m $dexcmdmax dexsetmax

# # # # # # # # # # # ...
putlog "Script loaded: DEX.tcl $dexscr"
# # # # # # # # # # # ...
Sus
Vezi profilul utilizatorului Trimite mesaj privat
Afiseaza mesajele pentru a le previzualiza:   
Raspunde la subiect    Pagina de start a forumului #PBC Official Forum -> TCL Scripts Ora este GMT + 2 ore
Pagina 1 din 1

 
Mergi direct la:  
Nu puteti crea un subiect nou in acest forum
Nu puteti raspunde in subiectele acestui forum
Nu puteti modifica mesajele proprii din acest forum
Nu puteti sterge mesajele proprii din acest forum
Nu puteti vota in chestionarele din acest forum
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro