mIRC Homepage
Posted By: NoPleX Idle kick&ban script - 29/05/04 05:41 AM
Hello.

I am making my own help channel named #needhelp and i want a script like the script on Helpy on #help
The script kicks and ban people who doesnt say anything for 10 minutes.

And i want the script to do the same thing but it sould not kick and ban people who got op or voice.

It would be great if some one could give me a script smile


NoPleX
Posted By: FiberOPtics Re: Idle kick&ban script - 29/05/04 10:21 AM
Hi,

the following piece of code will ban/kick any person that joins your channel, and doesn't say anything in 10 mins after joining. If they do say something, then the script won't kick them anymore.
Code:
 
#idlekicker on
 [color:red]  [/color] 
on *@!:JOIN:#needhelp: if !$timer($nick) { $+(.timer,$nick) 1 600 KickIdler $chan $nick }
on *:TEXT:*:#needhelp: if $timer($nick) { $+(.timer,$nick) off }
alias KickIdler if ($me isop $1) && ($2 isreg $1) { ban -k $1-2 2 Idling is not allowed! }
  [color:green]  [/color] 
#idlekicker end


Of course, people could say something within 10 minutes after joining, and then not say something for ages. To go around this, I've made you an alias that you can use, which will check all the regular nicks (not voiced, oped) for their idle time on the channel, and if the idle time is higher than 600 seconds, then it will ban/kick them.
Code:
 
alias CheckIdlers {
  var %chan = #needhelp
  if ($me !isop %chan) { echo -a You are not oped on %chan | return }
  var %a = $nick(%chan,0,r)
  while (%a) { 
    if ($nick(%chan,%a,r).idle > 600) { ban -k %chan $nick(%chan,%a,r) 2 Idling is not allowed! }
    dec %a
  }
}

Usage: /CheckIdlers

Hope this was useful for you,

Greets
Posted By: NoPleX Re: Idle kick&ban script - 29/05/04 11:56 AM
Ok thanks! Will the timer restart every time thay write something. I mean if thay dont say anything for 5 minutes and then say something, will it then start with 10 minutes and count down again?
If yes, how do i change the channel idle scan time?
Posted By: FiberOPtics Re: Idle kick&ban script - 29/05/04 12:21 PM
Ah ic,

well then let me propose to you 2 solutions, so pick one of them:

Solution 1
Code:
  
#idlekicker on 
[color:red]  [/color] 
on me:*:JOIN:#needhelp: .timer 0 300 CheckIdlers
[color:red]  [/color] 
#idlekicker end
 [color:red]  [/color] 
alias CheckIdlers {
  var %chan = #needhelp
  if ($me !isop %chan) { echo -a You are not oped on %chan | return }
  var %a = $nick(%chan,0,r)
  while (%a) { 
    if ($nick(%chan,%a,r).idle > [color:red]600[/color]) { ban -k %chan $nick(%chan,%a,r) 2 Idling is not allowed! }
    dec %a
  }
}


What will this script do?

1) When you join your channel #needhelp, a timer will start. That timer will be called upon every 300 seconds (= 5 minutes) and it will trigger the alias CheckIdlers.

2) So every 5 minutes the alias CheckIdlers will scan your channel for the idle times of all the regular nicks (not ops, voices). It will see if the idle times are higher than 600 seconds, and if so, it will ban/kick them from your channel.

To change the permitted idle time for your users, you simply change the 600 to whatever value you want. Say that your users may idle for 15 minutes, then simply change 600 to 900 in the alias CheckIdlers.

The first 300 = at which interval do you want to check for idlers. You can set this to whatever, like say if you want to check every 2 minutes, you would change it to 120.

The second 600 = the maximum allowed idle time that people may have when being on your channel.

Note that because the timer is only triggered every 300 seconds, the users have a safety interval of 300 seconds. This means that the maximum theoretical idle time that they can have is 600 + 300= 900 seconds. That's because the timer isn't checking every second if the idle time is above 600 seconds.

So the smaller you make the interval (perhaps change to 60 seconds), the lesser their maximum theoretical idle time will be, being: 600 + 60= 660


Solution 2
If you really really want to make sure that they only idle 600 seconds, and not 1 second more than that, then there's no other way than to create individual timers.
The solution would then be: (change the 600 to whatever maximum idle time you want)
Code:
 

#idlekicker on
 [color:red]  [/color] 
on *@!:JOIN:#needhelp: if !$timer($nick) { $+(.timer,$nick) 1 600 KickIdler $chan $nick }
on *:TEXT:*:#needhelp: $+(.timer,$nick) 1 600 KickIdler $chan $nick
alias KickIdler if ($me isop $1) && ($2 isreg $1) { ban -k $1-2 2 Idling is not allowed! }
 [color:red]  [/color] 
#idlekicker end
 


Solution 1 is less work for mIRC cuz it doesn't have to keep setting timers, but the downside is that because of the interval of the timer, you cannot make the idle time 100% strict.

Solution 2 is more work for mIRC cuz it has to set an individual timer for everyone who joins your channel, and re-set the timer for everyone who speaks. The good thing, is that the idle time will be exactly at a maximum of 600 seconds, with no interval whatsoever.

Greets
Posted By: NoPleX Re: Idle kick&ban script - 29/05/04 12:59 PM
Thanks your the mann cool

Your quite hardcore at this wink

And if i only want them to get banned for 300 seconds i'll just insert -u300 right?

Like so:

alias CheckIdlers {
var %chan = #needhelp
if ($me !isop %chan) { echo -a You are not oped on %chan | return }
var %a = $nick(%chan,0,r)
while (%a) {
if ($nick(%chan,%a,r).idle > 600) { ban -u300 -k %chan $nick(%chan,%a,r) 2 Please do not idle on #needhelp, come back later if you got any questions }
dec %a
}
}
Posted By: FiberOPtics Re: Idle kick&ban script - 29/05/04 01:30 PM
Hehe,

you're almost there:
Code:

alias CheckIdlers {
  var %chan = #needhelp
  if ($me !isop %chan) { echo -a You are not oped on %chan | return }
  var %a = $nick(%chan,0,r)
  while (%a) {
    if ($nick(%chan,%a,r).idle > 600) { 
      ban [color:red]-ku300 [/color]%chan $nick(%chan,%a,r) 2 Please do not idle on %chan $+ , come back later if you got any questions
    }
    dec %a 
  }
}


Greets
Posted By: NoPleX Re: Idle kick&ban script - 29/05/04 01:38 PM
Hehe ok.

Well it was a good guess :tongue:

I never use to make the ban and kick script that way though.

But thanks for you help! You are Great smile
Posted By: FiberOPtics Re: Idle kick&ban script - 29/05/04 02:00 PM
Hehe,

you're welcome. Gotta go now, unfortunately I must study for the exams frown

I wish I studied programming, atleast then studying would be fun :tongue:


Cya later!
Posted By: NoPleX Re: Idle kick&ban script - 29/05/04 09:17 PM
Hehe good luck on your exams smile
© mIRC Discussion Forums