Advertisement
Tiago_f

Perform dialog

Sep 7th, 2023 (edited)
1,961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 4.21 KB | None | 0 0
  1. alias sdt {
  2.   if ($did($did).state) { set % $+ $1 1 }
  3.   else { unset % $+ $1 }
  4. }
  5. alias _hmake {
  6.   if ($hget($1)) { hfree $1 }
  7.   hmake $1-
  8. }
  9. alias _txtdir { return $+($scriptdir,txt\,$1) }
  10. alias netsel.load {
  11.   if ($ini(servers.ini,servers,0)) {
  12.     window -h @loadnets
  13.     _hmake servtmp
  14.     loadbuf -tservers @loadnets servers.ini
  15.     var %i = $line(@loadnets,0), %nd = $token(%autoperform,0,32)
  16.     while (%i) {
  17.       if ($regex(loadnet,$line(@loadnets,%i),/^n\d+=.+SERVER:.+GROUP:([^:]+)/i)) && ($regml(loadnet,1) !isnum) && (!$hget(servtmp,$v1)) {
  18.         var %t = $regml(loadnet,1), %nn = %autoperform
  19.         if (!$istok(%nn,%t,32)) { did -a $dname 1 %t }
  20.         hadd servtmp $regml(loadnet,1) 1
  21.       }
  22.       dec %i
  23.     }
  24.     hfree servtmp
  25.     close -@ @loadnets
  26.   }
  27. }
  28. alias perforead {
  29.   var %line,%f $_txtdir(perform.txt),%l $lines(%f)
  30.   if ($read(%f,tnw,[[ $+ %previousnet $+ ]])) {
  31.     var %line $readn + 1
  32.     while (%line <= %l) {
  33.       var %r $read(%f,tn,%line)
  34.       if (!$regex(%r,/^\[[^\]\[]+\]$/)) && ($readn <= %l) {
  35.         write -dl %line $qt(%f)
  36.         dec %l
  37.       }
  38.       else { break }
  39.     }
  40.   }
  41.   if ($didtok($dname,11,10).text == $null) {
  42.     if (%line) write -dl $calc(%line -1) $qt(%f)
  43.   }
  44.   else {
  45.     if (%line) { write -il $v1 $qt(%f) $didtok($dname,11,10).text }
  46.     else { write $qt(%f) [[ $+ %previousnet $+ ]] $+ $crlf $+ $didtok($dname,11,10).text }
  47.   }
  48. }
  49. dialog netsel {
  50.   title "Add network"
  51.   size -1 -1 212 203
  52.   list 1, 6 21 118 177, sort size vsbar
  53.   button "&OK", 2, 131 144 76 23, ok
  54.   button "&Cancel", 3, 131 172 76 23, cancel
  55.   text "Select network:", 4, 8 5 82 14
  56. }
  57. on *:dialog:netsel:*:*:{
  58.   if ($devent == init) { netsel.load }
  59.   elseif ($devent == sclick) {
  60.     if ($did == 2) && ($did(1).seltext) { set %netsel.result $did(1).seltext }
  61.   }
  62.   elseif ($devent == dclick) && ($did == 1) {
  63.     set %netsel.result $did(1).seltext
  64.     dialog -c $dname
  65.   }
  66. }
  67. alias perform { dialog -m perform perform }
  68.  
  69. dialog perform {
  70.   title "Perform"
  71.   size -1 -1 293 320
  72.   check "E&nable perform on connect", 1, 10 15 155 14
  73.   text "Perform commands:", 2, 10 115 120 14
  74.   text "Network:", 3, 10 45 120 14
  75.   combo 4, 8 61 136 160, size sort drop
  76.   edit "", 11, 8 132 277 147, multi return hsbar vsbar
  77.   button "&Add", 14, 150 61 76 23
  78.   button "&Delete", 15, 150 90 76 23
  79.   button "&OK", 12, 128 289 76 23, ok
  80.   button "&Cancel", 13, 210 289 76 23, cancel
  81. }
  82. on *:dialog:perform:*:*:{
  83.   if ($devent == init) {
  84.     if (%perform.net) { did -c $dname 1 }
  85.     if (%autoperform == $null) { did -ca $dname 4 All Networks | set %previousnet perform }
  86.     else {
  87.       didtok $dname 4 32 %autoperform
  88.       did -c $dname 4 1
  89.       set %previousnet $did(4).seltext
  90.     }
  91.     var %f = $_txtdir(perform.txt)
  92.     if ($read(%f,tnw,[[ $+ %previousnet $+ ]])) loadbuf -ot $+ %previousnet $dname 11 %f
  93.   }
  94.   elseif ($devent == sclick) {
  95.     if ($did == 1) { sdt perform.net }
  96.     elseif ($did == 4) {
  97.       perforead
  98.       var %f $_txtdir(perform.txt)
  99.       did -r $dname 11
  100.       if (%autoperform != $null) { set %previousnet $did(4).seltext }
  101.       if ($read(%f,tnw,[[ $+ %previousnet $+ ]])) loadbuf -ot $+ %previousnet perform 11 $_txtdir(perform.txt)
  102.     }
  103.     elseif ($did == 12) { perforead }
  104.     elseif ($did == 14) {
  105.       perforead
  106.       noop $dialog(netsel,netsel,-4)
  107.       if (%netsel.result) {
  108.         if (%autoperform == $null) { did -d perform 4 1 }
  109.         set %autoperform $addtok(%autoperform,%netsel.result,32)
  110.         did -r $dname 11
  111.         did -ca $dname 4 %netsel.result
  112.         set %previousnet %netsel.result
  113.         unset %netsel.result
  114.       }
  115.     }
  116.     elseif ($did == 15) {
  117.       did -r $dname 4,11
  118.       perforead
  119.       if (%autoperform) {
  120.         var %c $_txtdir(perform.txt)
  121.         set %autoperform $remtok(%autoperform,%previousnet,32)
  122.         didtok $dname 4 32 %autoperform
  123.         did -c $dname 4 1
  124.         set %previousnet $did(4).seltext
  125.         if ($read(%c,tnw,[[ $+ %previousnet $+ ]])) loadbuf -ot $+ %previousnet perform 11 %c
  126.       }
  127.       if (%autoperform == $null) {
  128.         did -ca $dname 4 All Networks
  129.         set %previousnet perform
  130.       }
  131.     }
  132.   }
  133.   elseif ($devent == close) { unset %previousnet }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement