| View previous topic :: View next topic |
| Author |
Message |
jeroen_005 Voice
Joined: 22 Jun 2008 Posts: 19
|
Posted: Sun Jun 22, 2008 7:54 am Post subject: Script Request |
|
|
I new at TCL and would to know if it was possibel to get some data of my site when requested.
It should work as followd:
User types "!il jeroen 005" -> TCL look for http://www.twor.be/g/irc/il_box.php?auser=jeroen%20005&buser=jeroen_005 -> give the data back as following: "Het IL van Jeroen_005 is Vrijgesteld."
As you see in TCL need to change the space into a _ and lookup for both nicknames with space and _. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Jun 22, 2008 10:17 pm Post subject: |
|
|
| Code: | # twor.be
package require http
setudef flag twor
bind pub - !il twor
proc twor {nick uhost handle chan tag} {
if {[lsearch -exact [channel info $chan] +twor] == -1} { return }
set query "http://www.twor.be/g/irc/il_box.php?auser=[string map {" " "%20"} $tag]&buser=[string map {" " "_"} $tag]"
# if you own the site, using this agent string will let you know in
# your weblogs how much bandwidth the bot consumes and how
# often attempts to scrape are made. Otherwise change to "mozilla"
set ua "Eggdrop twor.be script"
set http [::http::config -useragent $ua -useragent "utf-8"]
catch {set http [::http::geturl "$query" -timeout [expr 1000 * 5]]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
putserv "privmsg $chan :Socket Fout bij het openen van '$query'.. Het moet omlaag.. :("
return 0
}
if {[string equal -nocase [::http::status $http] "timeout"]} {
putserv "privmsg $chan :Connection is een time-out."
return 0
}
set html [::http::data $http]
::http::cleanup $http
if {[regexp {@@start(.+?)@@end} $html - user]} {
putserv "privmsg $chan :Het IL van \002[lindex [split $user "+"] 0]\002 is \002[lindex [split $user "+"] 1]\002."
return 1
} else {
putserv "privmsg $chan :Geen resultaat gevonden."
return 0
}
}
putlog "twor.be geladen." |
Enjoy
.chanset #yourchan +twor on partyline
!il <tag> afterwards in #yourchan
note: assumed the language used is dutch. If I am mistaken just correct that dutch to what you desire..heh _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
jeroen_005 Voice
Joined: 22 Jun 2008 Posts: 19
|
Posted: Tue Jun 24, 2008 11:18 am Post subject: |
|
|
correct it's dutch
I have tried the script but it has the following output:
| Code: | [17:15:26] <@Jeroen_005> !il jeroen 005
[17:15:26] <@TWOR_LOG> Het IL van |
|
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Tue Jun 24, 2008 2:12 pm Post subject: |
|
|
| Code: | # twor.be
package require http
setudef flag twor
bind pub - !il twor
proc twor {nick uhost handle chan tag} {
if {[lsearch -exact [channel info $chan] +twor] == -1} { return }
set query "http://www.twor.be/g/irc/il_box.php?auser=[string map {" " "%20"} $tag]&buser=[string map {" " "_"} $tag]"
# if you own the site, using this agent string will let you know in
# your weblogs how much bandwidth the bot consumes and how
# often attempts to scrape are made. Otherwise change to "mozilla"
set ua "Eggdrop twor.be script"
set http [::http::config -useragent $ua -useragent "utf-8"]
catch {set http [::http::geturl "$query" -timeout [expr 1000 * 5]]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
putserv "privmsg $chan :Socket Fout bij het openen van '$query'.. Het moet omlaag.. :("
return 0
}
if {[string equal -nocase [::http::status $http] "timeout"]} {
putserv "privmsg $chan :Verbinding is een time-out."
return 0
}
set html [::http::data $http]
::http::cleanup $http
regsub {(?:\n|\t|\v|\r)} $html "" html
if {[regexp {@@start(.+?)@@end} $html - user]} {
putserv "privmsg $chan :Het IL van \002[string trim [lindex [split $user "+"] 0]]\002 is \002[string trim [lindex [split $user "+"] 1]]\002."
return 1
} else {
putserv "privmsg $chan :Geen resultaat gevonden."
return 0
}
}
putlog "twor.be geladen." |
This works. Didn't notice you had carriage returns embedded. Newlines, Carriage returns, Tabs, and Vertical Tabs are now stripped prior to parsing.
| Quote: | <speechles> !il jeron 005
<sp33chy> Het IL van jeron 005 is Onbekend (Geen account gevonden op onze website).
<speechles> !il jeroen 005
<sp33chy> Het IL van Jeroen_005 is Vrijgesteld. |
_________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
jeroen_005 Voice
Joined: 22 Jun 2008 Posts: 19
|
Posted: Wed Jun 25, 2008 7:37 am Post subject: |
|
|
Okey maybe a stupid question but how can i add an error message when a user don't define a nickname?
Somthing like: !il -> Gelieve een nickname of user id op te geven.
I have tryed something like if {$user == $null} but that doesn't works :'( |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Jun 25, 2008 8:54 am Post subject: |
|
|
| Code: | ... rest of code goes above here ...
if {[lsearch -exact [channel info $chan] +twor] == -1} { return }
if {$tag == ""} {
putserv "privmsg $chan :Gelieve een nickname of user id op te geven."
return 0
}
set query "http://www.twor.be/g/irc/il_box.php?auser=[string map {" " "%20"} $tag]&buser=[string map {" " "_"} $tag]"
... rest of code continues ...
|
See what I added? Thats all you should need _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
jeroen_005 Voice
Joined: 22 Jun 2008 Posts: 19
|
Posted: Wed Jun 25, 2008 8:56 am Post subject: |
|
|
oooh thnxs
Speechles FTW |
|
| Back to top |
|
 |
jeroen_005 Voice
Joined: 22 Jun 2008 Posts: 19
|
Posted: Wed Jun 25, 2008 11:03 am Post subject: |
|
|
Okey i have changed the script in the following it doesnt work anymore when i typ "!il ajax ruub" if you type 'il ajax_ruub' it works. does anyone know how this comes?
| Code: | # twor.be
package require http
setudef flag twor
bind pub - !il twor
proc twor {nick uhost handle chan tag} {
if {[lsearch -exact [channel info $chan] +twor] == -1} { return }
if {$tag == ""} {
putserv "privmsg $chan :\002FOUT:\002 Gelieve een nickname of userid op te geven."
return 0
}
set query "http://www.twor.be/g/irc/il_box.php?auser=[string map {" " "%20"} $tag]&buser=[string map {" " "_"} $tag]&cuser=[string map {"_" "%20"} $tag]"
# if you own the site, using this agent string will let you know in
# your weblogs how much bandwidth the bot consumes and how
# often attempts to scrape are made. Otherwise change to "mozilla"
set ua "Eggdrop twor.be script"
set http [::http::config -useragent $ua -useragent "utf-8"]
catch {set http [::http::geturl "$query" -timeout [expr 1000 * 5]]} error
if {[string match -nocase "*couldn't open socket*" $error]} {
putserv "privmsg $chan :\002FOUT:\002 :Socket Fout bij het openen van '$query'.. Probeer het zometeen nog een keer."
return 0
}
if {[string equal -nocase [::http::status $http] "timeout"]} {
putserv "privmsg $chan :\002FOUT:\002 De verbinding met de server is mislukt. Probeer het zometeen nog een keer."
return 0
}
set html [::http::data $http]
::http::cleanup $http
regsub {(?:\n|\t|\v|\r)} $html "" html
if {[regexp {@@start(.+?)@@end} $html - user]} {
putserv "privmsg $chan :Het IL van \002[string trim [lindex [split $user "+"] 0]]\002 is \002[string trim [lindex [split $user "+"] 1]]\002."
putserv "privmsg $chan :\002STATS: Gemiddelde:\002 [string trim [lindex [split $user "+"] 2]], \002Events:\002 [string trim [lindex [split $user "+"] 3]], \002Max:\002 [string trim [lindex [split $user "+"] 4]]. (afgelopen 31 dagen)"
return 1
} else {
putserv "privmsg $chan :\002FOUT:\002 De server kan uw vraag momenteel niet verwerken. Probeer het zometeen nog een keer."
return 0
}
}
putlog "Module loaded: SCRIPT: IL Box" |
|
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Jun 25, 2008 4:05 pm Post subject: |
|
|
| Code: | set query "http://www.twor.be/g/irc/il_box.php?auser=[string map {" " "%20"} $tag]&buser=[string map {" " "_"} $tag]&cuser=[string map {"_" "%20"} [string map {" " "_"} $tag]]"
#defeat-word-wrap############################################################################################################################################################### |
Fix this line to look _exactly_ like mine does above. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
|