Project

General

Profile

[Script]: AdiIRC Backup v1.0

Added by westor (GR) 3 months ago

Description:

The following code requested by Makis , allowing you to create a backup in your choose destination with your compression method, you have to use a Portable version of AdiIRC in order to work and .NET 4.5+ dotnet version, working on AdiIRC 3.4+, the backup progress may take some minutes to complete, it's depending on your Hard Drive speed and type (HDD or SSD) too, please note that if a backup progress is running and you exit AdiIRC then the progress will automatically be canceled.

Changelog:

  • v1.0
    - First public release.

Contact:

westor on IRC FreeNode in #AdiIRC

Preview:

Code:

alias f8 { ; by westor
  if ($version < 3.4) { _input error 30 Please update to the latest AdiIRC version! | return }
  if ($mid($dotnet,2,1) < 4) { _input error 30 You have to use .NET 4.5 and newer! | return }
  if (!$portable) { _input error 30 You have to use a portable version! | return }
  if ($zip(backup)) { _input error 30 The backup progress is already in use! | return }

  var %choose = $input(Please choose a option:,qudbm,Compression method,Fast,Fast,Good,Best)
  if (!%choose) { _input error 15 Backup has been canceled! | return }

  if (%choose == Fast) { var %c = 0 }
  if (%choose == Good) { var %c = 1 }
  if (%choose == Best) { var %c = 2 }

  var %dir = $sdir($iif(%old_backup_dir,$v1,$sysdir(desktop)),Select a folder to create an AdiIRC backup..)

  if (!$isdir(%dir)) { _input error 15 Backup has been canceled! | return }

  var %f = %dir $+ adiirc_backup.zip

  if ($file(%f)) { 
    var %ask = $input(There is already an old backup file in that destination! $crlf $crlf $+ Created on: $asctime($file(%f).ctime) $crlf $+ Filesize: $bytes($file(%f)).suf $crlf $crlf $+ $+ Continue with Overwrite?,yuwdbk9,Question)
    if (!%ask) { _input error 15 Backup has been canceled! | return }
  }

  set -eu3600 %backup_ticks $ticks
  set %old_backup_dir %dir

  zip -ol $+ %c backup $qt($mircdir) $qt(%f)

  _input ok 30 Creating a new backup, this may take a while.. Please wait! @newline@ @newline@ Source: $adiircdir @newline@ Destination: %f
}

ON *:ZIP:backup: {
  if ($ziperr) { _input error 30 Backup failed, there was an error occurred while trying to create a new backup, please try again later! | return }

  _input ok 30 Backup created successfully. @newline@ @newline@ Source: $zip($zip).src @newline@ Destination: $zip($zip).dest @newline@ @newline@ Filesize: $bytes($file($zip($zip).dest)).suf @newline@ Progress Took: $iif(%backup_ticks,$calc(($ticks - $v1) / 1000) $+ s,Unknown)
}

alias _input {
  if (!$1) || (!$3) || ($isid) { return }

  if ($1 == ok) { .timer -ho 1 0 !noop $input($replace($3-,@newline@,$crlf),ouidbk $+ $iif($2 && $2 isnum,$2,0),OK)) }
  if ($1 == error) { .timer -ho 1 0 !noop $input($replace($3-,@newline@,$crlf),houdbk $+ $iif($2 && $2 isnum,$2,0),Error)) }
  if ($1 == warn) { .timer -ho 1 0 !noop $input($replace($3-,@newline@,$crlf),woudbk $+ $iif($2 && $2 isnum,$2,0),Warn)) }
}