This script will allow you to save a pastebin from major pastebin sites, like pastebin.com and pastebin.ca.
It also works with custom modified pastebins, including http://thekingfails.info or any other site hosting a pastebin. Subdomained pastebins also work.
Not only can you save the text to a file, but you can also load it as a script/alias/popup.
I specifically designed this script to dynamically work remotely and directly.
You dont need to do anything differently, the pastebin alias will auto-detect if it was remotely triggered, or not, and act correspondingly. Only thing you need to do is put the alias into an event, yourself, I will not do that for you, although I will give an example:
on 100:TEXT:!pastebin *:*:pastebin $2-
The above will trigger on a user level 100 msg, any message thats normally echo'd will be messaged to the $nick, since its been triggered remotely.
Usage:
/pastebin [-a|-pscqnm|-ruvsN]
Saves the contents of the pastebin url to the given file. If the file exists, you will be prompted with confirmation to continue.
The switches are fed directly to the /load command. Nothing will change with the way the pastebin is saved with the switches, they control how the saved file is loaded into mIRC.
From the mIRC help file
/load <-a|-pscqnm|-ruvsN>
Loads the specified alias, popup, or script.
/load -a aliases.ini loads an aliases file
/load -ps status.ini loads a status window popup
/load -pc status.ini loads a channel popup
/load -pq status.ini loads a query popup
/load -pn status.ini loads a nickname list popup
/load -pm status.ini loads a menubar popup
/load -ru users.ini loads a users file
/load -rv vars.ini loads a variables file
/load -rs script.ini loads a scripts file
So if you were to load it as a script, you would do: /pastebin -rs
If no switches are given, the file is merely saved.
alias pastebin {
if ($isid) return
if ($sock(pastebin)) && (%pastebin.fail) { sockclose pastebin | unset %pastebin.fail }
if ($sock(pastebin)) {
if (!$event) echo -ag * /pastebin: Please wait for last call to complete. The next time /pastebin is called and it still has not completed, it will cancel and begin the new call.
else if ($nick) msg $nick * /pastebin: Please wait for last call to complete. The next time /pastebin is called and it still has not completed, it will cancel and begin the new call.
set %pastebin.fail 1
return
}
unset %textarea
if (-* iswm $1) { var %switch $1 | tokenize 32 $2 $noqt($3-) }
else tokenize 32 $1 $noqt($2-)
if (!$2) {
if (!$event) echo -ag * /pastebin: Please specify an address as well as a file name to save data to.
else if ($nick) msg $nick * /pastebin: Please specify an address as well as a file name to save data to.
return
}
if ($isfile($2-)) {
if (!$event) var %continue $?!="File $+(',$2-,') already exists, ok to overwrite? $+ $crlf $+ All stored data will be lost."
else if ($2- == %pb.file) && ($event) && ($nick) var %continue $true
else if ($nick) { msg $nick * /pastebin: File $+(',$2-,') already exists, If you wish to proceed anyway, repeat this command. Note: All stored data will be lost. | set %pb.file $2- | return }
if (%continue) .remove $qt($2-)
else return
}
if ($event) && ($nick) set %pb.event $nick
var %host $gettok($1,$iif(http://* iswm $1,2,1),47)
sockopen pastebin %host 80
sockmark pastebin %switch %host $mid($1,$calc($pos($1,%host) + $len(%host)) $+ -)) $qt($2-)
unset %pb.file
}
on *:SOCKOPEN:pastebin: {
tokenize 32 $sock($sockname).mark
if (%pb.event) msg $v1 Saving: $iif(-* iswm $1,$+($2,$3) to $4-,$+($1,$2) to $3-) $iif(-* iswm $1,Switches: $right($1,-1))
else echo -ag Saving: $iif(-* iswm $1,$+($2,$3) to $4-,$+($1,$2) to $3-) $iif(-* iswm $1,Switches: $right($1,-1))
sockwrite -n $sockname GET $iif(-* iswm $1,$3,$2) HTTP/1.0
sockwrite -n $sockname Host: $iif(-* iswm $1,$2,$1)
sockwrite $sockname $crlf
}
on *:SOCKREAD:pastebin: {
if ($sockerr) {
if (%pb.event) msg $v1 * /pastebin: Sock error: $sockerr
echo -ag * /pastebin: Sock error: $sockerr
return
}
tokenize 32 $sock($sockname).mark
var %x
sockread %x
if (<textarea *>* iswm %x) || ($+($str($chr(9),3),<textarea *>*) iswm %x) { set %textarea 1 }
if (%textarea == 1) { pb.parse %x }
if (*</textarea>* iswm %x) && (%textarea) { inc %textarea }
if (</html> isin %x) {
unset %textarea
if ($isfile($iif(-* iswm $1,$4,$3))) {
if (%pb.event) msg $v1 Saved pastebin successfully.
else echo -ag Saved pastebin successfully.
if (-* iswm $1) {
.load $1 $4-
if ($script($gettok($4-,$numtok($4-,92),92))) {
if (%pb.event) msg $v1 Loaded $4- successfully.
else echo -ag Loaded $4- successfully.
}
}
unset %pb.*
}
else {
if (%pb.event) msg $v1 Failed to save pastebin, please check link and try again.
else echo -ag Failed to save pastebin, please check link and try again.
}
}
}
alias pb.parse {
if (*<*>*</textarea> iswm $1-) write $iif(-* iswm $gettok($sock(pastebin).mark,1,32),$gettok($sock(pastebin).mark,4-,32),$gettok($sock(pastebin).mark,3-,32)) $html2chr($mid($left($1-,$pos($1-,</textarea>)),$iif($pos($left($1-,$pos($1-,</textarea>)),>,$pos($left($1-,$pos($1-,</textarea>)),>,0)),$calc($v1 +1),1),-1))
else if (</textarea> isin $1-) write $iif(-* iswm $gettok($sock(pastebin).mark,1,32),$gettok($sock(pastebin).mark,4-,32),$gettok($sock(pastebin).mark,3-,32)) $html2chr($left($1-,$+(1,-,$pos($1-,</textarea>))))
else if (*<*>* iswm $1-) write $iif(-* iswm $gettok($sock(pastebin).mark,1,32),$gettok($sock(pastebin).mark,4-,32),$gettok($sock(pastebin).mark,3-,32)) $html2chr($right($1-,$+(-,$iif($pos($1-,>,$pos($1-,>,0)),$v1,1))))
else write $iif(-* iswm $gettok($sock(pastebin).mark,1,32),$gettok($sock(pastebin).mark,4-,32),$gettok($sock(pastebin).mark,3-,32)) $html2chr($1-)
}
alias html2chr {
tokenize 32 $replace($1,",$chr(34),',$chr(39),&,$chr(38),<,$chr(60),>,$chr(62),×,$chr(215),÷,$chr(247))
var %x ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ ­ ® ¯ ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿, %z $numtok(%x,32)
while (%z) {
if ($gettok(%x,%z,32) isin $1-) tokenize 32 $replace($1-,$v1,$chr($calc(159+ %z)))
dec %z
}
var %x $pos($1-,&#,0)
while (%x) {
if (&#*;* iswm $mid($1-,$pos($1-,&#,%x),6)) {
if ($right($mid($1-,$pos($1-,&#,%x),6),1) != ;) var %y $mid($1-,$pos($1-,&#,%x),5), %z $mid($mid($1-,$pos($1-,&#,%x),6),3,2)
else var %y $mid($1-,$pos($1-,&#,%x),6), %z $mid($mid($1-,$pos($1-,&#,%x),6),3,3)
tokenize 32 $replace($1-,%y,$chr(%z))
}
if (%x > $pos($1-,&#,0)) var %x $v2
else dec %x
}
return $1-
}