r00t-err0r

fbold

May 25th, 2012
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 2.61 KB | None | 0 0
  1. # Command !pic2fb
  2.  
  3. # Usage example: !pic2fb http://a7.sphotos.ak.fbcdn.net/hphotos-ak-snc7/417229_270923126316188_216952361713265_609445_1510413814_n.jpg
  4.  
  5. # Export: Facebook -=> http://www.facebook.com/phone.use.flashlight -=> I use my phone as a flashlight, and hit random buttons to keep it lit | Facebook
  6.  
  7. # Coded by tik-tak & munZe
  8.  
  9. bind pub - !pic2fb pub_fb
  10. bind pub - !title pub_fb
  11. bind pubm - *fbcdn* pub_gfb
  12.  
  13. package require http
  14.  
  15. proc pub_fb {nick mask hand chan url} {
  16.     regsub {^(?:http://)*} $url {http://} url
  17.     if { ![regexp {.+fbcdn.+} $url] } {
  18.     set fburl $url
  19.     set titletxt "Title"
  20.     set page [ ::http::geturl $fburl ]
  21.     set page [ ::http::data [ ::http::geturl $fburl -strict 0 ] ]
  22.     regexp {<title>(.*)</title>} $page match title
  23.     set title [ encoding convertto utf-8 $title ]
  24.     } else {
  25.     set id [lindex [split $url _] end-3 ]
  26.         set fbid "http://www.facebook.com/profile.php?id=$id"
  27.     set titletxt "Facebook"
  28.     set page [ ::http::geturl $fbid ]
  29.     if { [ dict exists [array get $page] meta Location ] == 1  } {
  30.         set fburl [dict get [array get $page] meta Location]    
  31.         set page [ ::http::data [ ::http::geturl $fburl -strict 0 ] ]
  32.     }
  33.     regexp {<title>(.*)</title>} $page match title
  34.     if { [ info exists title ] == 0 } {
  35.         puthelp "PRIVMSG $chan Can't read page title."
  36.     } else {
  37.         set title [ encoding convertto utf-8 $title]
  38.         set fburl [ encoding convertto utf-8 $fburl] }
  39.  
  40.         puthelp "PRIVMSG $chan \002$titletxt -=>\002 \037$fburl\037 -=> \002$title\002"
  41.     }
  42.  
  43. }
  44.  
  45. proc pub_gfb {nick mask hand chan url} {
  46.     regsub {^(?:http://)*} $url {http://} url
  47.     if { ![regexp {.+fbcdn.+} $url] } {
  48.     set fburl $url
  49.     set titletxt "Title"
  50.     set page [ ::http::geturl $fburl ]
  51.     set page [ ::http::data [ ::http::geturl $fburl -strict 0 ] ]
  52.     regexp {<title>(.*)</title>} $page match title
  53.     set title [ encoding convertto utf-8 $title]
  54.     } else {
  55.     set id [lindex [split $url _] end-3 ]
  56.         set fbid "http://www.facebook.com/profile.php?id=$id"
  57.     set titletxt "Facebook"
  58.     set page [ ::http::geturl $fbid ]
  59.     if { [ dict exists [array get $page] meta Location ] == 1  } {
  60.         set fburl [dict get [array get $page] meta Location]    
  61.         set page [ ::http::data [ ::http::geturl $fburl -strict 0 ] ]
  62.     }
  63.     regexp {<title>(.*)</title>} $page match title
  64.     if { [ info exists title ] == 0 } {
  65.         puthelp "PRIVMSG $chan Can't read page title."
  66.     } else {
  67.         set title [ encoding convertto utf-8 $title]
  68.         set fburl [ encoding convertto utf-8 $fburl] }
  69.  
  70.         puthelp "PRIVMSG $chan \002$titletxt -=>\002 \037$fburl\037 -=> \002$title\002"
  71.     }
  72.  
  73. }
  74.  
  75.     putlog "Picture 2 Facebook is loaded nad coded by tik-tak & munZe"
Advertisement
Add Comment
Please, Sign In to add comment