• Welcome to Valhalla Legends Archive.
 

Automoderation - Idleban/kick

Started by Mephisto, October 22, 2004, 01:59 PM

Previous topic - Next topic

Mephisto

Logically I am having trouble implementing the automoderation modes idleban and idlekick.  I have the general idea, but I can't really put it together to where it works logically.  Can anyone share their implementations of it?  Perhaps Skywing/Kp from ZeroBot or iago/Trust from JavaOp or anyone else who would know how to do this...?

Minux

Quote from: Mephisto on October 22, 2004, 01:59 PM
Logically I am having trouble implementing the automoderation modes idleban and idlekick.  I have the general idea, but I can't really put it together to where it works logically.  Can anyone share their implementations of it?  Perhaps Skywing/Kp from ZeroBot or iago/Trust from JavaOp or anyone else who would know how to do this...?

Unfortunately I've only done this in VB, so I don't know if that is what you're looking for.

LivedKrad

I don't think he's looking for code, like he said, logic. I'm sure Mephisto can do the code as long as he has the right idea about doing it. Mephisto, maybe it could add each user that joined in a specific time frame to be added to an array or another sorting method. That way, you can reduce the amount of timers needed to ban/kick the certain people. (In the specified order of the arrays). I doubt this is a very accurate way though ;\

Mephisto

Minus, if you could share your implementation (explain how you do it) I'd appreciate it.  LivedKrad, not entirely sure what you mean, but I'm in a hurry to get out of the house so I'll analyze it better when I get back.  Thanks for sharing :)

iago

The idea behind vL's is that each event that occurs takes them one step closer to the limit.  You need to keep track of how many events have occurred since the last time they've been active (I'd imagine you'd have a list or vector or whatever of users in the channel who are vulnerable to it, and each of them would have a count associated with them).  When the key event occurs to put them over the threshold, they're kicked or banned.

The other option is to use timing, just store the last time they talked, and every time they talk the time is reset, and when an event occurs it checks if they're over the threshold.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Minux

Quote from: iago on October 22, 2004, 05:52 PM
The other option is to use timing, just store the last time they talked, and every time they talk the time is reset, and when an event occurs it checks if they're over the threshold.

Yeah that's pretty much what I did, I record the time they joined, or if they joined before me, the time I joined is set as their join time. And that time is their last talk time. Whenever they talk, their last talk time is to set the current time, I just use GetTickCount();. When IdleBan or IdleKick is set to on. I enable a timer with an interval of 10 seconds. And every 10 seconds it checks each user in the channel by doing


Result = GetTickCount(); - LastTalkTime[i];

if (Result >= 60000)
{
Send '/ban ' + Username
}


I hope that helps :|

If that doesn't make sense, I'll try again!

Networks

It's really simple:
- ID_USER (Store their idle time)
- ID_TALK, ID_EMOTE (Store their idle time)
- ID_JOIN (Store their idle time)
(Arrays are nice for this but I don't know enough C++ yet)

From that you can simply use a timer to check how long a user has been idle or as iago said you check on each event but I prefer timers because it's more accurate in my opinion.

NOTE: It's not a good idea to store idle time during the time idleban is off because when turned on the bot will begin banning users instantaneously if it's on a timer.

Gettickcount() is nifty for this and you can simply subtract the current gettickcount return from a person's stored idletime and ban/kick them.

The interval for your timing is what ever you should feel it should be. 1 second or 10 seconds, whatever.

iago

I wouldn't use a timer for it, since you'd need a timer for each user, and that's quite a bit of overhead.  But that's just me.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Minux

Obviously people aren't understanding what I said.

Use a For loop and go through each user in the array for the user's last talk time and then compare it to the current time.....And ban each user that has been idle for the amount of time you think is good. I don't know where ANYBODY got the idea that I suggested to use a timer for each user...

Kp

The method used in ZeroBot records time of last activity.  Each time an event occurs, a counter is decremented.  When it hits zero, the person who was idle the longest is kicked/banned.  This has the rather nice side effect that the bot doesn't spam up an otherwise quiet channel by kicking out idle people.  Once activity picks up, the counter starts moving again and the idlers don't have long to stay.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

LivedKrad

Quote from: Mephisto on October 22, 2004, 04:42 PM
Minus, if you could share your implementation (explain how you do it) I'd appreciate it.  LivedKrad, not entirely sure what you mean, but I'm in a hurry to get out of the house so I'll analyze it better when I get back.  Thanks for sharing :)

The idea I was trying to convey was this:

Let's say you have a time span of 10 seconds, if 5 users joined during these 10 seconds you could create an array and add all 5 of these users into the array. The array would have the unique value of these users joining at different intervals. And then, every 10 or 20 seconds, just check the specific array for unique join/idle time. While this poses a problem for second to second accuracy, it reduces overhead with minimal timers.

iago

Actually, I like Kp's idea -- using a shared counter sounds a lot more slick.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Mephisto

#12
Quote from: iago on October 22, 2004, 05:52 PM
The idea behind vL's is that each event that occurs takes them one step closer to the limit.  You need to keep track of how many events have occurred since the last time they've been active (I'd imagine you'd have a list or vector or whatever of users in the channel who are vulnerable to it, and each of them would have a count associated with them).  When the key event occurs to put them over the threshold, they're kicked or banned.

The other option is to use timing, just store the last time they talked, and every time they talk the time is reset, and when an event occurs it checks if they're over the threshold.

The timing was what I was thinking, but that's not accurate in all honesty.  Because you're banning them once they go over the timer limit when an event occurs.  An event may not occur for hours after they go over the time limit.  And also, what happens if they're the ones who issue the event after the timer expires?  Reset their time like you would by default or ban them?  It would seem odd to ban someone for being idle the second they send a message... :-\

The only way I see to implement idleban/kick with timers is to create a timer for each user that increments second by second either asynchronously or in another thread.  If a user issues an event, restart the timer.  If the timer expires (idealy we use SetTimer()) it sends a message to the main thread that the timer for that user has expired and to ban himf or being idle if he is not safelisted/friendslisted and idleban/kick is on.

iago

If no events are occuring, then who cares?
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


Stealth

QuoteThe idea behind vL's is that each event that occurs takes them one step closer to the limit.  You need to keep track of how many events have occurred since the last time they've been active (I'd imagine you'd have a list or vector or whatever of users in the channel who are vulnerable to it, and each of them would have a count associated with them).  When the key event occurs to put them over the threshold, they're kicked or banned.

iago and Kp make a lot of sense. Here's one way you could do it.

1. Assign each event that occurs an ID, sequentially. Store the current event ID globally.
2. When a user produces an event, record that event's ID in connection with their username.

globalLastEventID++
thisUser.lastEventID = globalLastEventID


3. Check after each event, or every few events, for people who have been idle for quite some time. To find out how many events have passed since the user last contributed to the channel, you can simply take

globalLastEventID - thisUser.lastEventID

for each user to determine which is most idle, or you can simply queue up bans for all users above a certain threshhold.
- Stealth
Author of StealthBot