All pastes #994266 Raw Edit

pastebin opener

public text v1 · immutable
#994266 ·published 2008-04-23 07:58 UTC
rendered paste body
Dialog Pastebin.ca {
  title "Pastebin.ca"
  size -1 -1 312 207
  option dbu
  edit "", 1, 18 35 274 159, autohs vsbar return multi
  box "Script", 2, 9 27 291 173
  text "Pastebib ID", 3, 0 11 311 8, center
  link "Pastebin.ca", 4, 141 20 33 8
}
Dialog Pastebin.caOpen {
  title "Pastebin.ca :: Open"
  size -1 -1 169 32
  option dbu
  text "Would you like to open the pastebin: ", 1, 1 4 168 8
  button "Yes", 2, 44 16 37 12
  button "No", 3, 86 16 37 12
}
ON *:TEXT:*:*:{
  if ($regex($1-,/(?:http:\/\/)?(?:www\.)?pastebin\.ca/(\d+)/i)) {
    var %ID $regml(1)
    if (!%PBID && !$dialog(Pastebin.ca)) {
      set %PBID %ID
      dialog -m Pastebin.caOpen Pastebin.caOpen
      did -a Pastebin.caOpen 1 Would you like to open the pastebin: %ID by $nick
    }
  }
}
ON *:DIALOG:Pastebin.caOpen:SCLICK:*:{
  if ($did == 2) {
    sockopen PB pastebin.ca 80
    sockmark PB %PBID
    dialog -x $dname
  }
  else {
    dialog -x $dname
    unset %PBID
  }
}
ON *:SOCKOPEN:PB:{
  sockwrite -nt $sockname GET $+(/,$sock($sockname).mark) HTTP/1.1
  sockwrite -nt $sockname Host: pastebin.ca
  sockwrite -nt $sockname $crlf $+ $crlf
}
ON *:SOCKREAD:PB:{
  var %PB
  sockread %PB
  if ($regex(%PB,/<textarea rows="20" cols="80" id="pastearea-id2243742" name="content" class="pastecontent">(.*)/i)) {
    dialog -m Pastebin.ca Pastebin.ca
    did -i Pastebin.ca 1 $did(Pastebin.ca,1).lines $regml(1)
    set %PBYES 1
  }
  if (%PBYES && !$regex(%PB,/(<textarea rows="20" cols="80" id="pastearea-id2243742" name="content" class="pastecontent">|</textarea>)/i)) {
    did -i Pastebin.ca 1 $did(Pastebin.ca,1).lines %PB
  }
  if (</textarea> isin %PB && %PBYES) {
    did -i Pastebin.ca 1 $did(Pastebin.ca,1).lines $remove(%PB,</textarea>)
    unset %PBYes
    did -a Pastebin.ca 3 Pastebin ID: %PBID
    unset %PBID
    sockclose $sockname
  }
}