alias -l makepoststring {
bset -t &poststring 1 $1
var %line = 1, %lines = $cb(0)
while (%line <= %lines) {
bset -t &poststring $calc($bvar(&poststring,0) + 1) $+($urlencode($iif($cb(%line) != $null,$v1,$chr(32))),%,0A)
inc %line
}
}
alias -l paste {
if (!$0) { return $false }
if (!%pastecontrol.lines) { %pastecontrol.lines = 5 }
if ($cb(0) > %pastecontrol.lines) {
if (!%pastecontrol.website) { %pastecontrol.website = pasthis.com }
pasteweb %pastecontrol.website /msg $1
}
else { msg $1 $replace($2-,$cr,%,$lf,$,$chr(1),$chr(123),$chr(255),$chr(125)) }
}
alias -l pasteweb {
if ($1 == pasthis.com) {
if ($sock(pastecontrol.pasthis)) { return $false }
sockopen pastecontrol.pasthis pasthis.com 80
sockmark pastecontrol.pasthis $2-
}
}
alias -l urlencode { return $regsubex($1,/([^A-Z0-9_\-])/gi,% $+ $base($asc(\t),10,16,2)) }
alias -l websites { return pasthis.com }
#pastecontrol on
on *:input:*:{
if ($inpaste) {
var %text = $1-
.timer -dh 1 0 paste $target $replace($1-,%,$cr,$,$lf,$chr(123),$chr(1),$chr(125),$chr(255))
haltdef
}
}
#pastecontrol end
on *:sockopen:pastecontrol.pasthis:{
if ($sockerr) { return }
makepoststring $+(lifetime=max&private=0&title=Autopaste%20by%20,$me,&nickname=,$me,&text=)
sockwrite -n $sockname POST /mirc/ HTTP/1.1
sockwrite -n $sockname Host: pasthis.com
sockwrite -n $sockname Accept: */*
sockwrite -n $sockname Connection: Close
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname Content-Length: $bvar(&poststring,0)
sockwrite -n $sockname
sockwrite $sockname &poststring
}
on *:sockread:pastecontrol.pasthis:{
var %data
sockread %data
if (Pasthis-URL: * iswm %data) {
if ($sock($sockname).mark != $null) { $v1 $gettok(%data,2,32) }
}
elseif (Pasthis-Message: * iswm %data) { echo -a * Paste control: $gettok(%data,2-,32) }
}
dialog pastecontrol {
title "Paste Control"
size -1 -1 180 162
option dbu notheme
check "Enable paste control", 1, 4 5 60 8
text "Only paste to the web when clipboard contains more than ", 2, 4 25 139 8
edit "", 3, 145 23 17 11, number
text "lines", 4, 164 25 11 8
text "I want paste control to paste to the following website:", 5, 5 41 132 8
list 6, 4 53 133 80, radio size vsbar
button "Ok", 7, 98 146 24 12, ok
button "Cancel", 8, 124 146 24 12, cancel
button "Apply", 9, 150 146 24 12, disable
}
on *:dialog:pastecontrol:init:*:{
if (!%pastecontrol.lines) { %pastecontrol.lines = 5 }
if (!%pastecontrol.website) { %pastecontrol.website = pasthis.com }
if ($group(#pastecontrol).status == on) { did -c $dname 1 }
did -a $dname 3 %pastecontrol.lines
didtok $dname 6 32 $websites
if ($didwm($dname,6,%pastecontrol.website,1)) { did -s $dname 6 $v1 }
}
on *:dialog:pastecontrol:sclick:*:{
if ($istok(1 6,$did,32)) { did -e $dname 9 }
elseif ($istok(7 9,$did,32)) {
$iif($did(1).state,.enable,.disable) #pastecontrol
%pastecontrol.lines = $did(3)
%pastecontrol.website = $did(6).seltext
if ($did == 9) { did -b $dname 9 }
}
}
on *:dialog:pastecontrol:edit:3:{ did -e $dname 9 }
menu channel,menubar,query,status {
$iif(!$dialog(pastecontrol),Paste control): dialog -m pastecontrol pastecontrol
}