#####################################################################
# Name: Auto Limit Users v1.3
# Author: Epic (http://epicnet.ru, irc.epicnet.ru:6667 #Code)
# Description: Auto sets the limit mode (+l) for the maximum allowed number of users on the channel.
#####################################################################
menu menubar,status,channel {
$+($iif(%alu_work == on,$style(1)),Auto Limit Users,$chr(9)): alu_dialog
}
alias -l alu_dialog { alu_default_set | if ($dialog(alu)) .dialog -x alu | .dialog -m alu alu }
dialog alu {
title "Auto Limit Users"
size -1 -1 300 272
option pixels
icon $mircexe,22
;-------------------------
tab "Settings", 1, 1 0 300 226
tab "Networks", 2
;-------------------------
box "Setting numerical values:", 10, 30 51 240 140, tab 1
text "Join Timer:", 11, 43 80 60 15, right, tab 1
edit %alu_timer_join, 12, 107 77 30 20, autohs, limit 3, tab 1
text "Part Timer:", 13, 43 105 60 15, right, tab 1
edit %alu_timer_part, 14, 107 102 30 20, autohs, limit 3, tab 1
text "Kick Timer:", 15, 43 130 60 15, right, tab 1
edit %alu_timer_kick, 16, 107 127 30 20, autohs, limit 3, tab 1
text "Quit Timer:", 17, 43 155 60 15, right, tab 1
edit %alu_timer_quit, 18, 107 152 30 20, autohs, limit 3, tab 1
text "Max Events:", 19, 155 80 60 15, right, tab 1
edit %alu_max_events, 20, 219 77 30 20, autohs, limit 3, tab 1
text "Plus Limit:", 21, 140 105 75 15, right, tab 1
edit %alu_plus_limit, 22, 219 102 30 20, autohs, limit 3, tab 1
;-------------------------
box "List of networks for work:", 50, 30 51 240 140, tab 2
list 51, 45 76 145 115, tab 2
button "Add", 52, 201 87 55 21, center flat, tab 2
button "Edit", 53, 201 113 55 21, center flat, tab 2
button "Del", 54, 201 139 55 21, center flat, tab 2
;-------------------------
button "Default", 999, 30 236 75 23, center flat
button "OK", 1000, 195 236 75 23, center flat default ok
}
on *:DIALOG:alu:init:0: alu_default_set | if (%alu_tab == 2) alu_list_networks | .timerALUTAB -m 1 0 alu_tab_focus
on *:DIALOG:alu:sclick:1: %alu_tab = 1 | .did -f alu 1000
on *:DIALOG:alu:sclick:2: %alu_tab = 2 | .did -f alu 1000 | .did -r alu 51 | alu_list_networks
on *:DIALOG:alu:edit:12: %alu_timer_join = $did($did).text
on *:DIALOG:alu:edit:14: %alu_timer_part = $did($did).text
on *:DIALOG:alu:edit:16: %alu_timer_kick = $did($did).text
on *:DIALOG:alu:edit:18: %alu_timer_quit = $did($did).text
on *:DIALOG:alu:edit:20: %alu_max_events = $did($did).text
on *:DIALOG:alu:edit:22: %alu_plus_limit = $did($did).text
on *:DIALOG:alu:sclick:52: var %nw $input(Enter the network name:,eo,Add) | if (%nw) { %alu_networks = $+(%alu_networks,$chr(44),%nw) | .did -a alu 51 %nw }
on *:DIALOG:alu:sclick:53: var %l $did(alu,51).sel, %t $did(alu,51).seltext | if (%t) { var %nw $input(Change the network name:,eo,Edit,%t) | if (%nw) { %alu_networks = $puttok(%alu_networks,%nw,$findtok(%alu_networks,%t,1,44),44) | .did -o alu 51 %l %nw } }
on *:DIALOG:alu:sclick:54: var %l $did(alu,51).sel, %t $did(alu,51).seltext | if (%t) { .did -d alu 51 %l | %alu_networks = $deltok(%alu_networks,$findtok(%alu_networks,%t,1,44),44) }
on *:DIALOG:alu:sclick:999: unset %alu_* | alu_dialog
---------------------------------------------------------------------
on !*:JOIN:#: alu
on *:PART:#: alu
on *:KICK:#: alu
on *:QUIT: alu
alias -l alu {
if (%alu_networks && !$istok(%alu_networks,$network,44)) { return }
if ($event == join) {
.hinc -m $+(alu_,$chan) join 1 | if ($hget($+(alu_,$chan),join) >= %alu_max_events) {
if ($me isop $chan) .timerALU_ $+ $chan 1 %alu_timer_join mode $chan +l $calc($nick($chan,0) + %alu_plus_limit) | .hdel -sw $+(alu_,$chan) *
}
}
if ($event == part) {
.hinc -m $+(alu_,$chan) part 1 | if ($hget($+(alu_,$chan),part) >= %alu_max_events) {
if ($me isop $chan) .timerALU_ $+ $chan 1 %alu_timer_part mode $chan +l $calc($nick($chan,0) + %alu_plus_limit -1) | .hdel -sw $+(alu_,$chan) *
}
}
if ($event == kick) {
.hinc -m $+(alu_,$chan) kick 1 | if ($hget($+(alu_,$chan),kick) >= %alu_max_events) {
if ($me isop $chan) .timerALU_ $+ $chan 1 %alu_timer_kick mode $chan +l $calc($nick($chan,0) + %alu_plus_limit -1) | .hdel -sw $+(alu_,$chan) *
}
}
if ($event == quit) {
var %i 1 | while (%i <= $comchan($nick,0)) {
var %chan $comchan($nick,%i) | .hinc -m $+(alu_,%chan) quit 1 | if ($hget($+(alu_,%chan),quit) >= %alu_max_events) {
if ($me isop %chan) .timerALU_ $+ %chan 1 %alu_timer_quit mode %chan +l $calc($nick(%chan,0) + %alu_plus_limit -1) | .hdel -sw $+(alu_,%chan) *
} | inc %i
}
}
}
alias -l alu_tab_focus { .did -fu alu %alu_tab | .did -f alu 1000 }
alias -l alu_list_networks { var %i 1 | while (%i <= $numtok(%alu_networks,44)) { .did -a alu 51 $gettok(%alu_networks,%i,44) | inc %i } }
alias -l alu_default_set {
if (!%alu_tab) || (%alu_tab == $null) { %alu_tab = 1 }
if (!%alu_networks) || (%alu_networks == $null) { %alu_networks = EpicNet.Ru,DaVang }
if (!%alu_timer_join) || (%alu_timer_join == $null) { %alu_timer_join = 10 }
if (!%alu_timer_part) || (%alu_timer_part == $null) { %alu_timer_part = 5 }
if (!%alu_timer_kick) || (%alu_timer_kick == $null) { %alu_timer_kick = 5 }
if (!%alu_timer_quit) || (%alu_timer_quit == $null) { %alu_timer_quit = 5 }
if (!%alu_max_events) || (%alu_max_events == $null) { %alu_max_events = 3 }
if (!%alu_plus_limit) || (%alu_plus_limit == $null) { %alu_plus_limit = 5 }
}