DoctorD90

PBin2TclH.tcl 1.4.0

May 11th, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 3.22 KB | None | 0 0
  1. ### PBin2TclH.tcl 1.4.0 ME5hHLZn
  2.  
  3. #SUGGESTED
  4. # PBinSrc.tcl fMrtKqyq
  5. # TCLLoader.tcl smApj15u
  6.  
  7. #LICENSE
  8. # Copyright © 2012 - 2013 Alberto Dietze "DoctorD90"
  9. #
  10. #    This program is free software: you can redistribute it and/or modify
  11. #    it under the terms of the GNU General Public License as published by
  12. #    the Free Software Foundation, either version 3 of the License, or
  13. #    (at your option) any later version.
  14. #
  15. #    This program is distributed in the hope that it will be useful,
  16. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. #    GNU General Public License for more details.
  19. #
  20. #    You should have received a copy of the GNU General Public License
  21. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  22. #
  23. # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
  24.  
  25. #PATERNITY
  26. #Coder: DoctorD90
  27. #Network: irc.OnlineGamesNet.net
  28. #Chan: #eHito
  29. #Script's List: www.EggTcl.tk
  30. #
  31. #Thanks to guys on #egghelp on irc.freenode.net
  32. #Special thanks to Thommey
  33.  
  34. #PURPOSE
  35. #Transfering text from pastebin.com to tclhelp.net.
  36.  
  37. #USAGE
  38. #Write pastebin.com's urls in chan or query, and
  39. #bot will give back the paste.tclhelp.net's urls.
  40. #Bot will detect links automatically or trougth a command
  41. #according with settings.
  42.  
  43. #SETTINGS
  44. #Set how script detects pastebin.com's urls;
  45. #0: Automatically, in all line; 1: Cmds;
  46. set pb2tclh(ai) "0"
  47. #Set flag of allowed people to use script in chan.
  48. set pb2tclh(pflag) "-"
  49. #Set flag of allowed people to use script in query.
  50. set pb2tclh(qflag) "-"
  51. #Set public command to detects pastebin.com's urls.
  52. set pb2tclh(pcmd) "!pastebin"
  53. #Set query command to detects pastebin.com's urls.
  54. set pb2tclh(qcmd) ".pastebin"
  55.  
  56.  
  57. ### DON'T EDIT ANYTHING BELOW ###
  58.  
  59. package require http
  60.  
  61. if {[string is integer -strict $pb2tclh(ai) && $pb2tclh(ai) >= "0" && $pb2tclh(ai) < "2"} {
  62.   if {$pb2tclh(ai) == "0"} {
  63.     set pb2tclh(pchk) "*pastebin.com/*"
  64.     set pb2tclh(qchk) "*pastebin.com/*"
  65.   }
  66.   if {$pb2tclh(ai) == "1"} {
  67.     set pb2tclh(pchk) "$pb2tclh(pcmd) *pastebin.com/*"
  68.     set pb2tclh(qchk) "$pb2tclh(qcmd) *pastebin.com/*"
  69.   }
  70. } else {
  71.   putlog "PBin2TclH.tcl ERROR: Wrong detecting setting."
  72. }
  73.  
  74. bind pubm $pb2tclh(pflag) $pb2tclh(qchk) pubm_pb2tclh
  75. proc pubm_pb2tclh {nick uhost hand chan text} {
  76.   pb2tclh_paster $chan $text
  77. }
  78.  
  79. bind msgm $pb2tclh(qflag) $pb2tclh(qchk) msgm_pb2tclh
  80. proc msgm_pb2tclh {nick uhost hand text} {
  81.   pb2tclh_paster $chan $text
  82. }
  83.  
  84. proc pb2tclh_paster {target text} {
  85.   set ids [lsearch -all -nocase -inline [split $text] "*pastebin.com/*" ]
  86.   if {![string length $ids]} {return}
  87.   foreach pbinid [split $ids] {
  88.     if {[regexp -nocase {(pastebin.com/[\d\w-]{8})} $pbinid link]} {
  89.       set code [http::data [set Token [http::geturl "http://pastebin.com/raw.php?i=[lindex [split $link /] end]" -timeout "30000"]]]
  90.       http::cleanup $Token
  91.       set sid [socket tclhelp.net 55555]
  92.       fconfigure $sid -buffering line
  93.       puts $sid $code
  94.       gets $sid
  95.       gets $sid
  96.       gets $sid url
  97.       close $sid
  98.       putserv "PRIVMSG $target :http://$link => $url"
  99.     }
  100.   }
  101. }
  102.  
  103. ###
  104. putlog "PBin2TclH.tcl LOADED"
Advertisement