
alias windowOFF { window -c @TEXTwindow | .timerTEXTwindowposition off }
alias eonickedits {
  if $dialog(eonickedits) = $null { dialog -m eonickedits eonickedits }
}
dialog eonickedits {
  icon $shortfn($mircdirSystem\Scripts\ControlPanel\ico\seln.ico)
  title "Настройка стиля [/eonickedits]"
  size -1 -1 380 148
  option pixels
  button "Ok", 1, 1 119 377 27, flat ok
  text "Для установки цвета используйте клавиши (Cntrl + K) <номер цвета текста>,<номер цвета фона>. (Cntrl + U) - подчеркивание, в конце сообщения которого нужно что то подчеркнуть надо нажать (Cntrl + U). (Cntrl + B) - жирный шрифт", 18, 1 1 379 54, center
  box "", 19, 1 56 378 40
  edit %eonickedits1, 20, 6 97 105 20, autohs
  text "НИК", 21, 116 100 25 14
  edit %eonickedits2, 22, 146 97 105 20, autohs
  text "Текст сообщения", 23, 256 100 101 14
  button "", 24, 0 0 0 0, Cancel
}

;=============================
on 1:dialog:eonickedits:init:0:{ ONwindow2 | refreshTEXT2 }

;=============================
on 1:dialog:eonickedits:sclick:199: { windowOFF }

;=============================
on 1:dialog:eonickedits:sclick:1:{ set %eonickedits1 $did(eonickedits,20).text | set %eonickedits2 $did(eonickedits,22).text | windowOFF }
on 1:dialog:eonickedits:sclick:24:{ windowOFF }

;=============================
on 1:dialog:eonickedits:edit:*:{ refreshTEXT2 }

alias refreshposition2 {  window $iif($dialog(eonickedits).active,-o,-u) @TEXTwindow $calc($dialog(eonickedits).x + 8) $calc($dialog(eonickedits).y + 98) 369 20 }
alias ONwindow2 {
  window -c @TEXTwindow
  window -hkdo +dL @TEXTwindow $calc($dialog(eonickedits).x + 8) $calc($dialog(eonickedits).y + 98) 369 20
  window -a @TEXTwindow
.timerTEXTwindowposition -mo 0 250 refreshposition2 }
alias refreshTEXT2 {
  clear @TEXTwindow
  echo @TEXTwindow $did(eonickedits,20).text $+ Ник $+ $did(eonickedits,22).text   Текст сообщения 
}
alias eonickedit { 
  if (%eonickedits1 $+ $$1 $+ %eonickedits2 $+  isin $editbox($active,0)) { editbox -a | pinfo $$1 }
  else { editbox -apf %eonickedits1 $+ $$1 $+ %eonickedits2 $+  }
  set %nicktrans %eonickedits1 $+ $$1 $+ %eonickedits2 $+ 
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias xpopdll {
  if ($isid) return $dll(xpopup.dll,$1,$2-)
  else dll " $+ xpopup.dll" $1 $2-
}
alias uxpop dll -u xpopup.dll
alias xpop {
  if ( $isid ) {
    return $xpopdll( _xpop, $1 $prop $2- )
  }
  else {
    xpopdll xpop $2 $1 $3-
  }
}
alias xpopup {
  if ( $isid ) {
    return $xpopdll( _xpopup, $1 $prop $2- )
  }
  else {
    xpopdll xpopup $2 $1 $3-
  }
}
alias mpopup {
  xpopdll mpopup $1 $2
}
ON *:SIGNAL:Xpopup-*: { 
  echo -s $signal : $1-
}
alias mirre {
  xpopup -i mirc 0 $shell
  mpopup mirc 1
  xpopup -t mirc %menustyle
  xpopup -b mirc icons\emo.bmp
}
alias mirre2 {
  xpopup -i mircbar 0 $shell
  mpopup mircbar 1
  xpopup -t mircbar %menustyle
  xpopup -b mircbar icons\emo.bmp
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias chgmode {
  set %first -3
  :mode1
  inc %curcle
  inc %first 4 | inc %second 4
  if ( %curcle > $calc($int($calc($snick($chan,0) / 4 )) + 1) ) { unset %first | unset %curcle | unset %first | unset %second | goto next }
  else { mode $chan $$1 $replace($gettok($snick($chan),%first $+ - $+ %second,44),$chr(44),$chr(32)) | goto mode1 }
  :next 
  set %first -3
  :mode2
  if ( $2 != $null ) {
    inc %curcle
    inc %first 4 | inc %second 4
    if ( %curcle > $calc($int($calc($snick($chan,0) / 4 )) + 1) ) { unset %first | unset %curcle | unset %first | unset %second | halt }
    else { mode $chan $$2 $replace($gettok($snick($chan),%first $+ - $+ %second,44),$chr(44),$chr(32)) | goto mode2 }
  }
  else { unset %first | unset %curcle | unset %first | unset %second | halt }
}
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; НАСТРОЙКИ IRC0OP SCRIPT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
alias newicons {
  toolbar -az2 Skins "Менеджер Скинов" " $+ icons\int.ico $+ " "/skins" 
  toolbar -az2 noptions "Help По скрпиту" " $+ icons\help.ico $+ " "/run help\script's.htm" 
  toolbar -az2 notify "Настройка Авай" " $+ icons\away.ico $+ " "/awayer" 
  toolbar -as sepp2 "-"
  toolbar -az2 anpois "Поиск" " $+ icons\channels.ico $+ " "/searchfind"
  toolbar -az2 ajoin "Цвет ников" " $+ icons\printer.ico $+ " "/nickcolors"
  toolbar -az2 menu "Панель настроек" " $+ icons\menu.ico $+ " "/main"
  toolbar -az2 pox "Sms Send" " $+ icons\sms.ico $+ " "/masms" 
  toolbar -az2 vol "Радио" " $+ icons\radio.ico $+ " "/radio"
  toolbar -az2 ad "Выбрать ICONS" " $+ icons\f-keys.ico $+ " "/ico"
  toolbar -as sepp3 "-"
  toolbar -az2 run3 "Посетить Сайт скрипта" " $+ icons\explor.ico $+ " "/run http:\\www.mirc-love.com" 
  toolbar -az2 Audio "Настройка Защиты" " $+ icons\security.ico $+ " "/security"
  toolbar -as sepp4 "-"
  if ($swamp(WinAmpGet, INSTALLED) == $true) {
    toolbar -az2 pre "Предыдущий трек (Winamp)" " $+ sys\icons\ $+ %icons $+ \pre.ico $+ " "/ampprev" 
    toolbar -az2 play "Игра\Пауза (Winamp)" " $+ sys\icons\ $+ %icons $+ \play.ico $+ " "/winampplay" 
    toolbar -az2 stop "Стоп (Winamp)" " $+ sys\icons\ $+ %icons $+ \stop.ico $+ " "/winampstop" 
    toolbar -az2 next "Следующий трек (Winamp)" " $+ sys\icons\ $+ %icons $+ \next.ico $+ " "/ampnext" 
    toolbar -az2 Wins "Настройка Winampa" " $+ icons\winamp.ico $+ " "/winampcontrol"
  }
}
on *:DIALOG:dsopt:sclick:20: {
  did $iif($did(dsopt,20).state == 0, -b, -e) dsopt 21
  did $iif($did(dsopt,20).state == 0, -b, -e) dsopt 15
  did $iif($did(dsopt,20).state == 0, -b, -e) dsopt 100
}
on *:DIALOG:dsopt:sclick:46: {
  dsdrcoloricons $did(dsopt,46).state
  did $iif($did(dsopt,46).stкate == 0, -b, -e) dsopt 47
  did $iif($did(dsopt,46).state == 0, -b, -e) dsopt 48
  did $iif($did(dsopt,46).state == 0, -b, -e) dsopt 49
  did $iif($did(dsopt,46).state == 0, -b, -e) dsopt 50
  did $iif($did(dsopt,46).state == 0, -b, -e) dsopt 101
}
on *:DIALOG:dsopt:sclick:101: {
  dsdrcoloricons $did(dsopt,46).state
}
on *:DIALOG:dsopt:sclick:30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45: {
  if ($did(dsopt,46).state == 0) { return }
  var %sel = $did(dsopt,101).seltext
  var %b = $calc($did -30)
  if (%sel == Я ) { set %nick.colors.temp $puttok(%nick.colors.temp,%b,1,32) }
  if (%sel == Овнер ) { set %nick.colors.temp $puttok(%nick.colors.temp,%b,2,32) }
  if (%sel == Оп ) { set %nick.colors.temp $puttok(%nick.colors.temp,%b,3,32) }
  if (%sel == Полуоп ) { set %nick.colors.temp $puttok(%nick.colors.temp,%b,4,32) }
  if (%sel == Войс ) { set %nick.colors.temp $puttok(%nick.colors.temp,%b,5,32) }
  if (%sel == Обычный ) { set %nick.colors.temp $puttok(%nick.colors.temp,%b,6,32) }
  if (%sel == Игнор ) { set %nick.colors.temp $puttok(%nick.colors.temp,%b,7,32) }
  if (%sel == Нотифи ) { set %nick.colors.temp $puttok(%nick.colors.temp,%b,8,32) }
  dsdrcoloricons $did(dsopt,46).state
}
alias dsdrcoloricons {
  var %b
  var %sel = $did(dsopt,101).seltext

  if (%sel == Я ) { %b = $gettok(%nick.colors.temp,1,32) }
  if (%sel == Овнер ) { %b = $gettok(%nick.colors.temp,2,32) }
  if (%sel == Оп ) { %b = $gettok(%nick.colors.temp,3,32) }
  if (%sel == Полуоп ) { %b = $gettok(%nick.colors.temp,4,32) }
  if (%sel == Войс ) { %b = $gettok(%nick.colors.temp,5,32) }
  if (%sel == Обычный ) { %b = $gettok(%nick.colors.temp,6,32) }
  if (%sel == Игнор ) { %b = $gettok(%nick.colors.temp,7,32) }
  if (%sel == Нотифи ) { %b = $gettok(%nick.colors.temp,8,32) }
  if ($1 == 0) { %b = -1 }
  if (%lastcolor && ( %b == %lastcolor )) { return }
  if ( %lastcolor >= 0 ) { did -g dsopt $calc(%lastcolor +30) 1 Pics\ $+ %lastcolor $+  .bmp }
  if (%b >= 0) { did -g dsopt $calc(%b +30) 1 Pics\ $+ %b $+  _.bmp }
  set %lastcolor %b
}
on ^*:NOTICE:*:*: {
  if ($nick != NickServ) && ($nick != ChanServ) && ($nick != SeenServ) && ($nick != MemoServ) && ($nick != -psyBNC) && ($nick != Global) && ($nick != SecureServ) && ($nick != ScanServ) && ($nick != $network) && ($nick != freza.dmitrov.ru) {
    if (%notice.me == on) { /dll libraries\game_tools.dll splay %notice.me.snd }
  }
  if (%dontshownotice == 1) {
    if $nick == nickserv || $nick == chanserv { goto next }
    var %x $strip($1-) , %i $numtok(%dontshow,32)
    while (%i) {
      if ($gettok(%dontshow,%i,32) iswm %x) || ($gettok(%dontshow,%i,32) isin %x) {
        halt
      }
      dec %i
    }
  }
  :next
  if ($nick == nickserv) { noticefromservice $1- }
  if ($nick == chanserv) { noticefromservice $1- }
  if ($nick == seenserv) { noticefromservice $1- }
  if ($nick == memoserv) { noticefromservice $1- }
  else {
    if  ( %stripcolornotices == 0 || $count($1-,,,,,) == 0 ) { echo $color(notice) -ati2bfl - $+  $+ %nick.color.regular $+ $nick $+ - $1- } 
  }
  haltdef 
}
on *:INPUT:* {
  if (!$ctrlenter) {
    if ($left($1-,1) != $chr(47)) {
      if ($chan && $poscs($chan($chan).mode,c)) { set %string $strip(%string) }
      if (%ourautotrans == 1) {
        set %string $strip($1-)
        if ($chan) {
          var %s1 = 0
          while ($nick($chan,%s1)) {
            inc %s1
            set %string $replace(%string,$nick($chan,%s1),)
          }
        }
        if ($transdictest(%string) == 1) {
          set %string $strip($1-)
          var %x $strip($1-) , %d $numtok(%perevisk,32)
          while (%d) {
            if ($gettok(%perevisk,%d,32) iswm %x) || ($gettok(%perevisk,%d,32) isin %x) {
              goto iskl
            }
            dec %d
          }
          transtemp
          :iskl
          haltdef
          if ($chan && $poscs($chan($chan).mode,c)) { msg $active $strip(%string) | halt }
          say Автоперевод -> %string
        }
        unset %string
      }
    }
  }
}

on *:text:*:* { 
  if  (%autotranslate == 1) {
    set %string $strip($1-)
    if ($chan) && ($query) {
      var %s1 = 0
      while ($nick($chan,%s1)) {
        inc %s1
        set %string $replace(%string,$nick($chan,%s1),)
      }
    }
    if ($transdictest(%string) == 1) {
      set %string $strip($1-)
      var %x $strip($1-) , %d $numtok(%perevisk,32)
      while (%d) {
        if ($gettok(%perevisk,%d,32) iswm %x) || ($gettok(%perevisk,%d,32) isin %x) {
          goto iskl
        }
        dec %d
      }
      transtemp
      %trans  %skinpref 4AutoT14ranslite 0=8=1> 15:9  $nick  14 %string
    }
    :iskl
    unset %string
  }
}

on *:DISCONNECT: { unset %myban }
on *:voice:#:{ 
  .timer -m 1 0 colorize $chan
}
on *:devoice:#:{ 
  .timer -m 1 0 colorize $chan
}
alias iconsset {
  if (%icons == Стандартные) {
    toolbar -r
    toolbar -d 8
    toolbar -d 8
    toolbar -d 8
    toolbar -az1 link "Настройка" icons\channels.ico "/opens" 
    toolbar -m 9 link
    toolbar -asz1 e "-"
    toolbar -m 10 e
  }
  else {
    toolbar -r
    toolbar -d 8
    toolbar -d 8
    toolbar -d 8
    toolbar -az1 link "Настройка сообщений..." " $+ icons\channels.ico $+ " "/opens" 
    toolbar -m 9 link
    toolbar -asz1 e "-"
    toolbar -m 10 e
    var %i = 1
    var %u = 2
    while (%i <= 14) {
      if ($toolbar(%i).type == separator) { inc %i }
      if ($findfile(sys\icons\ $+ %icons $+ , $+ %u $+ .ico,1)) { toolbar -pz2 $toolbar(%i).name " $+ $findfile(sys\icons\ $+ %icons $+ , $+ %u $+ .ico,1) $+ " }
      else { deleteicons %i }
      inc %u
      inc %i
    }
  }
}
alias deleteicons {
  var %e = $1
  var %d = $1
  while (%e <= 50) {
    if ($toolbar(%d).name) { toolbar -d %d }
    inc %e
  }
  newicons
}
alias font_ {
  if ($1 == 0) { if ($2 == 6) { return 406 } | if ($2 == 7) { return 407 } | if ($2 == 8) { return 408 } | if ($2 == 9) { return 409 } | if ($2 == 10) { return 410 } | if ($2 == 11) { return 411 } | if ($2 == 12) { return 412 } | if ($2 == 13) { return 413 } | if ($2 == 14) { return 414 } | if ($2 == 15) { return 415 } | if ($2 == 16) { return 416 } }
}
alias fontset {
  var %i = 1
  while (%i <= $scon(0)) {
    scon %i setfont
    inc %i
  }
}
alias setfont {
  if ($chan(0) != 0) { chanfont }
  if ($query(0) != 0) { queryfont }
  remini mirc.ini fonts
  writeini -n mirc.ini fonts fstatus %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts fchannel %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts fquery %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts fnotify %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts ffinger %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts flist %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts fwwwlist %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts fchat %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts fscripts %font $+ , $+ $font_(0,%fontsize) $+ ,204
  writeini -n mirc.ini fonts flinks %font $+ , $+ $font_(0,%fontsize) $+ ,204
  font -s %fontsize %font
}
alias chanfont {
  var %q = 1 
  while (%q <= $chan(0)) {
    .font -b $chan(%q) %fontsize %font
    inc %q
  }
}
alias queryfont {
  var %q = 1 
  while (%q <= $query(0)) {
    .font -b $query(%q) %fontsize %font
    inc %q
  }
}
;==========clonescan ===========(c) Voron
alias lookChanNickClones {
  ; parameters : nick #
  if ($ialchan($address($1,2),$2,0) == 1) return
  var %nNickCount = 0
  var %aNickClones = $1
  while (%nNickCount < $ialchan($address($1,2),$2,0)) {
    inc %nNickCount
    var %aNickClones = $addtok(%aNickClones,$ialchan($address($1,2),$2,%nNickCount).nick,32)
  }
  return %aNickClones
}
alias PClones {
  if ($ishideIPDNS($remove($address($1,2),*!*@)) == 1) return 
  return  $iif($ialchan($address($1,2),$2,0) > 1,Клоны) $iif($ialchan($address($1,2),$2,0) > 1,$ialchan($address($1,2),$2,0))
}
on *:dialog:rgb:scroll:*:{
  if ($did == 1) {
    /set %rgbred $did(1).sel
    did -ra rgb 8 %rgbred
    did -ra rgb 16 %rgbred
    colorup
  }
  if ($did == 2) {
    /set %rgbgreen $did(2).sel
    did -ra rgb 9 %rgbgreen
    did -ra rgb 17 %rgbgreen
    colorup
  }
  if ($did == 3) {
    /set %rgbblue $did(3).sel
    did -ra rgb 10 %rgbblue
    did -ra rgb 18 %rgbblue
    colorup
  }
}
on *:dialog:rgb:sclick:*:{
  if ($did == 11) {
    unset %rgbred
    unset %rgbgreen
    unset %rgbblue
    dialog -c rgb
  }
  if ($did == 13) {
    var %t = $?="Введите название нового оттенка"
    if (%t) {
      .write sys\popups\colours.txt %t $+ * $+ %rgbred $+ , $+ %rgbgreen $+ , $+ %rgbblue
      did -r dsopt 17
      var %w = 1
      while (%w <= $lines(sys\popups\Colours.txt)) {
        did -i dsopt 17 %w $gettok($read(sys\popups\Colours.txt,%w),1,42)
        inc %w
      }
      set %popupscolor $lines(sys\popups\Colours.txt)
      did -c dsopt 17 %popupscolor

      dialog -x rgb
    }
  }
}
alias colorup {
  mdx SetColor $dname 7 background $rgb(%rgbred,%rgbgreen,%rgbblue)
}
alias mixslovo { var %t = $1 | var %len = $len(%t) | var %x = 1 | while (%x <= %len) { :back | var %y = $rand(1,%len) | if ($istok(%was,%y,32) == $true) goto back | if ($istok(%was,%y,32) == $false) { var %was = %was %y | var %out = %out $+ $mid(%t,%y,1) } | inc %x } | return %out }
alias fav {
  if $dialog(fav) = $null { dialog -m fav fav }
}
dialog fav {
  title "Между никами должен быть пробел!"
  size -1 -1 187 50
  option dbu
  icon sys\icons\ $+ %icons $+ \1.ico
  edit "", 1, 4 3 178 10, autohs
  text "Напоминание: При включение скрипта ваш ник автоматически изменяется на прописанный в панели << Настройка ников >> !!! Там вы можете вкл/выкл эту функцию", 35, 2 15 180 200
  button "Настройка ников", 26, 95 30 75 15, flat
}
on *:dialog:fav:sclick:26: {
  /settingsfx
}
on *:dialog:fav:close:0: {
  if ($did(1).text) { set %nicks $did(1).text }
}
alias fav2 {
  if $dialog(fav2) = $null { dialog -m fav2 fav2 }
}
dialog fav2 {
  title ""
  size -1 -1 187 17
  option dbu
  icon sys\icons\ $+ %icons $+ \1.ico
  edit "", 1, 4 3 178 10
}
on *:dialog:fav2:close:0: {
  if ($did(1).text) { set %chanss $did(1).text }
}
alias adchan {
  if ($lines($setdir $+ servers.txt) != 0) {
    var %chan $1
    var %i = 1
    var %network = $2
    while (%i <= $lines($setdir $+ servers.txt)) {
      if ($readini($setdir $+ connect.ini,n,$read($setdir $+ servers.txt,%i),network) == %network) { 
        if (%chan !isin $readini($setdir $+ connect.ini,n,$read($setdir $+ servers.txt,%i),ajoin)) { nsc $read($setdir $+ servers.txt,%i) ajoin $readini($setdir $+ connect.ini,n,$read($setdir $+ servers.txt,%i),ajoin) $+ , $+ %chan | echo -a 4 Канал добавлен в автозаход сети %network | goto end } 
        if (%chan isin $readini($setdir $+ connect.ini,n,$read($setdir $+ servers.txt,%i),ajoin)) { nsc $read($setdir $+ servers.txt,%i) ajoin $remove($readini($setdir $+ connect.ini,n,$read($setdir $+ servers.txt,%i),ajoin), %chan $+ $chr(44)) | echo -a 4 Канал удален из автозахода сети %network }
        else { echo -a 4 Канал уже есть }      
      }
      inc %i
    }  
  }
  :end
}
alias checkchan {
  if ($lines($setdir $+ servers.txt) != 0) {
    var %chan $1
    var %i = 1
    while (%i <= $lines($setdir $+ servers.txt)) {
      if ($readini($setdir $+ connect.ini,n,$read($setdir $+ servers.txt,%i),network) == $network) { 
        if (%chan !isin $readini($setdir $+ connect.ini,n,$read($setdir $+ servers.txt,%i),ajoin)) { return ok | goto end }
        else { return neok }
      }
      inc %i
    }  

  }
  halt
  :end
}
alias doprog {
  var %q = 1 
  while (%q <= $lines($qlinktxt)) {
    if ($gettok($read($qlinktxt,%q),4,42) == 1) { run " $+ $gettok($read($qlinktxt,%q),2,42) $+ " }
    inc %q
  } 
}
alias nicks {
  if (!$dialog(nicks)) { dialog -ma nicks nicks } | else { dialog -av nicks }
}
alias more {
  if (!$dialog(dsopt)) { dialog -ma dsopt dsopt } | else { dialog -av dsopt }
}
alias adfoto { 
  var %foto = $dir="Выбирите Фото..." c:\*.jpg  
  var %foto " $+ %foto $+ " 
  if (%foto) {
    .background -adp %foto
  }
}
alias addwall { 
  var %foto = $dir="Выбирите файл..." c:\*.jpg  
  var %foto " $+ %foto $+ " 
  if (%foto) {
    .background -an %foto
  }
}

alias mdir {
  if (!$1) { run $mircdir }
  else { run $finddir($mircdir,$1,1) }
}
;=====
alias tc mk TopicModelator
dialog TopicModelator {
  title "Топики"
  size -1 -1 610 156
  option pixels
  icon $icl $+ tips.ico
  box "", 1, 5 43 600 40
  box "", 2, 5 77 600 50
  text "Текст Топика : ", 100, 15 57 100 15
  edit "", 101, 95 55 500 22, autohs
  check "Вкл / Выкл Стиль :", 103, 15 95 115 15
  combo 104, 133 92 158 206, drop
  button "Установить", 300, 508 95 87 22
  box "", 1000, 5 -1 600 50
  text "Канал:", 3, 302 95 37 16
  combo 4, 346 92 146 180, size drop
  button "Закрыть", 5, 528 131 75 19, cancel
  text "Осталось:", 6, 7 130 56 16
  text "", 7, 74 130 35 16
  text "символов", 8, 112 130 50 16
}
on 1:DIALOG:TopicModelator:init:0: { TopicExtract | reflen }
on 1:DIALOG:TopicModelator:close:0: { .timerTopicModelatorShow01position off | close -@TopicModelatorShow01 | TopicModelatorShow off | unset %chantopic }
alias TopicModelator { if ($dialog(TopicModelator) == $null)  dialog -m TopicModelator TopicModelator | else dialog -v TopicModelator }
alias TopicExtract {
  if ($active ischan) { did -ca TopicModelator 4 $chan($active) }
  var %nCount = 0
  while (%nCount < $lines(sys\txt\TopicIDX.txt)) {
    inc %nCount
    did -a TopicModelator 104 $read -l $+ %nCount sys\txt\TopicIDX.txt
  }
  var %k = 1
  while (%k <= $chan(0)) {
    if ($chan($active) != $chan(%k)) { did -i TopicModelator 4 %k $chan(%k) }
    inc %k
  }
  did -c TopicModelator 104 1
  if (%cTopicModelator.TargetTopic == $null) {  did -c TopicModelator 103 }
  else { did -ra TopicModelator 101 %cTopicModelator.TargetTopic }
  TopicModelatorShow on
  TopicModelatorShow refresh

}
alias reflen { if ($did(103).state == 1) { did -ra $d 7 $calc(308 - $calc($len($did(TopicModelator,101).text) + $len($read -l $+ $did(TopicModelator,104).sel sys\txt\Topic.txt))) } | if ($did(103).state == 0) { did -ra $d 7 $calc(308 - $calc($len($did(TopicModelator,101).text))) } }
on 1:DIALOG:TopicModelator:sclick:4: { set %chantopic $did(4).seltext  }
on 1:DIALOG:TopicModelator:edit:101: { TopicModelatorShow refresh | reflen }
on 1:DIALOG:TopicModelator:sclick:103: { TopicModelatorShow refresh | reflen }
on 1:DIALOG:TopicModelator:sclick:104: { TopicModelatorShow refresh | reflen }
on 1:DIALOG:TopicModelator:sclick:300: { 
  if ($did(101).text) {
    set %chantopic $did(4).text
    if ($server != $NULL ) { topic %chantopic $TopicModelatorBuild }
    window -a %chantopic
    unset %chantopic
  }
}
on 1:DIALOG:TopicModelator:sclick:301: { TopicModelatorShow off }
alias TopicModelatorShow {
  if ($1 == on) {
    window -c @TopicModelatorShow01
    window -hkdo +dL @TopicModelatorShow01 $calc($dialog(TopicModelator).x + 10) $calc($dialog(TopicModelator).y + 30) 592 36
    window -a @TopicModelatorShow01
    dialog -v TopicModelator
    .timerTopicModelatorShow01position -mo 0 250 TopicModelatorShow refreshposition
  }
  if ($1 == refresh) { 
    clear @TopicModelatorShow01
    echo @TopicModelatorShow01 $TopicModelatorBuild  $+ 
  }
  if ($1 == refreshposition) {
    window $iif($dialog(TopicModelator).active,-o,-u) @TopicModelatorShow01 $calc($dialog(TopicModelator).x + 10) $calc($dialog(TopicModelator).y + 30) 592 36
  }
  if ($1 == off) { unset %chantopic
    window -c @TopicModelatorShow01
    .timerTopicModelatorShow01position off
  }
}
alias TopicModelatorBuild {
  if ($did(TopicModelator,103).state) {
    var %cBuildTopic
    var %cBuildTopic = $read -l $+ $did(TopicModelator,104).sel sys\txt\Topic.txt
    var %cBuildTopic = $replace(%cBuildTopic,&looksharpCustomText,$did(TopicModelator,101).text)
    return %cBuildTopic
  }
  else return $iif($did(TopicModelator,101).text != $null,$did(TopicModelator,101).text,$LookVer)
}
