This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Script Request

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

Script Request

Post by jeroen_005 »

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?aus ... 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 _.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# 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
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

Post by jeroen_005 »

correct it's dutch

I have tried the script but it has the following output:

Code: Select all

[17:15:26] <@Jeroen_005> !il jeroen 005
[17:15:26] <@TWOR_LOG> Het IL van
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# 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.
<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.
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

Post by jeroen_005 »

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 :'(
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

... 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
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

Post by jeroen_005 »

oooh thnxs :D

Speechles FTW :D
j
jeroen_005
Voice
Posts: 19
Joined: Sun Jun 22, 2008 7:47 am

Post by jeroen_005 »

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: Select all

# 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"
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

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.
Post Reply