|
Joined: Feb 2007
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Feb 2007
Posts: 13 |
I've got yet another paste site, http://pasthis.com I'm about to release a script for Irssi which utilizes external interface I've made for that site. Basically what the script does is that it buffers your input if there is less than X milliseconds between line breaks (and line is over X chars), once all the pasted lines are in the buffer the buffer is sent to pasthis.com and saved. The interface returns the url for it and that line only appears on the irc channel. So in short: You paste 1000 lines directly to irc channel -> all you (and others) see is 19:09 < cue> http://pasthis.com/y3424bfSo what am I doing here? Unfortunately I'm not familiar in mIRC scripting and I don't own any computer which could even run mIRC natively, so if anyone is interested in writing similiar script to mIRC (if it is possible), I'll be happy to provide the specs for the external interface.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
I'll do it, mainly because I think it's a brilliant idea and will more than likely use it myself
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
Fjord artisan
Joined: Apr 2006
Posts: 400 |
You're lucky cue, you've got a great scripter who volunteered .
-Kurdish_Assass1n
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
I've made it and added a small dialog to configure the (few) options it has. As you can probably tell by the script, I'm planning on extending it to support more paste websites. If you want a later version that supports more, let me know.
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- }
}
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) {
.timer 1 0 paste $target
haltdef
}
}
#pastecontrol end
on *:sockopen:pastecontrol_pasthis:{
if ($sockerr) { return }
makepoststring $+(lifetime=max&nickname=,$me,&text=)
sockwrite -n $sockname POST /save.php 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 (Location: * iswm %data) {
if (*/error/* iswm %data) {
var %error = $gettok(%data,3,47)
if (%error == 1) { echo -a * Paste control: pasthis.com reports that you are pasting too much. }
elseif (%error == 2) { echo -a * Paste control: pasthis.com reports that you are pasting too quickly. Please wait one minute. }
elseif (%error == 3) { echo -a * Paste control: pasthis.com reports that you are not pasting enough. Minimum is 10 characters. }
}
elseif ($sock($sockname).mark != $null) { $v1 http://www.pasthis.com/ $+ $gettok(%data,3,47) }
}
}
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
}
Just right click in a channel, query, status window or use the menubar and select 'Paste control' to open the config dialog. Let me know if you have any issues PS. requires mIRC 6.2+ Oh, and I apologise for flooding your pastebin with my tests. Feel free to delete them..
|
|
|
|
Joined: Feb 2007
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Feb 2007
Posts: 13 |
Wow, that was fast, I didn't think I would even get a reply this fast - and there's the first version of the script already Anyway, it'd be better if you posted to other than the save.php. Better place to post would be http://pasthis.com/yc67e4a <- here's the info
Last edited by _cue_; 16/02/07 05:35 AM.
|
|
|
|
Joined: Feb 2007
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Feb 2007
Posts: 13 |
Just re-read the script, and you actually catch almost all of the error situations, nice one. But still it'd be better to use the /mirc to post them
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
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- }
}
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) {
.timer 1 0 paste $target
haltdef
}
}
#pastecontrol end
on *:sockopen:pastecontrol.pasthis:{
if ($sockerr) { return }
makepoststring $+(lifetime=max&title=Autopaste%20by%20,$me,&nickname=,$me,&text=)
; sockwrite -n $sockname POST /save.php HTTP/1.1
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
}
This one will go to /mirc/
|
|
|
|
Joined: Feb 2007
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Feb 2007
Posts: 13 |
Great!
Do you mind if I put that up for download on pasthis.com? With some installation instructions perhaps, or is it so straight forward in mirc that everyone knows how to do it if they just dl the script itself?
Or are you going to make some zipped autopaste packet for distribution?
Last edited by _cue_; 16/02/07 12:01 PM.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
I don't mind Just tell them to do the following: Hit Alt+R, go to File > New, copy/paste the script into the editbox, hit the ok button.
|
|
|
|
Joined: Feb 2007
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Feb 2007
Posts: 13 |
There it is, a link to that weird url is on the front page as well http://pasthis.com/xaef8fbIf you want to add or change info or link to some zip instead of that paste where the script is just tell me and I'll change it.
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
Will do, cheers
|
|
|
|
Joined: Feb 2007
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Feb 2007
Posts: 13 |
Just right click in a channel, query, status window or use the menubar and select 'Paste control' to open the config dialog. Let me know if you have any issues PS. requires mIRC 6.2+ I got a bug report from one tester, and then chose to try myself too before bugging you On a windows laptop @ work now Tested fresh install of mIRC 6.21, hit ALT-R, File -> New, pasted the script and hit ok. It is loaded ok as the paste control is there. But when I paste and it asks to confirm, nothing happens. I checked the web log and it didn't do a request to pasthis.com. Any settings I'm missing? Edit: the confirm dialog seems to be mIRC standard feature when pasting a lot. When pasting just 6-7 lines the confirm does not appear, no post request is done to pasthis.com and it only plays "beep" sound once. Also when pasting under the threshold (5) it says "* /msg: insufficient parameters (line 16, script1.ini)"
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
The problem was a result of me taking a portion of my expanded script (supports 9 pastebins + more options). I basically opened the "pastecontrol_pasthis" socket but tried receiving events for "pastecontrol.pasthis" (. instead of _). Here's the fix:
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- }
}
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) {
.timer 1 0 paste $target $1-
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
}
This also fixes the /msg error. I forgot to pass the text pasted to the /paste alias.
|
|
|
|
Joined: Feb 2007
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Feb 2007
Posts: 13 |
Thanks! Btw, the posts get these attributes now from your script Lifetime max (=stays there for unspecified amount of time, I don't know yet ) Private 1 (won't show on public lists) Those are what you want? btw, got irssi script there too now in case you're interested in how different it is to script irc clients in perl
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
I didn't realise it defaulted to private. I've editing my post to update the script again. lifetime=max is intended.
|
|
|
|
Joined: Feb 2007
Posts: 13
Pikka bird
|
OP
Pikka bird
Joined: Feb 2007
Posts: 13 |
Ok - will that be configurable in your final bigger script? I bet some people wouldn't want them to be automatically public. I had to make some changes to saving routines, unicode characters in pastes behaved quite funny, if you experienced any oddities during last 30mins, it was most likely me
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
Yeah. I've added support for another 8 paste websites to the script and I'll be making a dialog so that you can configure each ones options.
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
Fjord artisan
Joined: Apr 2006
Posts: 400 |
hixxy, you know what I think would make this script better. Let's say you have 10 lines in clipboard. It's something you want to be secure and just want it pasted to the chan. I think that you should make it where if you type CTRL + V then it just pastes it, but, if you right-click on a chan and choose Paste or something, then it will send to a link, hope you understand what I'm talking about.
-Kurdish_Assass1n
|
|
|
|
Joined: Sep 2005
Posts: 2,881
Hoopy frood
|
Hoopy frood
Joined: Sep 2005
Posts: 2,881 |
That's not possible without subclassing the editbox, and to do that you'll need a DLL. I could add that as a feature to the bigger addon I'm writing, but it kinda removes the simplicity that makes it appealing. I'll think about it
|
|
|
|
Joined: Apr 2006
Posts: 400
Fjord artisan
|
Fjord artisan
Joined: Apr 2006
Posts: 400 |
ok, nice job on the script though hixxy, works great /me uses it as well now :P
-Kurdish_Assass1n
|
|
|
|
|