DoctorD90

PBinSrc.tcl 1.0.0

Apr 18th, 2013
3,154
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ### PBinSrc.tcl 1.0.0 fMrtKqyq
  2.  
  3. #LICENSE
  4. # Copyright © 2013 Alberto Dietze "DoctorD90"
  5. #
  6. #    This program is free software: you can redistribute it and/or modify
  7. #    it under the terms of the GNU General Public License as published by
  8. #    the Free Software Foundation, either version 3 of the License, or
  9. #    (at your option) any later version.
  10. #
  11. #    This program is distributed in the hope that it will be useful,
  12. #    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. #    GNU General Public License for more details.
  15. #
  16. #    You should have received a copy of the GNU General Public License
  17. #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18. #
  19. # Full GPLv3 Text: http://www.gnu.org/licenses/gpl.txt
  20.  
  21. #PATERNITY
  22. #Coder: DoctorD90
  23. #Network: irc.OnlineGamesNet.net
  24. #Chan: #eHito
  25. #
  26. #Thanks to guys on #egghelp on irc.freenode.net
  27.  
  28. #PURPOSE
  29. #Keep update all scripts made by me.
  30.  
  31. #USAGE
  32. #Add this script to your eggdrop's list to load it.
  33.  
  34.  
  35. ### DON'T EDIT ANYTHING BELOW ###
  36.  
  37. package require http
  38.  
  39. set PBinSrc 1
  40.  
  41. proc pbinsrc_vchk {v1 v2} {
  42.   set v11 [lindex $v1 0]
  43.   set v12 [lindex $v1 1]
  44.   set v13 [lindex $v1 2]
  45.   set v21 [lindex $v2 0]
  46.   set v22 [lindex $v2 1]
  47.   set v23 [lindex $v2 2]
  48.   set v 1
  49.   if {$v11 > $v21} {set v "0"}
  50.   if {$v && $v12 > $v22} {set v "0"}
  51.   if {$v && $v13 >= $v23} {set v "0"}
  52.   return $v
  53. }
  54.  
  55. bind pub n .pbinupd pub_pbinupd
  56. proc pub_pbinupd {nick uhost hand chan text} {
  57.   if {![string length [string trim $text]} {
  58.     notice $nick "Script Name Required."
  59.     return
  60.   }
  61.   set scr [lindex [split $text] 0]
  62.   if {![file exists "scripts/$scr"]} {
  63.     notice $nick "Script Doesn't Exist In Script's Folder."
  64.     return
  65.   }
  66.   set fs [open "scripts/$scr"]
  67.   set lines [split [read -nonewline $fs] "\n"]
  68.   close $fs
  69.   set v1 [split [lindex [split [lindex $lines 0]] end-1] "."]
  70.   set link [lindex [split [lindex $lines 0]] end]
  71.   set code [http::data [set Token [http::geturl "http://pastebin.com/raw.php?i=$link"]]]
  72.   http::cleanup $Token
  73.   set v2 [split [lindex [split [lindex [split $code "\n"] 0]] end-1] "."]
  74.   if {![pbinsrc_vchk $v1 $v2]} {
  75.     notice $nick "\002$scr\002 Yet Latest Version Available."
  76.     return
  77.   }
  78.   set fs [open "scripts/$scr" w]
  79.   puts $fs $code
  80.   close $fs
  81.   notoce $nick "\002$scr\002 Successfully Updated."
  82.   rehash
  83. }
  84.  
  85.  
  86. bind pub n .pbindwl pub_pbindwl
  87. proc pub_pbindwl {nick uhost hand chan text} {
  88.   if {![string length [string trim $text]} {
  89.     notice $nick "Script Name Required."
  90.     return
  91.   }
  92.   set pbincheck [regexp -all -nocase {(pastebin.com/[\d\w-]{8})} $text pbinid]
  93.   set code [split [http::data [set Token [http::geturl "http://pastebin.com/raw.php?i=[lindex [split $pbinid /] 1]"]]] "\n"]
  94.   http::cleanup $Token
  95.   set scr [lindex [split [lindex $code 0]] 2]
  96.   set fs [open "scripts/$scr" w]
  97.   puts $fs $code
  98.   close $fs
  99.   privmsg $nick "Successfully Downloaded."
  100. #
  101. #DownLoad Requirements WiP
  102.   set l [expr {[lsearch $code "#REQUIREMENTS"] != "-1"] + 1}]
  103.   if {!$l} {return}
  104.   set a 1
  105.   while {$a} {
  106.     if {![string length [string trim [lindex $code $l]]]} {
  107.       set a 0
  108.     } else {
  109.       lappend req [lindex [split [lindex $code $l]] 2]
  110.       incr l
  111.     }
  112.   }
  113.   #download
  114. }
  115.  
  116. ###
  117. putlog "PBinSrc.tcl LOADED"
Advertisement
Comments
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment