delayed kick script
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

delayed kick script

Started by pis, 05 April, 2005, 06:33:29

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pis

Good morning all,

Sorry if this is wrong dir.

I wonder if there a script in LUA 5 out there I can use.

I'm running a Hub for registred only and I wonder if there is a script out there that does a delayed kick on a specific username upon login? Maybe after x amount of seconds and also with the possibility to add the reason for the kick.

Many thanks for feed-back.

Have a good day!

raz

lol it will be a normal kick script, for example say you have him kicked in entry of the hub for his name, jus your have 2 add a timer in and it should work perfectly. lol

i would make 1, if i knew how 2. lol i fink i should learn tho. lol any1 up 4 teaching me. lol  :D

pis

Quotelol it will be a normal kick script, for example say you have him kicked in entry of the hub for his name, jus your have 2 add a timer in and it should work perfectly. lol

Great, I've seen the light.

Quotei would make 1, if i knew how 2. lol i fink i should learn tho. lol any1 up 4 teaching me. lol :D

Right, well good luck to you man.

Dessamator

#3
-- Reg User Checker/banner
-- By Dessamator
-- kick delay function by nerbos

sec = 1 
min = 60*sec 
iDelay = 60*sec -- Time of delay before ban the user 
iBan = 5 -- Time of Ban in Minutes 

arrDelay = {} 
-- Activated on startup/then script is started
botname=frmHub:GetHubBotName() 
function Main()
StartTimer()
frmHub:RegBot(botname) 
end

-- called as often as the timer interval is set to
function OnTimer() 
local now,nick,time = os.clock() 
	for nick, time in arrDelay do 
		if (now >= time+iDelay) then 
			if (GetItemByName(nick) ~= nil) then 
GetItemByName(nick):SendPM(botname, "Regged Users only")
GetItemByName(nick):TimeBan(iBan) 
			end 
arrDelay[nick] = nil 
		end 
	end 
end 
function UserDisconnected(curUser) 
arrDelay[curUser.sName] = nil 
end 

-- new user connects

function NewUserConnected(User,sdata)
	if not(User.bRegistered) then
		arrDelay[User.sName] = os.clock()
		User:SendPM(botname, "Regged Users only, pls register using !regme or you will b kicked in "..iBan.." minutes")

	end
end

Done!!
Ignorance is Bliss.

pis

Thanks but from what I can see this is a script that kicks unreg users. What I'm after is a script that kicks a specifik username, reged or unreged, maybe a minute after they have logged on to the hub, together with a kick reason. Kind of like an offline message only with a inbuilt kick. Thanks again though for the feed back.

jiten

QuoteOriginally posted by pis
Thanks but from what I can see this is a script that kicks unreg users. What I'm after is a script that kicks a specifik username, reged or unreged, maybe a minute after they have logged on to the hub, together with a kick reason. Kind of like an offline message only with a inbuilt kick. Thanks again though for the feed back.

From what I understood, u want a script that allows u to kick a certain user with a reason (it doesn't matter if he's REG or not) and when he logs in he's able to see the kick reason and remain in the hub for a minute and then he's kicked?

Dessamator

#6
  
  
-- Tagged User checker/banner
-- By Dessamator
-- kick delay function by nerbos

sec = 1 
min = 60*sec 
iDelay = 60*sec -- Time of delay before ban the user 
iBan = 5 -- Time of Ban in Minutes 

arrDelay = {} 

tag ={}
fTag = "ftag.dat"
botname=frmHub:GetHubBotName() 

-- Activated on startup/then script is started
function Main()
LoadFromFile(fTag)
StartTimer()
frmHub:RegBot(botname) 
end

-- called as often as the timer interval is set to
function OnTimer() 
	local now,nick,time = os.clock() 
	for nick, time in arrDelay do 
		if (now >= time+iDelay) then 
			if (GetItemByName(nick) ~= nil) then 
				GetItemByName(nick):SendPM(botname, "Cya !!")
				GetItemByName(nick):TimeBan(iBan) 
			end 
arrDelay[nick] = nil 
		end 
	end

end 
function UserDisconnected(curUser) 
arrDelay[curUser.sName] = nil 
end 

-- Incoming chat message from user. If script return 1 hub don't process data.
function ChatArrival(curUser,sdata)
sdata = string.sub(sdata,1,string.len(sdata)-1) 
s,e,cmd = string.find(sdata, "%b<>%s+(%S+)") 
	if	cmd=="!tag" then
		addtag(curUser,sdata)
	return 1
	elseif
		cmd=="!showtag" then
		showtag(curUser,sdata)
	return 1
	elseif cmd=="!remtag" then
		remtag(curUser,sdata)
	return 1
	end
end

function NewUserConnected(User,sdata)
	if tag[(User.sName)] then
		arrDelay[User.sName] = os.clock()
		User:SendPM(botname, "u have been tagged and will be disconnected in "..iBan.." min")
	end
end

function addtag(curUser,sdata)
local s,e,nick = string.find(sdata, "%b<>%s+%S+%s+(.+)")
	if (tag[(nick)]==nil) then
		tag[(nick)] = 1 
		curUser:SendData(botname, "The user has been tagged")
	else
		curUser:SendData(botname, "User is already tagged")
	end
end

function showtag(curUser,sdata)
local temp,pos,table = "These are Tagged Users:".."\r\n"
	for pos,table in tag do
		temp=temp.."\t"..pos.."\r\n"
	end
		curUser:SendPM(botname,temp)
end

function remtag(curUser,sdata)
local s,e,nick = string.find(sdata, "%b<>%s+%S+%s+(.+)")
	if (tag[(nick)]==1) then
		tag[(nick)] = nil
		curUser:SendData(botname, "The user has been untagged")
	else
		curUser:SendData(botname, "That user isnt already tagged")
	end
end

function Serialize(tTable, sTableName, sTab)
        assert(tTable, "tTable equals nil");
        assert(sTableName, "sTableName equals nil");

        assert(type(tTable) == "table", "tTable must be a table!");
        assert(type(sTableName) == "string", "sTableName must be a string!");

        sTab = sTab or "";
        sTmp = ""

        sTmp = sTmp..sTab..sTableName.." = {\n"

        for key, value in tTable do
                local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);

                if(type(value) == "table") then
                        sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
                else
                        local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
                        sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
                end

                sTmp = sTmp..",\n"
        end

        sTmp = sTmp..sTab.."}"
        return sTmp
end

function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end

function LoadFromFile(file)
local handle = io.open(file,"r")
        if (handle ~= nil) then
                dofile(file)
handle:flush()
handle:close()
        end

end

function OnExit()
SaveToFile(fTag, tag, "tag")
end


Done !!!
Ignorance is Bliss.

jiten

Well, came a little late but, here is mine  :D :

-- Requested by pis
-- Modded by jiten from:
-- nErBos kick script converted to LUA5 by bolamix with help from Pothead March 2/3, 2005
-- Reg User Checker/banner by Dessamator (kick delay function by nerbos)

Bot = frmHub:GetHubBotName()

sec = 1 
min = 60*sec 
iDelay = 60*sec -- Time of delay before ban the user 
iBan = 5 -- Time of Ban in Minutes 

arrDelay = {} 
kicked = {}

function Main()
	StartTimer()
	frmHub:RegBot(Bot) 
end

function UserDisconnected(user) 
	arrDelay[user.sName] = nil 
end 

-- called as often as the timer interval is set to
function OnTimer() 
	local now,nick,time = os.clock() 
	for nick, time in arrDelay do 
		if (now >= time+iDelay) then 
			if (GetItemByName(nick) ~= nil) then 
				GetItemByName(nick):SendData(Bot, "You've been time kicked!")
				GetItemByName(nick):TimeBan(iBan)
			end 
			arrDelay[nick] = nil 
		end 
	end 
end 

function ChatArrival(user, data)
	s,e,cmd = string.find(data,"%b<>%s+(%S+)")
	if (cmd=="!tkick") then
		if (user.bOperator) then
			local s,e,usr,reason = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
			if (usr == nil or reason == nil) then
				user:SendData(Bot, "*** Error: Type !tkick nickname reason")
			else
				if (GetItemByName(usr) == nil) then
					user:SendData(Bot, "The user "..usr.." is not online.")
				else
					local userToBeKicked = GetItemByName(usr)
					if not userToBeKicked.bOperator then
						--SendToAll(Bot, userToBeKicked.sName.." has been kicked by "..user.sName.." because : "..reason)
						userToBeKicked:SendPM(Bot, "You are going to be kicked in "..iDelay.." seconds by "..user.sName.." because: "..reason)
						if (kicked[userToBeKicked.sName] == nil) then
							kicked[userToBeKicked.sName] = 1
						else
							kicked[userToBeKicked.sName] = kicked[userToBeKicked.sName] + 1
						end
						user:SendData(Bot, userToBeKicked.sName.." will be kicked in "..iDelay.." seconds because: "..reason.."")
						arrDelay[userToBeKicked.sName] = os.clock()
						--userToBeKicked:Disconnect()
					else
						userToBeKicked:SendPM(Bot, user.sName.." tried to kick you.")
						user:SendPM(Bot, userToBeKicked.sName.." is gonna kick your arse.")
					end
				end
			end
		else
			user:SendData(Bot, "*** Error: You don?t have permission to use this command.")
		end
		return 1
	end
end


Cheers

pis

ooops... sorry for not saying thanks. totaly forgot about this request of mine. many thanks to both of you. it was just what i was looking for.

many thanks again!

jiten


Stravides

One step further...

Using this -->
-- Requested by pis
-- Modded by jiten from:
-- nErBos kick script converted to LUA5 by bolamix with help from Pothead March 2/3, 2005
-- Reg User Checker/banner by Dessamator (kick delay function by nerbos)

Bot = "george"
sec = 1 
min = 60*sec 
iDelay = 10*min -- Time of delay before ban the user 
iBan = 25 -- Time of Ban in Minutes 

arrDelay = {} 
kicked = {}

function Main()
	StartTimer()
	frmHub:RegBot(Bot) 
end

function UserDisconnected(user) 
	arrDelay[user.sName] = nil 
end 

-- called as often as the timer interval is set to
function OnTimer() 
	local now,nick,time = os.clock() 
	for nick, time in arrDelay do 
		if (now >= time+iDelay) then 
			if (GetItemByName(nick) ~= nil) then 
				GetItemByName(nick):SendData(Bot, "You've been time kicked!")
				GetItemByName(nick):TimeBan(iBan)
			end 
			arrDelay[nick] = nil 
		end 
	end 
end 

function ChatArrival(user, data)
	s,e,cmd = string.find(data,"%b<>%s+(%S+)")
	if (cmd=="!tkick") then
		if (user.bOperator) then
			local s,e,usr,reason = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
			if (usr == nil or reason == nil) then
				user:SendData(Bot, "*** Error: Type !tkick nickname reason")
			else
				if (GetItemByName(usr) == nil) then
					user:SendData(Bot, "The user "..usr.." is not online.")
				else
					local userToBeKicked = GetItemByName(usr)
					if not userToBeKicked.bOperator then
						--SendToAll(Bot, userToBeKicked.sName.." has been kicked by "..user.sName.." because : "..reason)
						userToBeKicked:SendPM(Bot, "You are going to be kicked in "..iDelay.." seconds by "..user.sName.." because: "..reason)
						if (kicked[userToBeKicked.sName] == nil) then
							kicked[userToBeKicked.sName] = 1
						else
							kicked[userToBeKicked.sName] = kicked[userToBeKicked.sName] + 1
						end
						user:SendData(Bot, userToBeKicked.sName.." will be kicked in "..iDelay.." seconds because: "..reason.."")
						arrDelay[userToBeKicked.sName] = os.clock()
						--userToBeKicked:Disconnect()
					else
						userToBeKicked:SendPM(Bot, user.sName.." tried to kick you.")
						user:SendPM(Bot, userToBeKicked.sName.." is gonna kick your arse.")
					end
				end
			end
		else
			user:SendData(Bot, "*** Error: You don?t have permission to use this command.")
		end
		return 1
	end
end

How do I go about adding the REMOVE User from this..

reason I want it is to warn a user - if they dont reply to me it kicks them...
if they reply i can issue a command
!remtkick username and it removes them from this ...

many thanks in advance
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

Dessamator

   
How do I go about adding the REMOVE User from this.. 

reason I want it is to warn a user - if they dont reply to me it kicks them... 
if they reply i can issue a command 
!remtkick username and it removes them from this ... 

many thanks in advance


well its simple and since u want to learn how to script, just look at the ontimer event, it already does that !!!
Ignorance is Bliss.

jiten

#12
Well, try this one:

-- Requested by pis
-- Modded by jiten from:
-- nErBos kick script converted to LUA5 by bolamix with help from Pothead March 2/3, 2005
-- Reg User Checker/banner by Dessamator (kick delay function by nerbos)
-- Added option to remove a user from the delayed kick list

Bot = "george"
sec = 1 
min = 60*sec 
iDelay = 15*sec -- Time of delay before ban the user 
iBan = 25 -- Time of Ban in Minutes 

arrDelay = {} 
kicked = {}

function Main()
	frmHub:RegBot(Bot)
	StartTimer()
end

function UserDisconnected(user) 
	arrDelay[user.sName] = nil 
end 

-- called as often as the timer interval is set to
function OnTimer() 
	local now,nick,time = os.clock() 
	for nick, time in arrDelay do 
		if (kicked[GetItemByName(nick).sName] == 1) then
			if (now >= time+iDelay) then 
				if (GetItemByName(nick) ~= nil) then 
					GetItemByName(nick):SendData(Bot, "You've been time kicked!")
					GetItemByName(nick):TimeBan(iBan)
				end 
				arrDelay[nick] = nil 
			end 
		else
		end
	end 
end 

function ChatArrival(user, data)
	data=string.sub(data,1,string.len(data)-1) 
	s,e,cmd = string.find(data,"%b<>%s+(%S+)")
	if (cmd=="!tkick") then
		if (user.bOperator) then
			local s,e,usr,reason = string.find(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")
			if (usr == nil or reason == nil) then
				user:SendData(Bot, "*** Error: Type !tkick nickname reason")
			else
				if (GetItemByName(usr) == nil) then
					user:SendData(Bot, "The user "..usr.." is not online.")
				else
					local userToBeKicked = GetItemByName(usr)
					if not userToBeKicked.bOperator then
						--SendToAll(Bot, userToBeKicked.sName.." has been kicked by "..user.sName.." because : "..reason)
						userToBeKicked:SendPM(Bot, "You are going to be kicked in "..iDelay.." seconds by "..user.sName.." because: "..reason)
						if (kicked[userToBeKicked.sName] == nil) then
							kicked[userToBeKicked.sName] = 1
						else
							kicked[userToBeKicked.sName] = kicked[userToBeKicked.sName] + 1
						end
						user:SendData(Bot, userToBeKicked.sName.." will be kicked in "..iDelay.." seconds because: "..reason.."")
						arrDelay[userToBeKicked.sName] = os.clock()
					else
						userToBeKicked:SendPM(Bot, user.sName.." tried to kick you.")
						user:SendPM(Bot, userToBeKicked.sName.." is gonna kick your arse.")
					end
				end
			end
		else
			user:SendData(Bot, "*** Error: You don?t have permission to use this command.")
		end
		return 1
	elseif (cmd=="!remtkick") then
		if (user.bOperator) then
			s,e,usr = string.find( data, "%b<>%s+%S+%s+(%S+)" ) 
			if (usr == nil) then
				user:SendData(Bot, "*** Error: Type !remtkick nickname")
			else
				if (GetItemByName(usr) == nil) then
					user:SendData(Bot, "The user "..usr.." is not online.")
				else
					local userToBeKicked = GetItemByName(usr)
					if not userToBeKicked.bOperator then
						userToBeKicked:SendPM(Bot, "Your timed kick was removed by "..user.sName)
						if (kicked[userToBeKicked.sName] == 1) then
							kicked[userToBeKicked.sName] = nil
							arrDelay[userToBeKicked.sName] = nil
						end
						user:SendData(Bot, userToBeKicked.sName.."'s timed kick was removed.")
					else
					end
				end
			end
		else
			user:SendData(Bot, "*** Error: You don?t have permission to use this command.")
		end
		return 1
	end
end
Best regards,

jiten

Stravides

Excellent - thats nearly there :)
I have amalgamated it into my code (only name of bot changed)... I get this in main chat

[22:57:56]  Sssneakssys little sloopy wasss **Warned** By OP: Stravides Becaussse: 05. Sharing Installed Games, Installed Programs or Incomplete Files (Partial Downloads and Temporary Files) 
[22:57:56]  sloopy will be kicked in 10 Minutes because: 05. Sharing Installed Games, Installed Programs or Incomplete Files (Partial Downloads and Temporary Files) 
[22:58:06]  sloopy's timed kick was removed.
[23:00:39]  Sssneakssys little sloopy Has Been Time Kicked!!!

elseif (cmd=="!remtkick") then
		if (user.bOperator) then
			s,e,usr = string.find( data, "%b<>%s+%S+%s+(%S+)" ) 
			if (usr == nil) then
				user:SendData(Bot, "*** Error: Type !remtkick nickname")
			else
				if (GetItemByName(usr) == nil) then
					user:SendData(Bot, "The user "..usr.." is not online.")
				else
					local userToBeKicked = GetItemByName(usr)
					if not userToBeKicked.bOperator then
						userToBeKicked:SendPM(Bot, "Your timed kick was removed by "..user.sName)
						if (kicked[userToBeKicked.sName] == 1) then
							kicked[userToBeKicked.sName] = nil
		arrDelay[userToBeKicked.sName] = nil
		end
						user:SendData(Bot, userToBeKicked.sName.."'s timed kick was removed.")
					else
					end
				end
			end
		else
			user:SendData(Bot, "*** Error: You don?t have permission to use this command.")
		end
		return 1
	end


its missing the arrDelay[userToBeKicked.sName] = nil
see above :)
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

Herodes

#14
There is a lil smth that is a very efficient way to track changes in a table ...
The whole Book is a must have anyhow..
I believe new scripters and old ones alike have things to benefit from inside there ..

Programming In Lua 13.4.4 - Tracking Table Accesses

jiten

QuoteOriginally posted by Stravides
its missing the arrDelay[userToBeKicked.sName] = nil
see above :)

Yups  :D
Related post updated.

Cheers

Stravides

Thanks - you had 99.9% of it - I just realised part way thru my message that it was not removing from both arrays / tables...

always appreciate yer help here chaps...
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

jiten


FrancoS

#18
Hi guys, your scripts are close to what I need,

let say I simply need to delay ANY kind of user kick/disconnect.

Why?

'Cause the kick/disconnect explanation messages are not reaching those users. Seems that the disconnection happen before the message arrives to the user to be disconnected.

And... could seem stupid as request... but:

which is the correct way to send a user a message that goes to the main chat, but only to his[/u] main chat?

........

Now: if you add the two requests, you may understand which is my issue and need:

send an explanation to users to be disconnected and be sure that this message arrives... and because you can configure dc++ in such a way that PM from offline users (BOTs) are bounced... I need the message to be sent on that user main chat...

Last (but sorry, off topic) my hub is DC++ only. Which is the best solution to try to ensure that connecting clients are really DC++ and not fakes? If any...

Thank you in advance for any tip and suggestion and or solution.

Robert

SMF spam blocked by CleanTalk