mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Joined: Jul 2006
Posts: 242
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
great idea great script, just when i paste lines less then the amount specified it goes into the channel the wrong way round. also i keep getting when using it the following...
* Invalid parameters: $did
* Invalid parameters: $did
* Invalid parameters: $did
* Invalid parameters: $did
* Invalid parameters: $did
* Invalid parameters: $did
* Invalid parameters: $did
* Invalid parameters: $did

Last edited by HaleyJ; 17/02/07 10:28 PM.

Newbie
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Hmm, it seems that in order to have the lines paste in the correct order I have to use a high resolution timer, which I don't really like having to use. But if there's no other way around it..

I've also thrown in the ordering switch for good measure.

Here's the fix:

Code:
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
}


This also fixes the $did problem. It's a kludgy solution, but it works. For some reason when I tried using the usual way of unevaluating things (setting data to a %variable and passing % $+ variable to the timer), the variable couldn't be accessed by the /paste alias, so instead I've used a messy way of temporarily replacing $, %, { and } with $cr, $lf, $chr(1) and $chr(255) - which means the content you're pasting should not contain any of those characters. That's the best I can do until I figure out why mIRC isn't letting /paste access the variable I passed to it. It definitely was not a local variable.

Joined: Feb 2007
Posts: 13
_
_cue_ Offline OP
Pikka bird
OP Offline
Pikka bird
_
Joined: Feb 2007
Posts: 13
Someone had managed to make empty pastes with autopaste. The posts were full of \n nothing else. They won't be saved anymore, just thought I'd inform you.

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Does it give a new error or one that I've already supported?

Joined: Feb 2007
Posts: 13
_
_cue_ Offline OP
Pikka bird
OP Offline
Pikka bird
_
Joined: Feb 2007
Posts: 13
elseif (Pasthis-Message: * iswm %data) { echo -a * Paste control: $gettok(%data,2-,32) }

That works just fine smile

It just sets these headers on the new error:
Pasthis-Status: ERROR
Pasthis-Message: Paste emtpy, not saving.

Joined: Jul 2006
Posts: 242
H
Fjord artisan
Offline
Fjord artisan
H
Joined: Jul 2006
Posts: 242
great idea great script, but when i want to paste like a 100 lines or moreit crashes my client and i get a bunch of error messages like invalid parameters $did etc


Newbie
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Are you using the newest version I've posted on here?

Edit: I just pasted 500 lines into mIRC. It sent them to the server, but the server did not reply with an error and didn't add it as a paste. mIRC froze for about 8 seconds.

Edit 2: A quick debug shows that there's a PHP error. It'll be fixed when cue notices it I guess.

Joined: Feb 2007
Posts: 13
_
_cue_ Offline OP
Pikka bird
OP Offline
Pikka bird
_
Joined: Feb 2007
Posts: 13
Originally Posted By: hixxy


Edit 2: A quick debug shows that there's a PHP error. It'll be fixed when cue notices it I guess.


Damn! How did that get there ...

Fixed.

Joined: Feb 2007
Posts: 13
_
_cue_ Offline OP
Pikka bird
OP Offline
Pikka bird
_
Joined: Feb 2007
Posts: 13
Everything working ok or have I screwed up something? Haven't seen any mirc pastes in a while now.


Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Works fine. Pastes sent to /mirc/ aren't showing up on the main page, maybe that's why you can't see them?

Joined: Feb 2007
Posts: 13
_
_cue_ Offline OP
Pikka bird
OP Offline
Pikka bird
_
Joined: Feb 2007
Posts: 13
Ah so you set private to 1 now smile

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Oh so I did. I can't remember making that change confused

Page 2 of 2 1 2

Link Copied to Clipboard