PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: lazyj189 on 22 November, 2003, 17:58:56

Title: repeat 3x and get kicked.
Post by: lazyj189 on 22 November, 2003, 17:58:56
How about a bot that kicks a user for repeating what they say 3 times.

after they repeat 2 times they get a warning in main chat or in pm, wherever they are repeating themselves.

blah
blah
if you repeat yourself 1 more time I will have to kick you.
blah
bot is kicking Blah because they flooded the chat
User Blah was kicked.  IP: xx.xx.xx.xx

Title:
Post by: BlazeXxX on 23 November, 2003, 03:38:05
I remember someone did something like this b4.. lets see if someone posts it for us :)
Title:
Post by: plop on 23 November, 2003, 06:30:02
QuoteOriginally posted by lazyj189
How about a bot that kicks a user for repeating what they say 3 times.

after they repeat 2 times they get a warning in main chat or in pm, wherever they are repeating themselves.

blah
blah
if you repeat yourself 1 more time I will have to kick you.
blah
bot is kicking Blah because they flooded the chat
User Blah was kicked.  IP: xx.xx.xx.xx


so if user "testuser" says something 3x you want 2 kick user "blah".  lol
naaaaaa  i get the idea.
bit busy @ the moment so hope some1 else has it or can make it.
shouldn't be 2 hard 2 make.

plop
Title:
Post by: lazyj189 on 24 November, 2003, 06:11:17
ya I know it "shouldn't" be too hard to make, so we'll see.
Title:
Post by: tezlo on 24 November, 2003, 11:41:08
max = 3
table = {}

warnmsg = "dont flood"
kickmsg = "flooding"

function DataArrival(user, data)
if strsub(data, 1, 1) == "<" then
local s, e, str = strfind(data, "^%b<> (.*)|$")
return check(user, str)
end
end

function check(user, str)
local tmp, ret = table[user.sName] or {}
if tmp[1] ~= str then
tmp = { str, 1 }
else
tmp[2] = tmp[2] + 1
if tmp[2] == max - 1 then
user:SendData("Hub-Security", warnmsg)
elseif tmp[2] == max then
user:Kick(kickmsg)
tmp, ret = nil, 1
end
end table[user.sName] = tmp
return ret
end
Title:
Post by: BlazeXxX on 24 November, 2003, 12:19:33
Thx tezlo .. the man :p Would it work with IceCube IV ?
Title:
Post by: marci_n on 01 January, 2004, 19:57:23
but the kick all. Ops too :(
Title:
Post by: NightLitch on 01 January, 2004, 20:57:12
Here try this little update:

max = 3
table = {}

warnmsg = "dont flood"
kickmsg = "flooding"

function DataArrival(user, data)
if strsub(data, 1, 1) == "<" and not user.bOperator then
local s, e, str = strfind(data, "^%b<> (.*)|$")
return check(user, str)
end
end

function check(user, str)
local tmp, ret = table[user.sName] or {}
if tmp[1] ~= str then
tmp = { str, 1 }
else
tmp[2] = tmp[2] + 1
if tmp[2] == max - 1 then
user:SendData("Hub-Security", warnmsg)
elseif tmp[2] == max then
user:Kick(kickmsg)
tmp, ret = nil, 1
end
end table[user.sName] = tmp
return ret
end

Great piece Tezlo...

And it Works just tested...
Title:
Post by: NightLitch on 01 January, 2004, 21:04:04
Could you make it even if messages come like this:

hey
hey hey hey hey  ( But Here it is sended 4 times...)
hey
------------------------
kicked normally x3

Hope you get my point...

Everybody have new good year...
Title:
Post by: marci_n on 01 January, 2004, 23:51:11
BIG thx NightLitch :D