Created
September 14, 2011 06:22
-
-
Save norganna/1215971 to your computer and use it in GitHub Desktop.
Spamkick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Copyright 2011, Norganna's AddOns Pty Ltd. All rights reserved. | |
-- Made by Worfox, modified by kevinsweijen. | |
local lib = register("spamkick") | |
local spamdata = {} | |
lib:hook("loggedin", nil, function (perform) | |
local player = lib.detail.username | |
spamdata['t' .. player] = os.clock() | |
spamdata['c' .. player] = 0 | |
end) | |
lib:hook("loggedout", nil, function (perform) | |
local player = lib.detail.username | |
spamdata['t' .. player] = nil | |
spamdata['c' .. player] = nil | |
end) | |
lib:hook("messaged", nil, function (perform) | |
local player = lib.detail.username | |
local now = os.clock() | |
local last = spamdata['t' .. player] or 0 | |
local count = spamdata['c' .. player] or 0 | |
local elapsed = now - last | |
if last > 0 then | |
if elapsed < 2 then | |
if count > 10 then | |
perform('adminmessage', 'Auto-kicking ' + player + ' for spamming') | |
perform('kickplayer', player) | |
return | |
elseif count == 7 then | |
perform('playermessage', 'Approaching spam threshold') | |
end | |
else | |
count = count - elapsed * 2 | |
if (count < 0) then | |
count = 0 | |
end | |
end | |
end | |
spamdata['t' .. player] = now | |
spamdata['c' .. player] = count + 1 | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment