So, the new version of the script is ready. I had to tinker a little (especially with testing) because of which I had to constantly make new edits to the code and also had to create custom identifiers for repetitive actions.
I hope I managed to implement all your ideas and even a little more, so that the script matches your requirements.

Akick Temp Ban v2.0 – updates:

  1.Highly it is recommended in bot to run the command: "/atb_remove_vars" so that delete all old data stored in variables for the correct transition to the new version of the script.
  2.All text used in the script has been moved to variables in alias "atb_set" for easy editing and translation into your native language, so that more don't have to search/fix this is in another part of the code (to avoid crashing).
  3.Now all tokens-values in the database are separated by semicolon ";" instead of the usual comma "," – please change this on every line or just remove the old database. (It is very important).
     Example line from database: "[id:XW93884];troll;*!*@OKCHI.VPXW7.JMXH6.HEQ79;#test;🔨 Get out of here away!"

  4.Added new and changed some names of old variables in alias "atb_set". You can edit the values of these variables at your discretion, observing the correct format in the examples given:

     %atb_commhelp – contains a command for help. Default: <!bhelp>. (You can change this to any command you like).
     %atb_commadd – contains a command to add new users to the database list. Default: <!badd>. (You can change this to any command you like).
     %atb_commdel – contains a command to remove users from the database list. Default: <!bdel>. (You can change this to any command you like).
     %atb_commfind – contains a command to search for users in the database list. Default: <!bfind>. (You can change this to any command you like).
     %atb_commlist – contains a command to display a list of users in the database. Default: <!blist>. (You can change this to any command you like).
     %atb_pathreason – contains the path to a text file with a list of reasons for the kick. By default, it is assumed that the file will be located in the same place as the script: <$scriptdir $+ atb_reason.txt>.
     %atb_idprefix – contains a prefix for the id of the kick number. Default: <id:>. (You can change this to any other text/prefix you like).
     %atb_idformat – contains a value from characters to generate an identification number in random order: <L> = one letter, <N> = one numeral. Correct default format: <LLNNNNN>. If want only numbers, then set: <NNNNN>.
     %atb_btime – contains the time for which a temporary ban will be set. Correct format: <1s|1m|1h|1d>. Default: <10m>.
     %atb_stopcomm – contains time to protect against frequent and fast execution of commands. Correct format: <1s|1m|1h|1d>. Default: <3s>.

  5.Added new commands. Full list and their correct syntax:

     Add user to database: "!badd <nick> <host> [id] [reason]".
     Delete user from database: "!bdel <nick|host|id>".
     Find a user in the database: "!bfind <nick|mask|id>".
     List of users in the database: "!blist [N[-N]]".


Demo screenshots of the script's operability:


    [Linked Image from i.ibb.co]


This code must be inserted into the scripts editor. To do this, press the key combination "ALT+R" find the old code and replace it with the new one via "View", further save script called "AkickTempBan.mrc":


Code
#####################################################################
#   Name: Akick Temp Ban v2.0
#   Author: Epic (epicnet@mail.ru, http://epicnet.ru)
#   Description: Sets a temporary ban, which is automatically removed after a while and the intruder is entered into the database for subsequent auto-ban.
#   Commands: !bhelp
#####################################################################

alias atb_set {
  %atb_work = yes
  %atb_kick = yes
  %atb_akick = yes
  %atb_notice = yes
  %atb_private = no
  %atb_chans = all
  %atb_comm = !b
  %atb_commhelp = !bhelp
  %atb_commadd = !badd
  %atb_commdel = !bdel
  %atb_commfind = !bfind
  %atb_commlist = !blist
  %atb_pathreason = $scriptdir $+ atb_reason.txt
  %atb_pathdb = $scriptdir $+ atb_database.txt
  %atb_icons = 🔨,✞,☠,🔥,⚡,🌠,🏁,🚩,😈
  %atb_idprefix = id:
  %atb_idformat = LLNNNNN
  %atb_btype = 2
  %atb_btime = 10m
  %atb_stopcomm = 3s
  %atb_admins = Epic,Robert
  %atb_prefix = [!,~,&,@,%]
  ;-------------------------
  %atb_logo = AkickTempBan
  %atb_msg_rd = Bye! You are banned
  %atb_msg_cs = Correct syntax:
  %atb_msg_stopcomm = %atb_logo - Stop! Don't write commands so fast. It remains to wait:
  ;-------------------------
  %atb_msg_syntax_comm = %atb_comm <nick> [reason]
  %atb_msg_syntax_commadd = %atb_commadd <nick> <host> [id] [reason]
  %atb_msg_syntax_commdel = %atb_commdel <nick|host|id>
  %atb_msg_syntax_commfind = %atb_commfind <nick|mask|id>
  %atb_msg_syntax_commlist = %atb_commlist [N[-N]]
  ;-------------------------
  %atb_head_help = %atb_logo - Help for commands:
  %atb_msg_help1 = Set a temporary ban on the channel: %atb_msg_syntax_comm
  %atb_msg_help2 = Add user to database: %atb_msg_syntax_commadd
  %atb_msg_help3 = Delete user from database: %atb_msg_syntax_commdel
  %atb_msg_help4 = Find a user in the database: %atb_msg_syntax_commfind
  %atb_msg_help5 = List of users in the database: %atb_msg_syntax_commlist
  ;-------------------------
  %atb_head_add = %atb_logo - Adding a write to the database:
  %atb_false_add = %atb_logo - Such an entry already exists in the database:
  %atb_head_del1 = %atb_logo - Deleting channel from a line:
  %atb_head_del2 = %atb_logo - Line deleted from database:
  %atb_msg_del = Your channel has been removed from the list:
  %atb_false_del1 = %atb_logo - For this user there is no longer a ban for your channel:
  %atb_false_del2 = %atb_logo - Nothing found... Try changing search data.
  %atb_head_find = %atb_logo - According to your request, the database found:
  %atb_false_find = %atb_logo - Nothing found... Try changing search data.
  %atb_head_list = %atb_logo -  List of users in the database - Total:
  %atb_msg_check1 = %atb_logo - You don't have enough rights. Mandatory status prefix on the channel:
  %atb_msg_check2 = %atb_logo - I have no rights on this channel. I need a status prefix: ~,&,@,%
  %atb_msg_check3 = %atb_logo - I do not see on the channels a nickname:
}
=====================================================
on *:TEXT:*:#:{
  atb_set | if (%atb_work == yes) {
    if (%atb_chans == all) || ($istok(%atb_chans,$chan,44)) {
      var %atb_tokens $strip($1) $chan $nick $strip($2-) | tokenize 32 %atb_tokens
      if ($1 == %atb_comm) { if (!$stopcomm($2,$3)) { atb_check $1- | atb_bankick_comm $2- | stopcomm $2-3 } | else .notice $3 $stopcomm($2,$3) }
      if ($1 == %atb_commhelp) { if (!$stopcomm($2,$3)) { atb_check $1- | atb_help $2- | stopcomm $2-3 } | else .notice $3 $stopcomm($2,$3) }
      if ($1 == %atb_commadd) { if (!$stopcomm($2,$3)) { atb_check $1- | atb_add $2- | stopcomm $2-3 } | else .notice $3 $stopcomm($2,$3) }
      if ($1 == %atb_commdel) { if (!$stopcomm($2,$3)) { atb_check $1- | atb_del $2- | stopcomm $2-3 } | else .notice $3 $stopcomm($2,$3) }
      if ($1 == %atb_commfind) { if (!$stopcomm($2,$3)) { atb_check $1- | atb_find $2- | stopcomm $2-3 } | else .notice $3 $stopcomm($2,$3) }
      if ($1 == %atb_commlist) { if (!$stopcomm($2,$3)) { atb_check $1- | atb_list $2- | stopcomm $2-3 } | else .notice $3 $stopcomm($2,$3) }
    }
  }
}
on *:JOIN:#:{ atb_set | if (%atb_work == yes) { if (%atb_chans == all) || ($istok(%atb_chans,$chan,44)) { var %atb_jnick $nick | var %atb_jhost $address($nick,%atb_btype) | if ($istok($findb(%atb_jnick).chan,$chan,44)) { atb_bankick_jn $chan !nomsg! %atb_jnick $findb(%atb_jnick).id $findb(%atb_jnick).reason | halt } | if ($istok($findb(%atb_jhost).chan,$chan,44)) { atb_bankick_jn $chan !nomsg! %atb_jnick $findb(%atb_jhost).id $findb(%atb_jhost).reason } } } }
on *:NICK:{ atb_set | if (%atb_work == yes) { var %atb_nn $newnick | if ($findc(%atb_nn)) { var %atb_fcs $v1 | var %y 1 | while (%y <= $numtok(%atb_fcs,44)) { var %atb_fc $gettok(%atb_fcs,%y,44) | var %atb_nnick %atb_nn | var %atb_nhost $address(%atb_nn,%atb_btype) | if ($istok($findb(%atb_nnick).chan,%atb_fc,44)) { atb_bankick_jn %atb_fc !nomsg! %atb_nnick $findb(%atb_nnick).id $findb(%atb_nnick).reason | goto next1 } | if ($istok($findb(%atb_nhost).chan,%atb_fc,44)) { atb_bankick_jn %atb_fc !nomsg! %atb_nnick $findb(%atb_nhost).id $findb(%atb_nhost).reason } | :next1 | inc %y } } } }
-----------------------------------------------------
alias -l atb_check {
  var %atb_up $remove($nick($2,$3).pnick,$3)
  if (!$istok(%atb_admins,$3,44) && $sprefix(%atb_up,%atb_prefix,44) == $false) { .notice $3 %atb_msg_check1 $remove(%atb_prefix,[,]) | halt }
  if ($1 == %atb_comm) { if (!$count($nick($2,$me).pnick,~,&,@,%)) { .notice $3 %atb_msg_check2 | halt } | if (!$4) { .notice $3 %atb_msg_cs %atb_msg_syntax_comm | halt } | if (!$comchan($4,0)) { .notice $3 %atb_msg_check3 $4 | halt } }
  if ($1 == %atb_commadd) { if (!$4) || (!$5) { .notice $3 %atb_msg_cs %atb_msg_syntax_commadd | halt } | if ($6 && $chr(35) isin $6) { .notice $3 %atb_msg_cs %atb_msg_syntax_commadd | halt } }
  if ($1 == %atb_commdel) { if (!$4) { .notice $3 %atb_msg_cs %atb_msg_syntax_commdel | halt } }
  if ($1 == %atb_commfind) { if (!$4) { .notice $3 %atb_msg_cs %atb_msg_syntax_commfind | halt } }
  if ($1 == %atb_commlist) { if ($4 && $4 !isnum && - !isin $4) || ($4 && - isin $4 && !$count($gettok($4,1,45),0,1,2,3,4,5,6,7,8,9)) || ($4 && - isin $4 && !$count($gettok($4,2,45),0,1,2,3,4,5,6,7,8,9)) { .notice $3 %atb_msg_cs %atb_msg_syntax_commlist | halt } }
}
-----------------------------------------------------
alias -l atb_bankick_comm { if ($findb($3)) { var %atb_banid $findb($3).id | var %atb_reason $findb($3).reason } | else { var %atb_banid $+([,%atb_idprefix,$idform(%atb_idformat),]) | if (%atb_icons != $null) var %atb_icon $gettok(%atb_icons,$rand(1,$numtok(%atb_icons,44)),44) | if ($4) var %atb_reason %atb_icon $4- | else { if ($exists(%atb_pathreason) == $true) var %atb_reason %atb_icon $read(%atb_pathreason) | else var %atb_reason %atb_icon %atb_msg_rd } } | atb_bankick_act $1 $2 $3 %atb_banid %atb_reason }
alias -l atb_bankick_jn { if ($findb($3)) { var %atb_banid $findb($3).id | var %atb_reason $findb($3).reason } | else { if (%atb_icons != $null) var %atb_icon $gettok(%atb_icons,$rand(1,$numtok(%atb_icons,44)),44) | if (!$4) { var %atb_banid $+([,%atb_idprefix,$idform(%atb_idformat),]) } | else { var %atb_banid $4 } | if (!$5) { if ($exists(%atb_pathreason) == $true) var %atb_reason %atb_icon $read(%atb_pathreason) | else var %atb_reason %atb_icon %atb_msg_rd } | else { var %atb_reason $5- } } | atb_bankick_act $1 $2 $3 %atb_banid %atb_reason }
alias -l atb_bankick_act {
  if (%atb_akick == yes) { var %atb_aknick $3 | var %atb_akhost $address($3,%atb_btype) | if ($findb(%atb_aknick) && $2 != !nomsg!) { if (!$istok($findb(%atb_aknick).chan,$1,44)) { var %atb_l $findb(%atb_aknick).line | var %atb_s $findb(%atb_aknick).string | var %atb_t $+($gettok(%atb_s,4,59),$chr(44),$1) | var %atb_ns $puttok(%atb_s,%atb_t,4,59) | .write -l $+ %atb_l $qt(%atb_pathdb) %atb_ns } } | if ($findb(%atb_akhost) && $2 != !nomsg!) { if (!$istok($findb(%atb_akhost).chan,$1,44)) { var %atb_l $findb(%atb_akhost).line | var %atb_s $findb(%atb_akhost).string | var %atb_t $+($gettok(%atb_s,4,59),$chr(44),$1) | var %atb_ns $puttok(%atb_s,%atb_t,4,59) | .write -l $+ %atb_l $qt(%atb_pathdb) %atb_ns } } | if (!$findb(%atb_aknick) && !$findb(%atb_akhost)) { .write -il1 $qt(%atb_pathdb) $+($4,$chr(59),$3,$chr(59),$address($3,%atb_btype),$chr(59),$1,$chr(59),$5-) } }
  .ban $+(-u,$convertsec(%atb_btime)) $1 $3 %atb_btype | if (%atb_kick == yes && $3 ison $1) { .kick $1 $3 $5- $4 } | if (%atb_notice == yes && $2 != !nomsg!) { .notice $2 %atb_logo - $3 $+($chr(40),%atb_btime,$chr(41)) $4 $findb($3).chan - $5- } | if (%atb_private == yes && $2 != !nomsg!) { .msg $2 %atb_logo - $3 $+($chr(40),%atb_btime,$chr(41)) $4 $findb($3).chan - $5- }
}
-----------------------------------------------------
alias -l atb_help { .notice $2 %atb_head_help | .notice $2 %atb_msg_help1 | .notice $2 %atb_msg_help2 | .notice $2 %atb_msg_help3 | .notice $2 %atb_msg_help4 | .notice $2 %atb_msg_help5 }
alias -l atb_add {
  if (!$findb($3)) { var %atb_ah $+(*!*@,$remove($4,*,!,@)) | if (%atb_icons != $null) var %atb_icon $gettok(%atb_icons,$rand(1,$numtok(%atb_icons,44)),44) | var %atb_banchans $1 | if ($5) { var %atb_banid $+([,%atb_idprefix,$remove($5,id,:,[,]),]) } | else { var %atb_banid $+([,%atb_idprefix,$idform(%atb_idformat),]) } | if ($6) { var %atb_reason %atb_icon $6- } | else { if ($exists(%atb_pathreason) == $true) var %atb_reason %atb_icon $read(%atb_pathreason) | else var %atb_reason %atb_icon %atb_msg_rd } | .write -il1 $qt(%atb_pathdb) $+(%atb_banid,$chr(59),$3,$chr(59),%atb_ah,$chr(59),%atb_banchans,$chr(59),%atb_reason) | .notice $2 %atb_head_add | .notice $2 $+(,1,.,) %atb_banid $3 %atb_ah %atb_banchans - %atb_reason | return }
  else { if (!$istok($findb($3).chan,$1,44)) { var %atb_l $findb($3).line | var %atb_s $findb($3).string | var %atb_t $+($gettok(%atb_s,4,59),$chr(44),$1) | var %atb_ns $puttok(%atb_s,%atb_t,4,59) | .write -l $+ %atb_l $qt(%atb_pathdb) %atb_ns | var %atb_an $2 | tokenize 59 $findb($3).string | .notice %atb_an %atb_head_add | .notice %atb_an $+(,%atb_l,.,) $1-4 - $5- | return } } | var %atb_an $2 | tokenize 59 $findb($3).string | .notice %atb_an %atb_false_add $2 = line $+($chr(40),,$findb($3).line,,$chr(41)) | .notice %atb_an $+(,$findb($3).line,.,) $1-4 - $5-
}
alias -l atb_del { if ($3 && $findb($3)) { var %atb_dcc $1 | var %atb_dn $2 | var %atb_dl $findb($3).line | var %atb_ds $findb($3).string | var %atb_dc $findb($3).chan | if ($istok(%atb_dc,$1,44)) { var %atb_dc $remextcom($remove(%atb_dc,%atb_dcc)) | if (%atb_dc != $null) { var %atb_dst $puttok(%atb_ds,%atb_dc,4,59) | .write -l $+ %atb_dl $qt(%atb_pathdb) %atb_dst | tokenize 59 $findb($3).string | .notice %atb_dn %atb_head_del1 | .notice %atb_dn $+(,%atb_dl,.,) $1-4 - $5- | .notice %atb_dn %atb_msg_del %atb_dcc } | else { tokenize 59 %atb_ds | .write -dl $+ %atb_dl $qt(%atb_pathdb) | .notice %atb_dn %atb_head_del2 | .notice %atb_dn $+(,%atb_dl,.,) $1-4 - $5- } } | else { tokenize 59 %atb_ds | .notice %atb_dn %atb_false_del1 %atb_dcc | .notice %atb_dn $+(,%atb_dl,.,) $1-4 - $5- } } | else { .notice $2 %atb_false_del2 } }
alias -l atb_find { if ($3 && $findb($3)) { .notice $2 %atb_head_find | var %atb_fn $2 | var %atb_fl $findb($3).line | var %atb_fs $findb($3).string | tokenize 59 %atb_fs | .notice %atb_fn $+(,%atb_fl,.,) $1-4 - $5- } | else { .notice $2 %atb_false_find } }
alias -l atb_list { var %atb_ln $2 | var %atb_lnum $3 | var %atb_ll $lines(%atb_pathdb) | .notice %atb_ln %atb_head_list $+($chr(40),,%atb_ll,,$chr(41)) | var %w 1 | while (%w <= %atb_ll) { tokenize 59 $read(%atb_pathdb,%w) | if (!%atb_lnum) .notice %atb_ln $+(,%w,.,) $1-4 - $5- | if (%atb_lnum && - !isin %atb_lnum) { if (%w <= %atb_lnum) { .notice %atb_ln $+(,%w,.,) $1-4 - $5- } | else { .break } } | if (%atb_lnum && - isin %atb_lnum) { if (%w >= $gettok(%atb_lnum,1,45)) { .notice %atb_ln $+(,%w,.,) $1-4 - $5- } | if (%w >= $gettok(%atb_lnum,2,45)) { .break } } | inc %w } }
alias atb_remove_vars { unset %atb_* | .echo -st All script variables "AkickTempBan" have been deleted successfully. }
-----------------------------------------------------
alias -l findb { :next3 | if (!%sbd_line) var %sbd_line 1 | if ($read(%atb_pathdb, -w, $+(*,$1,*), %sbd_line)) { var %sdb_r $readn | var %sdb_s $read(%atb_pathdb,%sdb_r) | var %sbd_s1 $remove($gettok(%sdb_s,1,59),[id:,]) | var %sbd_s2 $gettok(%sdb_s,2,59) | var %sbd_s3 $gettok(%sdb_s,3,59) | if ($1 == %sbd_s1) || ($1 == %sbd_s2) || ($+(*,$1,*) iswm %sbd_s3) { if (line == $prop) return %sdb_r | if (string == $prop) return %sdb_s | if (id == $prop) return $gettok(%sdb_s,1,59) | if (nick == $prop) return $gettok(%sdb_s,2,59) | if (host == $prop) return $gettok(%sdb_s,3,59) | if (chan == $prop) return $gettok(%sdb_s,4,59) | if (reason == $prop) return $gettok(%sdb_s,5-,59) | return $true } | else { inc %sbd_line | if (%sbd_line <= $lines(%atb_pathdb)) goto next3 } } }
alias -l findc { var %n 1 | while (%n <= $comchan($1,0)) { var %coc $comchan($1,%n) | if (%atb_chans == all) || ($istok(%atb_chans,%coc,44)) { if (!%clc) var %clc %coc | else var %clc $+(%clc,$chr(44),%coc) } | inc %n } | return %clc }
alias -l sprefix { var %sp_sp $remove($2,[,]) | var %sp_sn $numtok(%sp_sp,$3) | var %q 1 | while (%q <= %sp_sn) { if ($gettok(%sp_sp,%q,$3) isin $1) return $true | inc %q } | return $false }
alias -l stopcomm { if ($hget($+(stopcomm,$2),$1)) return %atb_msg_stopcomm $+($chr(40),,$v1,,$chr(41),$chr(32),sec.) | if (!$hget($+(stopcomm,$2),$1)) .hadd -mz $+(stopcomm,$2) $1 $convertsec(%atb_stopcomm) }
alias -l convertsec { var %cst $right($1,1) | var %csn $remove($1,%cst) | if ($count(%cst,s,m,h,d)) { if (%cst == s) return %csn | if (%cst == m) return $calc(%csn * 60) | if (%cst == h) return $calc(%csn * 3600) | if (%cst == d) return $calc(%csn * 86400) } | else { .echo -st %atb_logo - Error: Invalid time format - Correct format: 1s,1m,1h,1d | return 60 } }
alias -l idform { if ($countcs($1,L,N)) { unset %atb_cif | var %i 1 | while (%i <= $len($1)) { if ($mid($1,%i,1) == L) var %atb_cif $+(%atb_cif,$rand(A,Z)) | if ($mid($1,%i,1) == N) %atb_cif = $+(%atb_cif,$rand(0,9)) | inc %i } | return %atb_cif } | else { .echo -st %atb_logo - Error: Invalid ID format - Correct format: LLNNNNN - L = random letter, N = random number. | return $+($rand(A,Z),$rand(A,Z),$rand(10000,99999)) } }
alias -l remextcom { var %rc_s $1 | :next4 | var %rc_s $replace(%rc_s,$+($chr(44),$chr(44)),$chr(44)) | if ($left(%rc_s,1) == $chr(44)) var %rc_s $mid(%rc_s,2) | if ($right(%rc_s,1) == $chr(44)) { var %rc_s $mid(%rc_s,1,$calc($len(%rc_s) -1)) | goto next4 } | return %rc_s }
=====================================================



Remember that if something went wrong, or you accidentally erased something, then you can always reinstall this script again.
I recommend that you test this script thoroughly on empty channels before you start using it for real with real users.
If you find any errors in the code or in its work, then be sure to write to me here about it, and we are together think about what we can do.




🌐 https://forum.epicnet.ru 📜 irc.epicnet.ru 6667 #Code | mIRC scripts, help, discuss, examples