Advertisement
denahv

Untitled

Apr 9th, 2011
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. # Script to grab titles from webpages - Copyright C.Leonhardt (rosc2112 at yahoo com) Aug.11.2007
  2. # http://members.dandy.net/~fbn/urltitle.tcl.txt
  3. # Loosely based on the tinyurl script by Jer and other bits and pieces of my own..
  4.  
  5. ################################################################################################################
  6.  
  7. # Usage:
  8.  
  9. # 1) Set the configs below
  10. # 2) .chanset #channelname +urltitle ;# enable script
  11. # 3) .chanset #channelname +logurltitle ;# enable logging
  12. # Then just input a url in channel and the script will retrieve the title from the corresponding page.
  13.  
  14. # When reporting bugs, PLEASE include the .set errorInfo debug info!
  15. # Read here: http://forum.egghelp.org/viewtopic.php?t=10215
  16.  
  17. ################################################################################################################
  18.  
  19. # Configs:
  20.  
  21. set urltitle(ignore) "bdkqr|dkqr" ;# User flags script will ignore input from
  22. set urltitle(pubmflags) "-|-" ;# user flags required for channel eggdrop use
  23. set urltitle(length) 5 ;# minimum url length to trigger channel eggdrop use
  24. set urltitle(delay) 1 ;# minimum seconds to wait before another eggdrop use
  25. set urltitle(timeout) 60000 ;# geturl timeout (1/1000ths of a second)
  26.  
  27. ################################################################################################################
  28. # Script begins:
  29.  
  30. package require http ;# You need the http package..
  31. set urltitle(last) 111 ;# Internal variable, stores time of last eggdrop use, don't change..
  32. setudef flag urltitle ;# Channel flag to enable script.
  33. setudef flag logurltitle ;# Channel flag to enable logging of script.
  34.  
  35. set urltitlever "0.01a"
  36. bind pubm $urltitle(pubmflags) {*://*} pubm:urltitle
  37. proc pubm:urltitle {nick host user chan text} {
  38. global urltitle
  39. if {([channel get $chan urltitle]) && ([expr [unixtime] - $urltitle(delay)] > $urltitle(last)) && \
  40. (![matchattr $user $urltitle(ignore)])} {
  41. foreach word [split $text] {
  42. if {[string length $word] >= $urltitle(length) && \
  43. [regexp {^(f|ht)tp(s|)://} $word] && \
  44. ![regexp {://([^/:]*:([^/]*@|\d+(/|$))|.*/\.)} $word]} {
  45. set urltitle(last) [unixtime]
  46. set urtitle [urltitle $word]
  47. if {[string length $urtitle]} {
  48. puthelp "PRIVMSG $chan :\002Title:\002 $urtitle"
  49. }
  50. break
  51. }
  52. }
  53. }
  54. if {[channel get $chan logurltitle]} {
  55. foreach word [split $text] {
  56. if {[string match "*://*" $word]} {
  57. putlog "<$nick:$chan> $word -> $urtitle"
  58. }
  59. }
  60. }
  61. # change to return 0 if you want the pubm trigger logged additionally..
  62. return 1
  63. }
  64.  
  65. putlog "Url Title Grabber $urltitlever (rosc) script loaded.."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement