My Theme — File Browser

MyThemev5.7 / MyThemev5.7 / theme.mrc

theme.mrc — 65.22 KB — Download this file

; My Theme v5.7 - by entropy 2022 (released: 6/21/23)

; Before installing this script, make sure you have installed the fixed width font Liberation Mono!
; Works well with Channels/Queries maximized.

alias -l sversion { return v5.7 }
alias -l syear { return 2023 }
alias -l sauthor { return entropy }

alias swap { msg $1- }

on *:load:{
  if ($version < 7.52) { 
    echo $color(own) -tag [ERROR] * You must be using mIRC version: 7.52 or greater to use this theme system!
    .unload -rs $qt($script)
    return
  }

  window -x $qt($active)

  %theme_services = Q X NS CS HS OS HS MS NickServ ChanServ HostServ OperServ MemoServ X@channels.undernet.org

  %theme_oldfont = $qt($window($active).font)
  %theme_oldsize = $window($active).fontsize

  %theme_font = "Liberation Mono"
  %theme_size = 16
  %theme_mycolor = 07
  %theme_spaces = Yes
  %theme_getip = Off

  font -z %theme_size %theme_font

  %theme_show = yes
  %theme_bg = On
  %theme_black = On
  %theme_acro = Off
  %theme_left = (
  %theme_right = )
  %theme_oper = 00
  %theme_away = 71
  %theme_fix = Off
  %theme_censor = Off
  %theme_caps = Off
  %theme_style = 13
  %theme_stylestatus = Off
  %theme_percent = 85
  %theme_swears = cunt punani prick twat arsehole cum slut dick cock asshole bitch pussy fuck shit penis vagina whore fag nigger nigga gook spic chink
  %theme_image = $qt($scriptdirImages\default.bmp)
  %theme_notices = active

  if (!$isdir($qt($scriptdirImages))) { mkdir $qt($scriptdirImages) }

  %theme_treebar = $replace($treebar,1,On,0,Off)
  %theme_switchbar = $replace($switchbar,1,On,0,Off)
  %theme_toolbar = $replace($toolbar,1,On,0,Off)

  %theme_keep = Off
  %theme_prefix = On
  %theme_global = On

  %theme_oldformat = $timestampfmt
  %theme_format = [hh:nn:sstt]

  %theme_oldtreebar = $replace($treebar,1,On,0,Off)
  %theme_oldswitchbar = $replace($switchbar,1,On,0,Off)
  %theme_oldtoolbar = $replace($toolbar,1,On,0,Off)

  .treebar on
  %theme_treebar = On

  .switchbar off
  %theme_switchbar = Off

  .toolbar on
  %theme_toolbar = On

  .cnick on
  getcolor
  restorecolor
  restoreacronyms
  saveoriginalsettings

  .timestamp on
  .timestamp -f %theme_format
  .timestamp -g %theme_format

  whoall

  bgall

  echos load
}

on *:unload:{

  var %a = 1, %b
  while ($scon(%a)) {
    .scid $v1
    background -xs
    inc %a
  }
  .scid -r


  .scon -at1 clearall
  echos unload

  if (%theme_oldtoolbar == On) { .toolbar on }
  else { .toolbar off }

  if (%theme_oldswitchbar == On) { .switchbar on } 
  else { .switchbar off }

  if (%theme_oldtreebar == On) { .treebar on } 
  else { .treebar off }

  .timestamp on
  .timestamp -f %theme_oldformat
  .timestamp -g %theme_oldformat

  bgclearall
  cleanup
  .cnick off

  .timerstate off
  window -r $qt($active)


  var %a = 1, %b
  while ($findfile($scriptdirImages\,*.bmp, %a)) {
    var %b = $v1
    if ($nopath(%b) != default.bmp) { .remove $qt(%b) }
    inc %a
  }
  remini $mircini windows
  remini $mircini chanhist
  remini $mircini backgrounds
  remini $mircini fonts
  flushini $mircini

  font -z %theme_oldfont %theme_oldsize
}


alias -l b {
  if (!$isid) { return }
  return $+(%theme_bl,$upper($1),%theme_br)
}


alias -l echos {
  var %a = 1
  while ($scon(%a)) {
    .scid $v1
    if ($1 == load) { echo $color(notify) -tsg * [LOAD] Welcome to My Theme $sversion - by $sauthor $syear }
    if ($1 == unload) { echo $color(notify) -tsg * [UNLOAD] Thank you for using My Theme $sversion - by $sauthor $syear }
    inc %a
  }
  .scid -r
}


alias -l acolor {
  if (!%result) { return }
  window -c @colors
  if (%result isin oper away) {  
    if (%result == oper) { %theme_oper = $1 }
    if (%result == away) { %theme_away = $1 }
    echo $color(info) -tag * $iif(%result == oper,Oper,$iif(%result == away,Away)) color is now: $+($chr(3),$1,$1,$chr(3))
  }
  else {
    %theme_mycolor = $1
    echo $color(info) -tag * BG Text color is now: $+($chr(3),$1,$1,$chr(3))
    bgall
  }
  unset %result
}

alias -l showcolors {
  if (!$exists($qt($scriptdirImages\colors.png))) { return }
  if ($1 == oper) { %result = oper }
  elseif ($1 == away) { %result = away }
  elseif ($1 == text) { %result = text }
  else { return }
  window -c @Colors
  window -dpfCw0ok0 +tn @Colors -1 -1 317 242

  if (%result == text) {
    titlebar @Colors BG Text (Current: %theme_mycolor $+ )
  }
  else {  
    titlebar @Colors $+($upper($mid(%result,1,1)),$lower($mid(%result,2))) (Current: $eval($+(%,theme_,%result),3) $+ )
  }
  drawpic -sc @Colors 0 0 $qt($scriptdirImages\colors.png)
}

on *:close:@Colors:{ unset %result }

alias -l domouse {
  if ($mouse.x isnum $1 && $mouse.y isnum $2) { acolor $3 }
}

menu @Colors {
  sclick {
    ;OLD COLORS (top)
    domouse 5-28 5-28 00
    domouse 32-54 5-28 01
    domouse 58-78 5-28 02
    domouse 82-107 5-28 03
    domouse 111-132 5-28 04
    domouse 136-157 5-28 05
    domouse 162-183 5-28 06
    domouse 188-209 5-28 07

    ;OLD COLORS (bottom)
    domouse 5-28 32-54 08
    domouse 32-54 32-54 09
    domouse 58-78 32-54 10
    domouse 82-107 32-54 11
    domouse 111-132 32-54 12
    domouse 136-157 32-54 13
    domouse 162-183 32-54 14
    domouse 188-209 32-54 15

    ;NEW COLORS


    ;ROW 1
    domouse 5-28 61-81 16
    domouse 32-54 61-81 17
    domouse 58-78 61-81 18
    domouse 82-107 61-81 19
    domouse 111-132 61-81 20
    domouse 136-157 61-81 21
    domouse 162-183 61-81 22
    domouse 188-209 61-81 23
    domouse 214-235 61-81 24
    domouse 240-261 61-81 25
    domouse 267-287 61-81 26
    domouse 293-313 61-81 27


    ;ROW 2
    domouse 5-28 87-108 28
    domouse 32-54 87-108 29
    domouse 58-78 87-108 30
    domouse 82-107 87-108 31
    domouse 111-132 87-108 32
    domouse 136-157 87-108 33
    domouse 162-183 87-108 34
    domouse 188-209 87-108 35
    domouse 214-235 87-108 36
    domouse 240-261 87-108 37
    domouse 267-287 87-108 38
    domouse 293-313 87-108 39    


    ;ROW 3
    domouse 5-28 113-134 40
    domouse 32-54 113-134 41
    domouse 58-78 113-134 42
    domouse 82-107 113-134 43
    domouse 111-132 113-134 44
    domouse 136-157 113-134 45
    domouse 162-183 113-134 46
    domouse 188-209 113-134 47
    domouse 214-235 113-134 48
    domouse 240-261 113-134 49
    domouse 267-287 113-134 50
    domouse 293-313 113-134 51    


    ;ROW 4
    domouse 5-28 140-161 52
    domouse 32-54 140-161 53
    domouse 58-78 140-161 54
    domouse 82-107 140-161 55
    domouse 111-132 140-161 56
    domouse 136-157 140-161 57
    domouse 162-183 140-161 58
    domouse 188-209 140-161 59
    domouse 214-235 140-161 60
    domouse 240-261 140-161 61
    domouse 267-287 140-161 62
    domouse 293-313 140-161 63      


    ;ROW 5
    domouse 5-28 165-187 64
    domouse 32-54 165-187 65
    domouse 58-78 165-187 66
    domouse 82-107 165-187 67
    domouse 111-132 165-187 68
    domouse 136-157 165-187 69
    domouse 162-183 165-187 70
    domouse 188-209 165-187 71
    domouse 214-235 165-187 72
    domouse 240-261 165-187 73
    domouse 267-287 165-187 74
    domouse 293-313 165-187 75        


    ;ROW 6
    domouse 5-28 192-213 76
    domouse 32-54 192-213 77
    domouse 58-78 192-213 78
    domouse 82-107 192-213 79
    domouse 111-132 192-213 80
    domouse 136-157 192-213 81
    domouse 162-183 192-213 82
    domouse 188-209 192-213 83
    domouse 214-235 192-213 84
    domouse 240-261 192-213 85
    domouse 267-287 192-213 86
    domouse 293-313 192-213 87


    ;ROW 7
    domouse 5-28 217-238 88
    domouse 32-54 217-238 89
    domouse 58-78 217-238 90
    domouse 82-107 217-238 91
    domouse 111-132 217-238 92
    domouse 136-157 217-238 93
    domouse 162-183 217-238 94
    domouse 188-209 217-238 95
    domouse 214-235 217-238 96
    domouse 240-261 217-238 97
    domouse 267-287 217-238 98

    unset %result
    whoall
  }
}


alias -l whoaway {
  if ($1 ischan && $server) {
    who $1
  }
}
alias -l default {
  if ($1 ischan) { 
    var %a = 1
    while ($nick($1,%a)) {
      .cline -r $1 $v1
      inc %a
    }
  }
}


alias -l whoisscon {
  if ($query($1)) { echo $color(whois) -tg $1 * [WHOIS] $1- }
  else { echo $color(whois) $iif($activecid == $cid,-a,-s) $+ tg * [WHOIS] $1- }
  halt
}
alias whoisfirst {
  if ($query($1)) { echo $color(whois) $1 - }
  else { echo $color(whois) $iif($activecid == $cid,-a,-s) $+ g - }
}

; WHOIS RAWS

raw 311:*:{ 
  var %tld = $gettok($4,-1,46)
  if ($hget(tld,%tld)) { whoisscon $2 Host: $+($3,@,$4) $5- * TLD: $v1 }
  else { whoisscon $2 Host: $+($3,@,$4) $5- }
}
raw 319:*:{ whoisscon $2 Channels: $3- }
raw 312:*:{ whoisscon $2 Server: $3- }
raw 330:*:{ whoisscon $2 Logged in as: $2 }
raw 317:*:{ whoisscon $2 Idle: $remove($replace($duration($3),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32)) $+ , Signon: $asctime($4) ( $+ $remove($replace($duration($calc($ctime - $4)),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32)) ago) }
raw 338:*:{ whoisscon $2 is actually: $3- }
raw 307:*:{ whoisscon $2- }
raw 671:*:{ whoisscon $2 is using a secure connection (SSL) }
raw 313:*:{ whoisscon $2 is an IRC Operator $iif($4-6 != an IRC Operator,$+($chr(40),$4-,$chr(41))) }
raw 301:*:{ whoisscon $2 is away: $+(",$remove($3-,:),") }
raw 378:*:{ 
  whoisscon $2-
}
raw 379:*:{ whoisscon $2- }
raw 320:*:{ whoisscon $2- }
raw 318:*:{ whoisscon $2- }
raw 401:*:{ whoisscon $2- }
raw 301:*:{ whoisscon $2- }
raw 335:*:{ whoisscon $2 $strip($3-) }

raw 439:*:{ halt }

; MODE ON JOIN
;raw 324:*:{ echo $color(info2) $iif($active == Status Window,-tsg,-tg $2) * [MODE] $iif($active == Status Window,$2-,$3-) | halt } 

; CREATED BY ON JOIN
;raw 329:*:{ echo $color(info2) $iif($active == Status Window,-tsg,-tg $2) * [CREATED] $iif($active == Status Window,$2 $asctime($3),$asctime($3)) | halt } 



; Connect RAWS

raw 001:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 002:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 003:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 004:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 005:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 251:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 252:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 254:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 255:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 265:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 266:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 250:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }
raw 253:*:{ echo $color(info2) -tsg * [RAWS] $remove($2-,:) | halt }

raw 422:*:{ echo $color(info) -tsg * [MOTD] - MOTD file is missing | halt }
raw 375:*:{ echo $color(info) -tsg * [MOTD] - $remove($3-,:)  | halt }
raw 372:*:{ var %text = [MOTD] $replace($parms,$chr(32),$chr(160)) | echo $color(info) -tsg * [MOTD] $replace(%text,[MOTD] $sauthor,-, $+(-,$chr(160),-),-) | halt }
raw 376:*:{ echo $color(info) -tsg * [MOTD] - End of /MOTD command. | halt }

raw 396:*:{ echo $color(info2) -tsg * [HOST] $2- | halt }

raw 276:*:{ echo $color(info) -tsg * [CERT] $qt($2) $3- | halt }


raw 439:*:{
  ;Target Change too fast (when joining)!
  $+(.timer,changetarget,$2) -o 1 $calc($9 + 5) join $unsafe($2)
}

; /WHO LIMIT
raw 263:*:{ halt }

;NOTIFY
on ^*:notify:{
  if ($isfile($notify($nick).sound)) { .splay $qt($notify($nick).sound) }
  echo $color(notify) -tsg * [ONLINE] $nick
  halt
}
on ^*:unotify:{ echo $color(notify) -tsg * [OFFLINE] $nick has left IRC | halt }

;WHO RAWS

raw 352:*:{
  var %a = 1, %b
  while ($comchan($6,%a)) {
    %b = $v1
    var %r = $fline(%b,$6,1,1)
    if (* isin $7 && $6 != $me) { .cline %theme_oper %b %r }
    elseif (G isincs $7 && $6 != $me) { .cline %theme_away %b %r }
    elseif (H isincs $7 && %r) { .cline -r %b %r }
    inc %a
  }
  halt
}
raw 315:*:{ halt }

alias -l whoall {
  var %a = 1, %b
  while ($scon(%a)) {
    .scid $v1
    var %x = 1, %y, %net = $network
    while ($chan(%x)) {
      %y = $v1
      whoaway %y
      .timer $+ who $+ %y $+ %net 0 1800 whoaway $unsafe(%y)
      inc %x
    }
    inc %a
  }
  .scid -r
}


on *:start:{
  if (!$hget(acronyms)) { hmake acronyms 100 }
  if (!$hget(settings)) { hmake settings 100 }

  if ($exists($qt($scriptdiracronyms.dat))) { hload acronyms $qt($scriptdiracronyms.dat) }
  if ($exists($qt($scriptdirsettings.dat))) { hload settings $qt($scriptdirsettings.dat) }

  if ($scon(0) == 1 && !$server) { bg $network -s }

  if (!$hget(tld)) { 
    hmake tld 100
    if ($exists($qt($scriptdirtld.dat))) { hload tld $qt($scriptdirtld.dat) }
  }
}

menu menubar,status,channel,query {
  -
  Theme $sversion
  .Theme Status $chr(9) $iif($group(#theme).status == on,On,Off) {
    $iif($group(#theme).status == on,.disable,.enable) #theme
    echo $color(info) -tag * Theme is now: $replace($group(#theme).status,on,On,off,Off)
  }
  .-
  .Font/Size $chr(9) $+($remove(%theme_font,"),/,%theme_size) { 
    font
    %theme_font = $qt($window($active).font)
    %theme_size = $window($active).fontsize

    font -z %theme_size %theme_font
    if (%theme_bg == On) { bgall } 
    else { bgclearall } 
    echo $color(info) -tag * Font is now: %theme_font - Size is now: %theme_size
  }
  .-
  .Nick
  ..Spaces $chr(9) $replace(%theme_spaces,yes,Yes,no,No) {
    %theme_spaces = $iif(%theme_spaces == Yes,No,Yes)
    echo $color(info) -tag * Spaces are now: %theme_spaces
  }
  ..-
  ..Brackets $chr(9) $iif(!%theme_left && !%theme_right,None,%theme_left $+ $me $+ %theme_right)
  ...$iif(%theme_left == $chr(40),$style(1)) 1 ( $+ $me $+ ) { %theme_left = $chr(40) | %theme_right = $chr(41) | echo -tag [BRACKETS] * Are now: %theme_left %theme_right }
  ...$iif(%theme_left == $chr(91),$style(1)) 2 $chr(91) $+ $me $+ $chr(93) { %theme_left = $chr(91) | %theme_right = $chr(93) | echo -tag [BRACKETS] * Are now: %theme_left %theme_right }
  ...$iif(%theme_left == $chr(123),$style(1)) 3 $chr(123) $+ $me $+ $chr(125) { %theme_left = $chr(123) | %theme_right = $chr(125) | echo -tag [BRACKETS] * Are now: %theme_left %theme_right }
  ...$iif(%theme_left == $chr(171),$style(1)) 4 $chr(171) $+ $me $+ $chr(187) { %theme_left = $chr(171) | %theme_right = $chr(187) | echo -tag [BRACKETS] * Are now: %theme_left %theme_right }
  ...$iif(%theme_left == <,$style(1)) 5 < $+ $me $+ > { %theme_left = < | %theme_right = > | echo -tag [BRACKETS] * Are now: %theme_left %theme_right }
  ...-
  ...$iif(%theme_left == $null,$style(1)) None { %theme_left = "" | %theme_right = "" | echo -tag [BRACKETS] * Are now: None }
  ..-
  ..Oper Color $chr(9) %theme_oper {
    showcolors oper
  } 
  ..-
  ..Away Color $chr(9) %theme_away {
    showcolors away
  }  
  ..-
  ..Styler $chr(9) %theme_stylestatus {
    %theme_stylestatus = $iif(%theme_stylestatus == On,Off,On)
    echo $color(info) -tag * Nick Styler is now: %theme_stylestatus  
  }
  ..Style $chr(9) %theme_style { styles }
  ..-
  ..Show Mode Prefix $chr(9) %theme_prefix {
    %theme_prefix = $iif(%theme_prefix == On,Off,On)
    echo $color(info) -tag * Show Mode Prefix is now: %theme_prefix
  }
  .-
  .Text Manipulators
  ..Sentence Correction $chr(9) %theme_fix {
    %theme_fix = $iif(%theme_fix == On,Off,On)
    echo $color(info) -tag * Sentence Correction is now: %theme_fix  
  }
  ..Censor Correction $chr(9) %theme_censor {
    %theme_censor = $iif(%theme_censor == On,Off,On)
    echo $color(info) -tag * Censor Correction is now: %theme_censor  
  }
  ..Acronyms Correction $chr(9) %theme_acro {
    %theme_acro = $iif(%theme_acro == On,Off,On)
    echo $color(info) -tag * Acronyms are now: %theme_acro  
  }
  ..All Caps Correction $chr(9) %theme_caps {
    %theme_caps = $iif(%theme_caps == On,Off,On)
    echo $color(info) -tag * All Caps Correction is now: %theme_caps  
  }
  ..-
  ..All Manipulators On { 
    %theme_fix = On
    %theme_censor = On
    %theme_acro = On
    %theme_caps = On
    echo $color(info) -tag * Text Manipulators are now: On  
  }
  ..All Manipulators Off { 
    %theme_fix = Off
    %theme_censor = Off
    %theme_acro = Off
    %theme_caps = Off
    echo $color(info) -tag * Text Manipulators are now: Off  
  }
  .-
  .Dynamic Backgrounds
  ..Text Background Status $chr(9) %theme_bg {
    %theme_bg = $iif(%theme_bg == On,Off,On)
    echo $color(info) -tag * Text Background Status is now: %theme_bg
    bgclearall
    bgall
  }
  ..Background Text Color $chr(9) %theme_mycolor {
    showcolors text
  }
  ..-
  ..Image Background Status $chr(9) %theme_black {
    %theme_black = $iif(%theme_black == On,Off,On)
    echo $color(info) -tag * Image Background Status is now: %theme_black
    bgclearall
    bgall
  }
  ..Image $chr(9) $mid(%theme_image,1,20) $+ ... {
    %theme_image = $qt($sfile($scriptdirImages\*.jpg,Theme Background Image:,Got it!))
    if ($pic(%theme_image).width < 800 || $pic(%theme_image).height < 600) {
      echo $color(info) -tag * Theme Background Image must at least be 800px width and 600 height!
      return
    }
    if (%theme_image) {
      echo $color(info) -tag * Theme Background Image is now: %theme_image
      bgall
    }
  }  
  .-
  .Restore Colors
  ..Theme { restorecolor }
  ..Default { restoredefault }
  .-
  .Settings
  ..Save Settings { saveoriginalsettings | echo $color(info) -tag * Saved All Settings. }
  ..Restore Settings { reloadoriginalsettings | echo $color(info) -tag * Restored All Settings. }
  ..-
  ..Global Timestamp $chr(9) %theme_global {
    %theme_global = $iif(%theme_global == On,Off,On)
    if (%theme_global == On) { .timestamp on }
    else { .timestamp off }
    echo $color(info) -tag * Global Timestamp is now: %theme_global
  }
  ..-
  ..IP Lookup $chr(9) %theme_getip {
    %theme_getip = $iif(%theme_getip == On,Off,On)
    echo $color(info) -tag * IP Lookup is now: %theme_getip
  }
  ..-
  ..Timestamp Format $chr(9) %theme_format {
    %theme_format = $input(New Timestamp Format?,5)
    echo $color(info) -tag * Timestamp Format is now: %theme_format
    .timestamp on
    .timestamp -f %theme_format
    .timestamp -g %theme_format
  }
  ..-
  ..Keep Channels Open On Disconnect $chr(9) %theme_keep {
    %theme_keep = $iif(%theme_keep == On,Off,On)
    echo $color(info) -tag * Keep Channels Open On Disconnect is now: %theme_keep
  }
  ..-
  ..Caps Correction Percent $chr(9) $iif(%theme_percent,$v1,0) $+ % {
    %theme_percent = $remove($input(Max percent caps?,5),%)
    echo $color(info) -tag * Caps Percent is now: %theme_percent $+ % 
  }
  ..-
  ..Notices $chr(9) $iif(%theme_notices == active,Active,Status) { %theme_notices = $iif(%theme_notices == active,status,active) | echo $color(info) -tag * Notices are now being sent to: %theme_notices }
  ..-
  ..Acronyms List { doacronyms }
  ..-
  ..Services Nicknames List
  ... %theme_services
  ...-
  ...Add { 
    var %a = $input(Add Services nicknames? $+ $crlf $+ %theme_services,5)
    if (%a) {
      var %s = 1, %b
      while ($gettok(%a,%s,32)) { %b = $v1 | if (!$istok(%theme_services,%b,32)) { %theme_services = $addtok(%theme_services,%b,32) } | inc %s }
      noop $input(Services Nickname list: $+ $crlf $+ %theme_services,4)
    }
  }
  ...Delete { 
    var %a = $input(Delete Services nicknames? $+ $crlf $+ %theme_services,5)
    if (%a) {
      var %s = 1, %b
      while ($gettok(%a,%s,32)) { %b = $v1 | if ($istok(%theme_services,%b,32)) { %theme_services = $remtok(%theme_services,%b,1,32) } | inc %s }
      noop $input(Services Nickname list: $+ $crlf $+ %theme_services,4)
    }
  }
  ...-
  ...Clear {
    unset %theme_services
    noop $input(Services Nicknames list cleared!,4)
  }
  ..-
  ..Censor List 
  ... %theme_swears
  ...-
  ...Add { 
    var %a = $input(Add Swear words? $+ $crlf $+ %theme_swears,5)
    if (%a) {
      var %s = 1, %b
      while ($gettok(%a,%s,32)) { %b = $v1 | if (!$istok(%theme_swears,%b,32)) { %theme_swears = $addtok(%theme_swears,%b,32) } | inc %s }
      noop $input(Swears list: $+ $crlf $+ %theme_swears,4)
    }
  }
  ...Delete { 
    var %a = $input(Delete Swear words? $+ $crlf $+ %theme_swears,5)
    if (%a) {
      var %s = 1, %b
      while ($gettok(%a,%s,32)) { %b = $v1 | if ($istok(%theme_swears,%b,32)) { %theme_swears = $remtok(%theme_swears,%b,1,32) } | inc %s }
      noop $input(Swears list: $+ $crlf $+ %theme_swears,4)
    }
  }
  ...-
  ...Clear {
    unset %theme_swears
    noop $input(Swears list cleared!,4)
  }
  .-
  .Check for Updates $chr(9) $iif(%theme_last,(last upgraded $remove($replace($duration($calc($ctime - %theme_last)),wks,w,wk,w,days,d,day,d,hrs,hr,mins,m,min,m,secs,s,sec,s),$chr(32)) ago)) { check }
  .-
  .Credits { echo $color(info) -tag * My Theme $sversion was created by $sauthor in $syear }
  .-
  .Unload { .unload -rs $qt($script) }
  -
}


alias doacronyms {
  window -c @acronyms
  window -ldpfCw0ok0s +tn @acronyms -1 -1 400 690

  var %a = 1, %b, %c, %d = 1
  while ($hget(acronyms,%a).item) {
    %b = $v1
    %c = $hget(acronyms,%b)
    aline -l @acronyms %b $chr(9) %c
    inc %d
    inc %a
  }   
}
menu @acronyms {
  dclick { 
    var %r = $gettok($sline(@acronyms,1),1,9)
    var %r2 = $gettok($sline(@acronyms,1),3-,9)
    var %t = $input(New value for: %r ,5)
    if (%t) {  
      hadd -m acronyms %r %t
      doacronyms
    }
  }
  -
  Add { 
    var %r = $input(New Acronym and definintion: (space delimited),5)
    var %s = $gettok(%r,1,32)
    if ($hget(acronyms,%s)) { noop $input(Acronym Exists!,4) }
    elseif ($gettok(%r,2-,32)) { 
      hadd -m acronyms %r
      doacronyms
    }
  }
  -
  Remove Selected {
    var %a = 1, %b, %total
    while ($line(@acronyms,%a)) {
      var %all = $gettok($line(@acronyms,$sline(@acronyms,%a).ln,1),1,9)
      if (%all) { inc %total | hdel acronyms %all }
      inc %a
    }
    doacronyms
  }
  Remove All {
    var %a = $line(@acronyms,0), %b
    while ($line(@acronyms,%a)) {
      dline @acronyms %a
      inc %a
    }
    hfree acronyms
    hmake acronyms 100
    doacronyms
  }
  -
  Select All {
    var %a = 1, %b
    while (%a <= $line(@acronyms,0)) {
      sline -a @acronyms %a
      inc %a
    }
  }
  -
  Save Database { 
    hsave -o acronyms $qt($scriptdiracronyms.dat)
    noop $input(Database has been saved.,4)
  }
  -
  Restore Last Updated Database { noop $input(Last updated database has been restored.,4) | restorelastacronyms | doacronyms }
  -
  Restore Default Database { noop $input(Default database has been restored.,4) | restoreacronyms | doacronyms }
  -
  Close { window -c @acronyms }
}

alias -l getcolor {
  %get_bg = $color(background)
  %get_editbox = $color(editbox)
  %get_treebar = $color(treebar)
  %get_treebartext = $color(treebar text)
  %get_editboxtext = $color(editbox text)
  %get_listboxtext = $color(listbox text)
  %get_action = $color(action)
  %get_ctcp = $color(ctcp)
  %get_highlight = $color(highlight)
  %get_info = $color(info)
  %get_info2 = $color(info2)
  %get_inactive = $color(inactive)
  %get_invite = $color(invite)
  %get_join = $color(join)
  %get_kick = $color(kick)
  %get_list = $color(list)
  %get_mode = $color(mode)
  %get_nick = $color(nick)
  %get_normal = $color(normal)
  %get_notice = $color(notice)
  %get_notify = $color(notify)
  %get_other = $color(other)
  %get_own = $color(own)
  %get_part = $color(part)
  %get_quit = $color(quit)
  %get_topic = $color(topic)
  %get_wallops = $color(wallops)
  %get_whois = $color(whois)
  %get_titletext = $color(title text)
  %get_gray = $color(gray)
}

alias -l restoreoriginal {
  color background %get_bg
  color editbox %get_editbox
  color list %get_list
  color treebar %get_treebar
  color treebar text %get_treebartext
  color editbox text %get_editboxtext
  color inactive %get_inactive
  color listbox text %get_listboxtext
  color action %get_action  
  color ctcp %get_ctcp
  color highlight %get_highlight
  color info %get_info
  color info2 %get_info2
  color invite %get_invite
  color join %get_join
  color kick %get_kick
  color mode %get_mode
  color nick %get_nick
  color normal %get_normal
  color notice %get_notice
  color notify %get_notify
  color other %get_other
  color own %get_own
  color part %get_part
  color quit %get_quit
  color topic %get_topic
  color wallops %get_wallops
  color whois %get_whois
  color title text %get_titletext
  color gray %get_gray
  if (%theme_oldsize && %theme_oldfont) { font -z %theme_oldsize %theme_oldfont }
}

alias -l saveoriginalsettings {
  var %y = hadd -m settings
  %y oldfont %theme_oldfont
  %y oldsize %theme_oldsize
  %y font %theme_font
  %y size %theme_size
  %y mycolor %theme_mycolor
  %y spaces %theme_spaces
  %y bg %theme_bg
  %y black %theme_black
  %y acro %theme_acro
  %y left %theme_left
  %y right %theme_right
  %y oper %theme_oper
  %y away %theme_away
  %y fix %theme_fix
  %y censor %theme_censor
  %y caps %theme_caps
  %y style %theme_style
  %y stylestatus %theme_stylestatus
  %y percent %theme_percent
  %y swears %theme_swears
  %y image %theme_image
  %y treebar %theme_treebar
  %y switchbar %theme_switchbar
  %y toolbar %theme_toolbar
  %y keep %theme_keep
  %y prefix %theme_prefix
  %y oldformat %theme_oldformat
  %y format %theme_format
  %y global %theme_global
  %y oldtreebar %theme_oldtreebar
  %y oldtoolbar %theme_oldtoolbar
  %y oldswitchbar %theme_oldswitchbar
  hsave -o settings $qt($scriptdirsettings.dat)
}

alias -l reloadoriginalsettings {
  %theme_oldfont = $hget(settings,oldfont)
  %theme_oldsize = $hget(settings,oldsize)
  %theme_font = $hget(settings,font)
  %theme_size = $hget(settings,size)
  %theme_mycolor = $hget(settings,mycolor)
  %theme_spaces = $hget(settings,spaces)
  %theme_bg = $hget(settings,bg)
  %theme_black = $hget(settings,black)
  %theme_acro = $hget(settings,acro)
  %theme_left = $hget(settings,left)
  %theme_right = $hget(settings,right)
  %theme_oper = $hget(settings,oper)
  %theme_away = $hget(settings,away)
  %theme_fix = $hget(settings,fix)
  %theme_censor = $hget(settings,censor)
  %theme_caps = $hget(settings,caps)
  %theme_style = $hget(settings,style)
  %theme_stylestatus = $hget(settings,stylestatus)
  %theme_percent = $hget(settings,percent)
  %theme_swears = $hget(settings,swears)
  %theme_image = $hget(settings,image)
  %theme_treebar = $hget(settings,treebar)
  %theme_switchbar = $hget(settings,switchbar)
  %theme_toolbar = $hget(settings,toolbar)
  %theme_keep = $hget(settings,keep)
  %theme_prefix = $hget(settings,prefix)
  %theme_oldformat = $hget(settings,oldformat)
  %theme_format = $hget(settings,format)
  %theme_global = $hget(settings,global)
  %theme_oldtreebar = $hget(settings,oldtreebar)
  %theme_oldtoolbar = $hget(settings,oldtoolbar)
  %theme_oldswitchbar = $hget(settings,oldswitchbar)
}

alias -l b { return $+($chr(2),$1-,$chr(2)) }

alias -l restoredefault {
  var %i = $cnick(0)
  while (%i) { .cnick -r $iif($cnick(%i) != $null,$v1,*) | dec %i }

  color background 0
  color editbox 0
  color list 0
  color treebar 0
  color treebar text 1
  color editbox text 1
  color inactive 0
  color listbox text 1
  color action 6  
  color ctcp 4
  color highlight 5
  color info 12
  color info2 3
  color invite 3
  color join 3
  color kick 3
  color mode 3
  color nick 3
  color normal 1
  color notice 4
  color notify 7
  color other 7
  color own 1
  color part 3
  color quit 12
  color topic 3
  color wallops 5
  color whois 1
  color title text 6
  color gray 14


  bgclearall
}

alias -l restoreacronyms {
  if ($hget(acronyms)) { hfree acronyms }
  hmake acronyms 100
  if ($exists($qt($scriptdiracronyms.dat))) { .remove $qt($scriptdiracronyms.dat) }

  var %t = hadd -m acronyms

  %t afaik as far as i know
  %t arent aren't
  %t np no problem
  %t bbl be back later
  %t hb hurry back
  %t wont won't
  %t didnt didn't
  %t im i'm
  %t ftw for the win
  %t thats that's
  %t l8r later
  %t wyd what are you doing
  %t tc take care
  %t tho though
  %t imo in my opinion
  %t dont don't
  %t fu fuck you
  %t gn good night
  %t ppl people
  %t couldnt couldn't
  %t wd well done
  %t pls please
  %t fml fuck my life
  %t w8 wait
  %t cant can't
  %t its it's
  %t idk i don't know
  %t sup what's up
  %t gg good game
  %t ... …
  %t hru how are you
  %t dunno don't know
  %t ffs for fucks sake
  %t nmu not much you
  %t tyt take your time
  %t ttyl talk to you later
  %t bbs be back soon
  %t ru are you
  %t gonna going to
  %t u2 you too
  %t af as fuck
  %t nvm nevermind
  %t smh shake my head
  %t yw you're welcome
  %t n1 nice one
  %t jk just kidding
  %t ikr i know right
  %t cba can't be assed
  %t wtf what the fuck
  %t atm at the moment
  %t mirc mIRC
  %t afk away from keyboard
  %t nm not much
  %t gl good luck
  %t tyvm thank you very much
  %t hows how's
  %t doesnt doesn't
  %t <3 ❤
  %t ur you are
  %t prolly probably
  %t bbiab be back in a bit
  %t ltns long time no see
  %t brb be right back
  %t ofc of fucking course
  %t nini night night
  %t wouldnt wouldn't
  %t btw by the way
  %t yvw you're very welcome
  %t wb welcome back
  %t imho in my humble opinion
  %t whats what's
  %t wanna want to
  %t ic i see
  %t omg oh my god
  %t ty thank you

  hsave -o acronyms $qt($scriptdiracronyms.dat)
}
alias -l restorelastacronyms {
  if (!$exists($qt($scriptdiracronyms.dat))) { return }
  if ($hget(acronyms)) { hfree acronyms }
  hmake acronyms 100
  hload acronyms $qt($scriptdiracronyms.dat)
  hsave -o acronyms $qt($scriptdiracronyms.dat)
}

alias -l restorecolor {
  var %i = $cnick(0)
  while (%i) { .cnick -r $iif($cnick(%i) != $null,$v1,*) | dec %i }

  .cnick $!me 7 
  .cnick -l60 * 5 ~  
  .cnick * 4 ~
  .cnick -l60 * 42 &  
  .cnick * 8 &
  .cnick -l60 * 3 @ 
  .cnick * 9 @
  .cnick -l60 * 6 %
  .cnick * 13 %
  .cnick -l60 * 10 +
  .cnick * 11 +
  .cnick -l60 * 93
  .cnick * 95

  color background 1
  color editbox 1
  color list 1
  color treebar 1
  color treebar text 0
  color editbox text 0
  color inactive 1
  color listbox text 0
  color action 13  
  color ctcp 4
  color highlight 7
  color info 11
  color info2 3
  color invite 11
  color join 9
  color kick 9
  color mode 9
  color nick 9
  color normal 0
  color notice 4
  color notify 7
  color other 7
  color own 0
  color part 3
  color quit 3
  color topic 9
  color wallops 5
  color whois 7
  color title text 6
  color gray 14
  if (%theme_bg == On || %theme_black == On) { bgall }
}



#theme on

alias -l cleanup {
  var %a = 1, %b
  while ($findfile($scriptdirImages,*.bmp,%a)) {
    %b = $v1
    if ($nopath(%b) != default.bmp) { .remove $qt($v1) }
    inc %a
  }
  restoreoriginal
  unset %get_*
  unset %theme_*
  if ($exists($qt($scriptdiracronyms.dat))) { .remove $qt($scriptdiracronyms.dat) }

  var %i = $cnick(0)
  while (%i) { .cnick -r $iif($cnick(%i) != $null,$v1,*) | dec %i }

  var %a = 1, %b, %y, %s
  while ($scon(%a)) {
    .scid $v1
    var %x = 1, %y, %s
    while ($chan(%x)) {
      %y = $v1
      %s = 1
      while ($nick(%y,%s)) {
        .cline -r %y %s
        inc %s
      }
      inc %x
    }
    inc %a
  }
  .scid -r

  if ($scon(0) == 1 && !$network) { background -x "Status Window" }  
  $+(.timerwho#*,$network) off
}

alias -l bgclearall {
  var %a = 1
  while ($scon(%a)) {
    .scid $v1
    var %b = 1, %c
    while ($window(*,%b)) {
      %c = $v1
      if (!$istok(chanlist notify picture listbox custom,$window(%c).type,32)) {
        background -x $qt(%c)
      }
      inc %b
    }
    inc %a
  }
  .scid -r

  var %a = 1, %b
  while ($findfile($qt($scriptdirImages),*.bmp,%a)) {
    %b = $v1
    if ($nopath(%b) != default.bmp) { .remove $qt(%b) }
    inc %a
  }
}

on *:input:*:{
  if ($active == Status Window && /* !iswm $1-) { echo $color(info) -tsg * You can't chat in this window! | haltdef | return }
  elseif ($left($active,1) == $chr(35) && !$server) { echo $color(info) -tag * You aren't connected to any server! | haltdef | return }

  var -n %xx = $1-


  ; Rest

  if ($server) {
    if ($inpaste) {
      %ctrl = No
      msg $target $1-
      haltdef
    }
    elseif ($ctrlenter) {
      %ctrl = Yes
      msg $target $1-
      haltdef
    }
    elseif (/* !iswm $1-) {
      %ctrl = No
      msg $target %xx
      haltdef
    }
  }
}

alias -l acronyms {
  if (!$hget(acronyms)) { hmake acronyms 100 }
  var -n %a = 1
  var -n %b = $1-
  var -n %c, %new, %rest, %d
  while ($gettok(%b,%a,32) != $null) {
    %c = $ifmatch
    %new = $remove(%c,!,.,$chr(44),?)
    %rest = $remove(%c,%new)
    if ($hget(acronyms,%new)) { 
      %d = $ifmatch
      var %lo = $+(!.? $+ $chr(44))
      if ($left(%c,1) !isin %lo) {
        %b = $reptok(%b,%c,$+(%d,%rest),1,32)
        ;%b = $replace(%b,%c,$+(%d,%rest))
      }
    }
    inc %a
  }
  return $iif(%theme_acro == On,%b,$1-)
}

alias -l pa { return $mid($1,1,$2) $+ $chr(31) $+ $mid($1,$calc($2 + 1),1) $+ $chr(31) $+ $mid($1,$+(-,$2)) }

alias msg {
  if (!$server) { echo $color(info) -tag * [ERROR] You can't /msg offline! | unset %ctrl | return }
  elseif ($2 == $null) { echo $color(join) -tag * /msg: No Parameter Specified! | unset %ctrl } 
  elseif ($left($1,1) == @) { return } 
  else {
    var -n %txt = $2-


    if (%ctrl == Yes) { goto done }

    if ($left(%txt,1) !isin .!@) {
      %txt = $censor(%txt)
      %txt = $apos(%txt)
      %txt = $fixit(%txt)
      %txt = $acronyms(%txt)
      %txt = $fixsentences(%txt)
      %txt = $eye(%txt)
      %txt = $upperit(%txt)
      %txt = $dotit(%txt)
    }


    :done

    if (!%theme_percent) { %theme_percent = 65 }
    if ($caps(%txt) >= %theme_percent && $len(%txt) > 20 && %theme_caps == On) { %txt = $lower(%txt) }

    if (c isincs $chan($1).mode) { %txt = $strip(%txt) }

    var %mode = $left($remove($nick($1,$me).pnick,$me),1)


    var %color = $line($1,$fline($1,$me,1,1),1).color
    var %t = $strip($+($chr(40),$chr(3),%color,%mode,$me,$chr(3),$chr(41)))
    var %p = $len($timestamp)

    ; Styler (new as of v4.0)
    if (%theme_stylestatus == On && $left(%txt,1) !isin .!@) {
      var %a = 1, %b, %snick, %nick, %modex, %fullnick, %c = $iif(%theme_style == $null,12,%theme_style), %rest
      while ($gettok(%txt,%a,32) != $null) {
        %b = $strip($v1)
        %nick = $remove(%b,~,&,@,%,+,!,?,$chr(44),.,:,'s)

        if ($chr(35) isin $1) { %nick = $line($1,$fline($1,%nick,1,1).ln,1) }
        if ($query($1)) { %nick = $v1 }


        %rest = $remove(%b,%nick)
        %nick = $remove(%nick,%rest)
        if (%nick ison $1) {
          ; || $query(%nick)

          if (%theme_prefix == On) { %modex = $left($remove($nick($1,%nick).pnick,%nick),1) }
          else { %modex = "" }

          %fullnick = $+(%modex,%nick,%rest)

          if (%ctrl == No && %rest !isalnum) { %txt = $replace(%txt,$+(%nick,%rest),$styler(%c,$+(%modex,%nick)) $+ %rest) }
          else { %txt = $2- }

        }
        inc %a
      }
    }

    if (%theme_left == $null && %theme_right == $null) { var %q = * [MESG] $iif(%theme_spaces == yes,$str($chr(160),$calc(21 - $len(%t)))) $+(%theme_left,$chr(3),%color,%mode,$me,$chr(3),%theme_right) %txt }
    else { var %q = * [MESG] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $+(%theme_left,$chr(3),%color,%mode,$me,$chr(3),%theme_right) %txt }

    if ($window($1).stamp == $false) { var %s = 30 }
    else { var %s = $len($timestamp) + 31 }
    if ($show) {
      if ($1 ischan || $query($1)) { echo $color(own) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $1 %q }
      elseif (!$query($1)) { echo $color(own) -tag -> $+(*,$chr(3),$color(treebar text),$1,$chr(3),*) $2- }
    }

    unset %ctrl

    if ($1 == $me) { echo $color(info) -tag * [ERROR] You cannot message yourself! }
    ;elseif ($left($1,1) != $chr(35) && $istok(%theme_services,$1,32)) { !.msg $1 $remove(%txt,.,?,,!,$chr(44),:) }
    else { !.msg $1 %txt }

    haltdef
  }
}

alias amsg {
  if ($chan(1) && $1) {
    var %a = 1, %b
    while ($chan(%a)) {
      %b = $v1
      msg %b $1-
      inc %a
    }
    haltdef
  }
}
alias ame {
  if ($chan(1) && $1) {
    var %a = 1, %b
    while ($chan(%a)) {
      %b = $v1
      describe %b $1-
      inc %a
    }
    haltdef
  }
}


alias uwho {
  echo $color(join) -tag * Looking up $1 user info...
  .!uwho $1-
  haltdef
}

alias -l hl {
  var %a = 1, %b, %c = $1-
  while ($gettok(%c,%a,32)) {
    %b = $v1
    if ($len(%b) == 3) { %c = $replace(%c,%b, $+($mid(%b,1,1) $+ $chr(31) $+ $mid(%b,2,1) $+ $chr(31) $+ $mid(%b,3,1))) }
    elseif ($len(%b) == 5) { %c = $replace(%c,%b, $+($mid(%b,1,2) $+ $chr(31) $+ $mid(%b,3,1) $+ $chr(31) $+ $mid(%b,4,2))) }
    elseif ($len(%b) == 7) { %c = $replace(%c,%b, $+($mid(%b,1,3) $+ $chr(31) $+ $mid(%b,4,1) $+ $chr(31) $+ $mid(%b,5,3))) }
    elseif ($len(%b) == 9) { %c = $replace(%c,%b, $+($mid(%b,1,4) $+ $chr(31) $+ $mid(%b,5,1) $+ $chr(31) $+ $mid(%b,6,4))) }
    elseif ($len(%b) == 11) { %c = $replace(%c,%b, $+($mid(%b,1,5) $+ $chr(31) $+ $mid(%b,6,1) $+ $chr(31) $+ $mid(%b,7,5))) }
    inc %a
  }
  return %c
}

on ^*:text:*:#:{

  ;var -n %text = $replace($parms,$chr(32),$chr(160))
  var -n %text = $parms


  var %mode = $left($remove($nick(#,$nick).pnick,$nick),1)
  var %color = $line(#,$fline(#,$nick,1,1),1).color
  var %t = $strip($+($chr(40),$chr(3),%color,%mode,$nick,$chr(3),$chr(41)))

  if (%theme_left == $null && %theme_right == $null) { var %q = * [MESG] $iif(%theme_spaces == yes,$str($chr(160),$calc(21 - $len(%t)))) $+(%theme_left,$chr(3),%color,%mode,$nick,$chr(3),%theme_right) %text }
  else { var %q = * [MESG] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $+(%theme_left,$chr(3),%color,%mode,$nick,$chr(3),%theme_right) %text }

  if ($window(#).stamp == $false) { var %s = 30 }
  else { var %s = $len($timestamp) + 31 }

  window -g2 $target

  var %a = $highlight($me).color
  if (%a && $istok($strip(%text),$me,32)) { 
    echo %a $iif(%theme_spaces == yes,$+(-tli,%s),-tl) $target %q
  }
  else { 
    echo $color(normal) $iif(%theme_spaces == yes,$+(-tli,%s),-tl) $target %q
  }
  haltdef
}

on ^*:text:*:?:{
  var -n %text = $1-

  var %t = $strip($+($chr(40),$chr(3),%color,%mode,$nick,$chr(3),$chr(41)))
  if (%theme_left == $null && %theme_right == $null) { var %q = * [MESG] $iif(%theme_spaces == yes,$str($chr(160),$calc(21 - $len(%t)))) $+(%theme_left,$chr(3),%color,%mode,$nick,$chr(3),%theme_right) %text }
  else { var %q = * [MESG] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $+(%theme_left,$chr(3),%color,%mode,$nick,$chr(3),%theme_right) %text }

  var %s = $len($timestamp) + 31

  var %a = $highlight($me).color
  if (%a && $istok($remove($strip($1-),~,&,@,%,+,$chr(44),.,!,?),$me,32)) { window -g2 $nick | flash | echo %a $iif(%theme_spaces == yes,$+(-ti,%s),-t) $nick %q }
  else { window -g2 $nick | flash | echo $color(normal) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $nick %q }

  haltdef
}



;raw 352:*:{ hadd -m $+($network,.,$2) $6 | halt }

;alias -l updatewho { .timer $+ $1 -o 1 1 whoaway $1 }


alias -l addchans {
  var %a = 1, %b
  while ($nick($2,%a)) {
    %b = $v1
    hadd -m $+($1,.,$2) %b $ctime
    inc %a
  }
}

on ^*:join:#:{

  if ($nick == $me) { 
    bg #
    var %t = [JOIN]
    var %q = * [!] $iif(%theme_spaces == yes,$str($chr(160),$calc(25 - $len(%t)))) Now talking in # $+ ...
    var %s = $len($timestamp) + 31
    echo $color(join) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $target %q

    if (!$hget($+($network,.,#))) { hmake $+($network,.,#) 100 }

    hadd -m $+($network,.,#) $me $ctime

    whoaway #
    .timer $+ who $+ # $+ $network -o 0 1800 whoaway $unsafe(#)
    .timer 1 1 addchans $network $unsafe(#)

    haltdef
  }
  else {
    var %host = $gettok($address($nick,5),2,33)
    hadd -m $+($network,.,#) $nick $ctime

    if (%theme_show == yes || !%theme_show) { var %show = %host }
    else { var %show }

    var %t = $strip($nick)
    var %q = * [JOIN] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $nick $iif(%show,$+($chr(40),%host,$chr(41))) has joined # $iif($hget(tld,$gettok(%host,-1,46)) ,$+($chr(40),TLD: $v1,$chr(41)))
    var %s = $len($timestamp) + 31
    echo $color(join) $iif(%theme_spaces == yes,$+(-ti,%s),-t) # %q
    $+(.timer,$network,#) -o 1 1 who $nick

    ;IPInfo
    var %t = $gettok($fulladdress,2,64)
    if ($remove(%t,.) isnum) || (: isin %t && *:IP !iswm %t) { 
      if (%theme_getip == On) { 
        $+(.timeripinfo,$network,$chan) -o 1 1 getip %t $nick $unsafe(#)
      }
    }

    haltdef
  }
}

alias -l format {
  return $remove($replace($duration($calc($ctime - $1)),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32))
}

on ^*:part:#:{
  if ($nick == $me) {
    var %t = $strip($me)
    var %l = $len(%t)
    var %q = * [PART] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - %l))) You have left # $+ ...
    if ($hget($+($network,.,#))) { hfree $+($network,.,#) }
    .timer $+ who $+ # $+ $network off
  }
  else {
    if ($hget($+($network,.,#),$nick)) {
      var %t = $v1
      var %dur = $remove($replace($duration($calc($ctime - %t)),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32))
      hdel $+($network,.,#) $nick
    }
    var %t = $strip($nick)
    var %l = $len(%t)

    if (%theme_show == yes || !%theme_show) { var %host = $+($chr(40),$gettok($address($nick,5),2,33),$chr(41)) }
    else { var %host = "" }

    var %q = * [PART] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - %l))) $nick %host has left # $iif($1,$+($chr(40),$strip($1-),$chr(41))) $iif(%dur,$+($chr(40),On channel: %dur,$chr(41)))
  }
  var %s = $len($timestamp) + 31
  echo $color(part) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $target %q

  haltdef
}

ctcp *:version:?:{ .ctcpreply $nick VERSION My Theme $sversion (https://mircscripts.info/lv86s) - by $sauthor $syear }

on ^*:action:*:#:{ 
  var %a = $target, %mode
  %mode = $left($remove($nick(#,$nick).pnick,$nick),1)
  var %t = $strip($+(%mode,$nick))
  var %q = * [ACTN] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $+(%mode,$nick) $1-
  var %s = $len($timestamp) + 31
  ;32

  var %x = $highlight($me).color
  if (%x && $istok($remove($strip($1-),~,&,@,%,+,$chr(44),.,!,?),$me,32)) { window -g2 $target | echo %x $iif(%theme_spaces == yes,$+(-ti,%s),-t) $target %q }
  else { window -g2 $target | echo $color(action) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $target %q }

  haltdef
}


ctcp ^*:sound:#:{
  var %a = $target, %mode
  %mode = $left($remove($nick(#,$nick).pnick,$nick),1)
  var %t = $strip($+(%mode,$nick))
  var %q = * [ACTN] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $+(%mode,$nick) $1-
  var %s = $len($timestamp) + 31
  ;32

  var %x = $highlight($me).color
  if (%x && $istok($remove($strip($1-),~,&,@,%,+,$chr(44),.,!,?),$me,32)) { window -g2 $target | echo %x $iif(%theme_spaces == yes,$+(-ti,%s),-t) $target %q }
  else { window -g2 $target | echo $color(action) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $target %q }

  haltdef
}

on ^*:action:*:?:{ 
  var %a = $target, %mode
  var %t = $strip($nick)
  var %q = * [ACTN] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $nick $1-
  var %s = $len($timestamp) + 31

  var %x = $highlight($me).color
  if (%x && $istok($remove($strip($1-),~,&,@,%,+,$chr(44),.,!,?),$me,32)) { window -g2 $nick | flash | echo %x $iif(%theme_spaces == yes,$+(-ti,%s),-t) $nick %q }
  else { window -g2 $nick | flash | echo $color(action) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $nick %q }

  haltdef
}

alias action { describe $1 $2- | halt }
alias me { describe $active $1- | halt }
alias say { msg $active $1- | halt }

alias describe {
  if ($2) {
    var %mode = $left($remove($nick($1,$me).pnick,$me),1)
    var %t = $strip($+(%mode,$me))
    var %q = * [ACTI] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $+(%mode,$me) $2-
    var %s = $len($timestamp) + 31
    ;if ($query($1)) { !query $1 }

    if (#* !iswm $1 && !$query($1)) { !query $1 }    

    echo $color(action) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $1 %q
    !.describe $1 $2-

    haltdef
  }
}

on ^*:quit:{
  var %a = 1, %b, %x, %dur
  while ($comchan($nick,%a)) {
    %b = $v1
    unset %dur
    if ($hget($+($network,.,%b),$nick)) {
      %x = $v1
      var %dur = $remove($replace($duration($calc($ctime - %x)),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32))
    }

    if (%theme_show == yes || !%theme_show) { var %host = $+($chr(40),$gettok($address($nick,5),2,33),$chr(41)) }
    else { var %host = "" }

    var %mode = $left($remove($nick(%b,$nick).pnick,$nick),1)
    var %g = $nick
    var %rsn = $remove($1-,$+(Quit:,$chr(32)),Quit:)
    if ($left(%rsn,2) == $+(:,$chr(32))) { %rsn = $gettok(%rsn,2-,32) }
    if (%rsn == $chr(32)) { %rsn = "" }
    var %q = * [QUIT] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len($+(%mode,%g))))) $+(%mode,%g) %host has quit IRC $iif(%rsn != : && %rsn,$+($chr(40),$strip(%rsn),$chr(41))) 

    var %s = $len($timestamp) + 31
    echo $color(quit) $iif(%theme_spaces == yes,$+(-ti,%s),-t) %b %q $iif(%dur,$+($chr(40),On channel: %dur,$chr(41)))

    if ($hget($+($network,.,%b))) { hdel $+($network,.,%b) $nick }

    inc %a
  }
  haltdef
}
on ^*:nick:{
  var %a = 1, %b, %x
  while ($comchan($newnick,%a)) {

    %b = $v1
    if ($hget($+($network,.,%b),$nick)) {
      var %g = $hget($+($network,.,%b),$nick)
      hdel $+($network,.,%b) $nick
      hadd $+($network,.,%b) $newnick %g
    }

    if (%theme_show == yes || !%theme_show) { var %host = $+($chr(40),$gettok($address($newnick,5),2,33),$chr(41)) }
    else { var %host = "" }

    var %t = $strip($nick)
    var %q = * [NICK] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $nick %host is now known as $newnick
    var %s = $len($timestamp) + 31
    echo $color(nick) $iif(%theme_spaces == yes,$+(-ti,%s),-t) %b %q

    inc %a
  }
  haltdef
}
on ^*:topic:#:{
  var %t = $nick
  var %q = * [TOPIC] $iif(%theme_spaces == yes,$str($chr(160),$calc(18 - $len(%t)))) $nick sets topic: $+($qt($1-)) 
  var %s = $len($timestamp) + 31
  echo $color(topic) $iif(%theme_spaces == yes,$+(-ti,%s),-t) # %q

  haltdef
}

on ^*:kick:#:{
  if ($knick == $me) { 
    hfree $+($network,.,#)
    .timer $+ who $+ # $+ $network off
  }
  else {
    if ($hget($+($network,.,#),$knick)) {
      var %t = $v1
      var %dur = $remove($replace($duration($calc($ctime - %t)),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32))
      hdel $+($network,.,#) $knick
    }

    var %t = $strip($nick)
    var %q = * [KICK] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $nick has kicked $knick out of # $iif($1,$+($chr(40),$1-,$chr(41)))
    var %s = $len($timestamp) + 31

    echo $color(kick) $iif(%theme_spaces == yes,$+(-ti,%s),-t) # %q $iif(%dur,$+($chr(40),On channel: %dur,$chr(41)))

    haltdef
  }
}
on ^*:rawmode:#:{
  var %t = $strip($nick)
  var %q = * [MODE] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) $nick sets mode: $+($1-) 
  var %s = $len($timestamp) + 31
  echo $color(mode) $iif(%theme_spaces == yes,$+(-ti,%s),-t) # %q

  haltdef
}


;RAWS

raw 421:*:{ echo $color(info) -tag * Unknown command: " $+ $lower($2) $+ " | halt }
raw 520:*:{ halt }

/*
; MODE RAWS

raw 324:*:{
  var %r = $eval($+(%,raw,$network,$2,324),2)
  if (%r) {
    var %t = [!)
    var %q = * [!] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) Modes: $3-
    var %s = $len($timestamp) + 31
    echo $color(join) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $2 %q
    unset $+(%,raw,$network,$2,324)
  }
  halt
}

; CREATED BY RAWS

raw 329:*:{ 
  var %r = $eval($+(%,raw,$network,$2,329),2)
  if (%r) {
    var %t = [!)
    var %q = * [!] $iif(%theme_spaces == yes,$str($chr(160),$calc(17 - $len(%t)))) Created: $asctime($3) 
    var %s = $len($timestamp) + 31
    echo $color(join) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $2 %q
    unset $+(%,raw,$network,$2,329)
  }
  halt
}
*/

;TOPIC RAWS

raw 332:*:{
  var %t = [!)
  var %q = * [!] $iif(%theme_spaces == yes,$str($chr(160),$calc(19 - $len(%t)))) Topic: $qt($3-)
  var %s = $len($timestamp) + 31
  echo $color(join) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $2 %q
  halt
}
raw 333:*:{
  var %t = [!)
  var %q = * [!] $iif(%theme_spaces == yes,$str($chr(160),$calc(18 - $len(%t)))) Set by: $3 on $asctime($4)
  var %s = $len($timestamp) + 31
  echo $color(join) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $2 %q
  halt
}


alias query {
  if ($server) {
    if ($1 == $me) { echo $color(info) -tag * [ERROR] You cannot query yourself! }
    elseif (-* iswm $1 && $2) { !query $1- | bg $2 }
    elseif ($1) { !query $1 | bg $1 }
    whois $1 $1
    haltdef
  }
  else { echo $color(info) -tag * [ERROR] You are not connected to this IRC server! }
}


alias whois { if ($server && $1) { if ($active ischan) { set -u3 %_chan $active } | !whois $1 $1 } }


alias -l bg {
  if (!$1) { return }
  if (%theme_mycolor == $null) { %theme_mycolor = 00 }

  var %chan = $mkfn($1), %flags = $2

  var %n = $iif($len($1) >= 22,$+($mid($1,1,22),...),$1)
  window -pdh @logo

  if ($exists(%theme_image) && %theme_black == On) {
    var %w = $window($1).w
    var %h = $window($1).h
    drawpic -ms @logo 9 0 %theme_image
  }

  if (%theme_bg == On) {
    drawtext -o @logo 01 $qt(%theme_font) 75 20 7 %n
    drawtext -o @logo %theme_mycolor $qt(%theme_font) 75 20 5 %n
  }
  if (* !isin $1) {
    drawsave -b32q100 @logo $qt($+($scriptdirImages\,%chan,.bmp))
  }

  window -c @logo

  if (%flags) { 
    if ($server) { background %flags $+ f $qt($+($scriptdirImages\,%chan,.bmp)) }
    else { background %flags $+ f $qt($+($scriptdirImages\default.bmp)) }
  }
  else { 
    if ($server && * !isin $1) { background -f $1 $qt($+($scriptdirImages\,%chan,.bmp)) }
    elseif ($server) { background -f $1 $qt($+($scriptdirImages\default.bmp)) }
  }
}
alias -l bgall {
  var %a = 1, %b
  while ($scon(%a)) {
    .scid $v1
    if (%theme_black == Off) { background -xs }
    else { bg $network -s }
    var %x = 1 | while ($chan(%x)) { var %r = $v1 | if (%theme_black == Off) { background -x %r } | else { bg %r } | inc %x }
    var %x = 1 | while ($query(%x)) { var %r = $v1 | if (%theme_black == Off) { background -x %r } | else { bg %r } | inc %x }
    inc %a
  }
  .scid -r
}
on *:disconnect:{
  var %x = 1, %y
  while ($chan(%x)) {
    %y = $v1
    if ($hget($+($network,.,%y))) {
      hfree $+($network,.,%y)
    }
    .timer $+ who $+ %y $+ $network off
    inc %x
  }

  var %a = 1, %b
  while ($chan(%a)) {
    %b = $v1
    if (%theme_bg == On || %theme_black == On) { background -f %b $qt($scriptdirImages\default.bmp) }
    else { background -x %b }
    inc %a
  }


  var %a = 1, %b
  while ($query(%a)) {
    %b = $v1
    if (%theme_bg == On || %theme_black == On) { background -f %b $qt($scriptdirImages\default.bmp) }
    else { background -x %b }
    inc %a
  }

  if (%theme_keep == Off) { .partall }
  if ($exists($qt($scriptdirImages\default.bmp))) { background -sx | background -sf $qt($scriptdirImages\default.bmp) }
}

on *:connect:{ 
  bg $network -s
  bgall
}

on *:open:?:*:{ 
  bg $nick
}

on *:exit:{
  var %a = 1, %b
  while ($findfile($scriptdirImages/,*.bmp,%a)) {
    %b = $v1  
    if ($nopath(%b) != default.bmp) { .remove $qt(%b) }
    inc %a
  }
  hsave -o acronyms $qt($scriptdiracronyms.dat)
  hsave -o settings $qt($scriptdirsettings.dat)

  remini $mircini windows
  remini $mircini chanhist
  remini $mircini backgrounds
  flushini $mircini 
  if ($hget(tld)) { hsave -o tld $qt($scriptdirtld.dat) }
}

; Notice Stuff...

on ^*:snotice:*:{
  echo $color(notice) -tgs * [SNOTICE] $+(-,$nick,-) $1-
  beep
  haltdef
}

on ^*:notice:*:#:{
  echo $color(notice) -tgl # * [NOTICE] $+(-,$nick,/,#,-) $1-
  beep
  haltdef
}

on ^*:notice:*:?:{

  if ([*] iswm $1 && $remove($1,[,]) ischan) {
    echo $color(notice) -t $remove($1,[,]) * [NOTICE] $+(-,$nick,-) $1-
  }
  else {
    echo $color(notice) $iif($activecid == $cid && %theme_notices == active,-atg,-stg) * [NOTICE] $+(-,$nick,-) $1-
  }
  beep
  haltdef
}

alias -l safe return $!decode( $encode($1-, m) ,m)

alias -l styles {
  if (!$window(@styles)) { window -ldpfCw0ok0 +tn @styles -1 -1 400 313 }
  var %a = 1
  while (%a <= 13) {
    aline -l @styles %a $+ ) - $styler(%a,$+($iif(%theme_prefix == On,@),$me))
    inc %a
  }
}
menu @styles {
  dclick { %theme_style = $remove($gettok($sline(@styles,1),1,32),$chr(41)) | noop $input(You have updated your NC Style to: $qt(%theme_style) $+ ...,4) }
  -
  Update { window -c @styles | styles }
  -
  Close { window -c @styles }
  -
}

alias -l styler {
  var %rcolor = 03 04 06 07 08 09 10 11 13 14 15
  var %a = 1, %b
  while (%a <= 96) {
    %b = $v1
    %rcolor = $addtok(%rcolor,%a,32)
    inc %a
  }
  %rcolor = $remove(%rcolor,88,89,90,91,92,93,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39)

  if ($1 == rand) { tokenize 32 $rand(1,13) $2- }

  if ($1 == 1) {
    if ($len($2) == 1 || $len($2) == 2) { return $+(,$2,) }
    return $+(,$left($2,1),,$mid($2,2,-1),,$right($2,1),)
  }
  elseif ($1 == 2) {
    var %c = $gettok(%rcolor,$r(1,$numtok(%rcolor,32)),32)
    if ($len($2) == 1 || $len($2) == 2) { return $+(,%c,,$2,) }
    return $+(,%c,,$left($2,1),,$mid($2,2,-1),,%c,,$right($2,1),)
  }
  elseif ($1 == 3) {
    var %c = $gettok(%rcolor,$r(1,$numtok(%rcolor,32)),32)
    if ($len($2) == 1 || $len($2) == 2) { return $2 }
    return $+($left($2,1),,%c,$mid($2,2,-1),,$right($2,1))
  }
  elseif ($1 == 4) {
    if ($len($2) isnum 1-4) { return $+(05,$2,) }
    else { return $+(05,$left($2,1),04,$mid($2,2,1),07,$mid($2,3,$calc($len($2) - 4)),04,$mid($2,$calc($len($2) - 1),1),05,$right($2,1),) }
  }
  elseif ($1 == 5) {
    if ($len($2) isnum 1-4) { return $+(02,$2,) }
    else { return $+(02,$left($2,1),12,$mid($2,2,1),11,$mid($2,3,$calc($len($2) - 4)),12,$mid($2,$calc($len($2) - 1),1),02,$right($2,1),) }
  }
  elseif ($1 == 6) {
    var %r = $gettok(%rcolor,$r(1,$numtok(%rcolor,32)),32)
    return $+(14,$chr(40),,%r,$2,14,$chr(41),)
  }
  elseif ($1 == 7) {
    var %r = $gettok(%rcolor,$r(1,$numtok(%rcolor,32)),32)
    return $+(14,$chr(91),,%r,$2,14,$chr(93),)
  }
  elseif ($1 == 8) {
    var %r = $r(1,$len($2)), %c = $gettok(%rcolor,$r(1,$numtok(%rcolor,32)),32)
    if (%r == 1) { return $+($chr(2),$chr(31),$chr(3),%c,$left($2,1),$chr(3),$chr(31),$chr(2),$mid($2,2,$len($2)))) }
    if (%r == $len($2)) { return $+($mid($2,1,-1),$chr(2),$chr(31),$chr(3),%c,$right($2,1),$chr(3),$chr(31),$chr(2))) }
    else { return $+($mid($2,1,$calc(%r - 1)),$chr(2),$chr(31),$chr(3),%c,$mid($2,%r,1),$chr(3),$chr(31),$chr(2),$mid($2,$calc(%r + 1),$len($2))) }
  }
  elseif ($1 == 9) {
    var %r = $r(1,$len($2))
    if (%r == 1) { return $+($chr(2),$chr(31),$left($2,1),$chr(31),$chr(2),$mid($2,2,$len($2)))) }
    if (%r == $len($2)) { return $+($mid($2,1,-1),$chr(2),$chr(31),$right($2,1),$chr(31),$chr(2))) }
    else { return $+($mid($2,1,$calc(%r - 1)),$chr(2),$chr(31),$mid($2,%r,1),$chr(31),$chr(2),$mid($2,$calc(%r + 1),$len($2))) }
  }
  elseif ($1 == 10) {
    var %c = $gettok(%rcolor,$r(1,$numtok(%rcolor,32)),32)
    if ($len($2) isnum 1-4) { return $+($chr(3),%c,$2,$chr(3)) }
    else { return $+($left($2,2),$chr(2),$chr(3),%c,$mid($2,3,-2),$chr(3),$chr(2),$right($2,2)) }
  }
  elseif ($1 == 11) {
    var %c = $gettok(%rcolor,$r(1,$numtok(%rcolor,32)),32)
    if ($len($2) isnum 1-4) { return $+($chr(3),%c,$2,$chr(3)) }
    else { return $+($chr(3),%c,$left($2,2),$chr(3),$chr(31),$chr(2),$mid($2,3,-2),$chr(2),$chr(31),$chr(3),%c,$right($2,2),$chr(3)) }
  }
  elseif ($1 == 12) {
    return $2
  }
  elseif ($1 == 13) {
    var %r = $r(1,$len($2))
    if (%r == 1) { return $+($chr(31),$left($2,1),$chr(31),,$mid($2,2,$len($2)))) }
    if (%r == $len($2)) { return $+($mid($2,1,-1),$chr(31),$right($2,1),$chr(31))) }
    else { return $+($mid($2,1,$calc(%r - 1)),$chr(31),$mid($2,%r,1),$chr(31),$mid($2,$calc(%r + 1),$len($2))) }
  }
}

alias -l apos {
  var -n %a = 1
  var -n %b = $1-
  var %c, %new, %rest
  while ($gettok(%b,%a,32) != $null) {
    %c = $v1
    %new = $remove(%c,!,.,$chr(44),?)
    %rest = $remove(%c,%new)
    var %y, %x = 1
    while ($wildtok(%b,%new,%x,32)) {
      if ($istok(hadnt havent couldnt im youre arent didnt wouldnt lets thats aint doesnt hes shes whats its isnt wont cant shouldnt dont werent ive whos wasnt hows shouldnt,%new,32)) { 
        %b = $puttok(%b,$+($replace(%new,hadnt,hadn't,hows,how's,wasnt,wasn't,whos,who's,havent,haven't,couldnt,couldn't,im,i'm,youre,you're,arent,aren't,didnt,didn't,wouldnt,wouldn't,lets,let's,thats,that's,aint,ain't,doesnt,doesn't,hes,he's,shes,she's,whats,what's,its,it's,isnt,isn't,wont,won't,cant,can't,shouldnt,shouldn't,dont,don't,werent,weren't,ive,i've,shouldnt,shouldn't),%rest),$findtok(%b,%new,%x,32),32)
      }
      inc %x
    }
    inc %a
  }
  return $iif(%theme_fix == On,%b,$1-)
}

alias -l eye {
  var -n %total = $1-, %x = 1, %b
  while ($findtok(%total,I,%x,32)) {
    %b = $gettok(%total,$v1,32)
    %total = $reptok(%total,%b,I,%x,32)
    inc %x
  }
  var %a = 1, %b
  while ($gettok(%total,%a,32) != $null) {
    %b = $v1
    if (I isincs %b && $len(%b) > 1 && $remove(%b,I) isupper && %theme_caps == On) { %total = $replace(%total,%b,$lower(%b)) }
    inc %a
  }
  return $iif(%theme_fix == On,%total,$1-)
}

alias -l upperit {
  var %a = 1, %b, %c = $1-, %after
  while ($gettok(%c,%a,32)) {
    %b = $v1
    if (u* iswm %b && $remove(%b,!,$chr(44),@,.,$chr(44),?) == u) {
      %after = $remove(%b,u)
      %c = $reptok(%c,%b,$+(you,%after),1,32)
    }
    elseif (r* iswm %b && $remove(%b,!,$chr(44),@,.,$chr(44),?) == r) {
      %after = $remove(%b,r)
      %c = $reptok(%c,%b,$+(are,%after),1,32)
    }
    inc %a
  }
  return %c
}

alias -l dotit {
  return $replace($1-,...,$chr(8230))
}


alias -l fixit {
  var -n %total $1- 
  var %w = 1
  while ($mid(rcuk,%w,1)) {
    var %n = $v1, %n2 = %n
    /*
    if (%n == r) { %n2 = are }
    if (%n == u) { %n2 = you }
    if (%n == c) { %n2 = see }
    if (%n == k) { %n2 = ok }
    */

    var %a = 1, %b, %new, %rest, %g
    while ($gettok(%total,%a,32) != $null) {
      %b = $v1
      %new = $remove(%b,!,.,$chr(44),:,?,0,1,2,3,4,5,6,7,8,9)
      %rest = $remove(%b,%new)

      if ($len(%new) == 1 && $+(%n,*) iswm %b && %b != %n) { %total = $replace(%total,%b,$+(%n2,%rest)) }
      elseif (%b == %n) { %total = $reptok(%total,%n,%n2,1,32) }
      inc %a
    }
    inc %w
  }
  return $iif(%theme_fix == On,%total,$1-)
}

alias -l fixsentences {
  var -n %xx $1-
  if ($left(%xx,1) isin .?!@) { return %xx }
  else {
    var %a = 1, %b, %total = %xx, %prev, %current, %doupper
    while ($gettok(%total,%a,32) !== $null) {
      %b = $v1
      %prev = $gettok(%total,$calc(%a -1),32)

      if ($right(%prev,1) isin .?! && http*//* !iswm %b && www.* !iswm %b) { %total = $reptok(%total,%b,$+($upper($left(%b,1)),$mid(%b,2)),0,32) }

      inc %a
    }
    var %t = $gettok(%total,-1,32)
    if ($chr(125) !isin %total && $left(%t,1) !isin :~&@%+ && $len(%total) >= 10 && *http*//* !iswm %total && $numtok(%total,32) > 1 && $right(%total,1) !isin .!? && $right(%total,1) isalnum && $right(%total,1) isnum && $remove($strip(%t),~,&,@,%,+,.,!) !ison # && www.* !iswm %t && $right(%total,1) !isnum) { %total = $+(%total,.) }

    var %t = $gettok(%total,1,32)
    if ($left(%t,1) !isupper && $len(%total) >= 10 && http*//* !iswm %t && $chr(123) !isin %total && $numtok(%total,32) > 1) { %total = $+( $upper($left(%t,1)) , $mid(%total,2)) }

    return $iif(%theme_fix == On,%total,$1-)
  }
}

alias -l censor {
  var -n %t = $1-
  var %a = 1, %b, %swears = %theme_swears
  while ($gettok(%swears,%a,32) != $null) {
    %b = $v1
    if (%b isin %t) { %t = $replace(%t,%b,$str(*,$len(%b))) }
    inc %a
  }
  return $iif(%theme_censor == On,%t,$1-)
}



alias -l nohtml {
  return $regsubex($1, /<[^>]+(?:>|$)|^[^<>]+>/g,)
}

alias -l check {
  %theme_duration = $ctime
  sockclose checkx
  sockopen -e4 checkx mircscripts.info 443
}
on *:sockopen:checkx:{
  if ($sockerr) { return }
  sockwrite -n $sockname GET https://mircscripts.info/lv86s HTTP/1.1
  sockwrite -n $sockname Host: mircscripts.info  
  sockwrite -n $sockname $str($crlf,2)
}
on *:sockread:checkx:{
  if ($sockerr) { return }
  var %a
  sockread -f %a
  tokenize 32 %a
  if (*My Theme v* iswm $1-) { 
    var %new = $6
    if ($sversion > %new) {
      echo $color(notice) -tag * [UPDATE] Your Theme version is more recent than the newest!
    }
    elseif ($sversion != %new) { 
      echo $color(notice) -tag * [NEW] An update is available! Version: %new (You have: $sversion $+ )
      echo $color(action) -tag * Auto downloading file...
      d.image
    }
    else { echo $color(notice) -tag * [UPDATE] Your Theme is up to date! }
    sockclose $sockname
  }
}

alias d.image { sockopen -e4 image mircscripts.info 443 | write -c $qt($scriptdirtheme.zip) }
on *:sockopen:image:{
  sockwrite -nt $sockname GET https://mircscripts.info/addons/theme.zip HTTP/1.1
  sockwrite -nt $sockname Host: mircscripts.info
  sockwrite -nt $sockname $str($crlf,2)
}
on *:sockread:image:{
  if (!$sock($sockname).mark) {
    var %read | sockread %read
    if (%read == $null) { echo $color(action) -tag * Downloading... | sockmark $sockname 1 }
  }
  else { sockread &image | bwrite $qt($scriptdirtheme.zip) -1 -1 &image }
}
on *:sockclose:image:{
  echo $color(action) -tag * File Size: $bytes($file($qt($scriptdirtheme.zip)).size).suf
  echo $color(action) -tag * Download complete. $+($chr(40),$duration($calc($ctime - %theme_duration)) elapsed,$chr(41))
  run $qt($scriptdirtheme.zip)
  unset %theme_duration
  %theme_last = $ctime
}

alias -l caps { return $calc($regex($remove($1-,$chr(32)),/[A-Z]/g) / $len($remove($1-,$chr(32))) * 100) }

on ^*:usermode:{
  echo $color(mode) -tsg * [MODE] $me sets mode: $1-
  haltdef
}

;=======================================

alias getip {
  ;remove to enable
  return
  var %a = xip $+ $rand(1000,9999)
  sockclose %a
  sockopen -46 %a ipinfo.io 80
  sockmark %a $1
  set -u5 $+(%,%a,nick) $2
  set -u5 $+(%,%a,line) ""
  set -u5 $+(%,%a,chan) $3
}
on *:sockopen:xip*:{
  if ($sockerr) { unset $eval($+(%,$sockname,line),1) $eval($+(%,$sockname,chan),1) $eval($+(%,$sockname,nick),1) | return }
  sockwrite -n $sockname GET $+(http://ipinfo.io/,$sock($sockname).mark,/geo) HTTP/1.1
  sockwrite -n $sockname Host: ipinfo.io
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
  sockwrite -n $sockname Accept-Language: en-US
  sockwrite -n $sockname Content-Type: application/json; charset=utf-8
  sockwrite -n $sockname $str($crlf,2)
}
on *:sockread:xip*:{
  if ($sockerr) { unset $eval($+(%,$sockname,line),1) $eval($+(%,$sockname,chan),1) $eval($+(%,$sockname,nick),1) | return }
  var %x, %2
  sockread -f %x
  tokenize 32 %x
  if ("*": * iswm $1-) { 
    var %2 = $remove($2-,",$chr(44))

    if ($1 == "error":) { sockclose $sockname | return }
    if ($1 == "ip":) { set $eval($+(%,$sockname,line),1) $eval($+(%,$sockname,line),2) $eval($+(%,$sockname,nick),2) IP: %2 }
    if ($1 == "city":) { set $eval($+(%,$sockname,line),1) $eval($+(%,$sockname,line),2) $c City: %2 }
    if ($1 == "region":) { set $eval($+(%,$sockname,line),1) $eval($+(%,$sockname,line),2) $c Region: %2 }
    if ($1 == "country":) { set $eval($+(%,$sockname,line),1) $eval($+(%,$sockname,line),2) $c Country: $iif($hget(tld,%2),$v1,%2) }
    if ($1 == "loc":) { set $eval($+(%,$sockname,line),1) $eval($+(%,$sockname,line),2) $c Location: $replace(%2,-,$+($chr(44),-)) }
    if ($1 == "timezone":) { set $eval($+(%,$sockname,line),1) $eval($+(%,$sockname,line),2) $c Timezone: %2 | endxit $sockname | sockclose $sockname }
  }
  if ($chr(125) isin $1) { endxit $sockname | sockclose $sockname }
}
alias -l endxit {
  if ($eval($+(%,$1,chan),2)) { 
    if ($window($eval($+(%,$1,chan),2)).stamp == $false) { var %s = 32 }
    else { var %s = $len($timestamp) + 31 }
    var %q = * [IPInfo] $iif(%theme_spaces == yes,$str($chr(160),$calc(17 - $len($eval($+(%,$1,nick),2))))) $replace($eval($+(%,$1,line),2),United States of America,USA)
    if (%q != * [IPInfo]) { echo $color(join) $iif(%theme_spaces == yes,$+(-ti,%s),-t) $eval($+(%,$1,chan),2) %q }
  }
  unset $eval($+(%,$1,line),1) $eval($+(%,$1,chan),1) $eval($+(%,$1,nick),1)
}

;=======================================

alias -l c { return $chr(9679) } 

;=======================================

alias join {
  if (!$server) { echo $color(info) -tag * [JOIN] Not connected to any server! }
  else { !join $1-2 }
}

#theme end