Reg to stay Bot
 

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

Reg to stay Bot

Started by Doobert, 15 May, 2005, 18:04:56

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Doobert

i am looking for a stand alone script which would give an unregistered user a certain amount of time to register.
It wuld warn them at intervals that they need to register.
If they dont it would then kick them with a tempban.
I have searched but cannot find what I am looking for and I am a bit of a nerd when it comes to things like this.
any help or pointers would be much appreciated.
thanks

Dessamator

#1
-- By Dessamator
-- Simple Regme bot with warning timer
-- added logs(request by doobert)
warns={}
kicks={}
sec=1000
min=sec*60
hour=min*60

--config--
bot = frmHub:GetHubBotName() 	-- bot name
maxwarns =3			-- max number of warns b4 kick
iwarn = 1*sec			-- time to wait before warning
--

function Main()
SetTimer(iwarn)
StartTimer()
end

function ChatArrival(user,data)
local temp="\r\n\t\These are the UnRegged users Logs:\r\n"
	data=string.sub(data,1,-2)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)") 
	if cmd =="!reglogs" then
		for usr,pos in warns do
			temp=temp.."\t\t\User :"..usr.."\r\n"
			temp=temp.."\t\t\Warns :"..pos.."\r\n"
		end
		for usr,pos in kicks do
			temp=temp.."\t\t\Kicks :"..pos.."\r\n"	
		end
	end
	user:SendData(bot,temp)
end


function OnTimer()
	for pos,user in frmHub:GetOnlineUsers(-1) do
		if warns[user.sName]==nil then 
			warns[user.sName]=1
		else
			warns[user.sName]=warns[user.sName]+1
		end
		if warns[user.sName]


Done !
Ignorance is Bliss.

Doobert

thanks mate ill try it later youre a star:)))

Dessamator

Ignorance is Bliss.

Doobert

#4
so far so good its sending out the warnings :D
I have my hub set so unregistered users cant search, download or chat except with Ops so Im a little puzzled as to what they are doing when they dont bother:))))

catwo

?(  it banned everyone in my hub including me and OPs?

Doobert

Its still working ok for me. What hubsoft are you using? any other scripts running?

Dessamator

doobert ur request has been added, :)
Ignorance is Bliss.

Dessamator

#8
-- By Dessamator
-- Simple Regme bot with warning timer
-- added Doobert Request

RegLogs={}
sec=1000
min=sec*60
hour=min*60
fUnreg="Unregged.log"

--config--
bot = frmHub:GetHubBotName() 	-- bot name
maxwarns =3			-- max number of warns b4 kick
iwarn = 1*hour			-- time to wait before warning
--

function Main()
	SetTimer(iwarn)
	StartTimer()
local handle = io.open(fUnreg,"r")
       if (handle ~= nil) then
                dofile(fUnreg)
handle:flush()
handle:close()
        end
end

function ChatArrival(user,data)
local temp="These are the UnRegged users Logs\r\n"
	data=string.sub(data,1,-2)
	s,e,cmd = string.find(data, "%b<>%s+(%S+)") 
	if cmd =="!reglogs" and user.bOperator then
		for usr,pos in RegLogs do
			temp=temp.."User :"..usr.."\r\n"
			if pos.warns then
			        temp=temp.."Warns :"..pos.warns.."\r\n"
			end
			if pos.kicks then
			        temp=temp.."Kicks :"..pos.kicks.."\r\n"
			end
		end
		user:SendPM(bot,temp)
                  return 1
	end
end


function OnTimer()
	for pos,user in frmHub:GetOnlineUsers(-1) do	
		if not (type(RegLogs[user.sName])=="table") then
			RegLogs[user.sName] ={}
		end
		if user then
			if not(RegLogs[user.sName]["warns"]) then 
				RegLogs[user.sName]["warns"]=1
				user:SendPM(bot,"Please register by using !regme or after 3 warns u will get kicked  this is ur "..RegLogs[user.sName]["warns"].." warning!")
			elseif (RegLogs[user.sName]["warns"])==3 then
				RegLogs[user.sName]["kicks"]=1
				user:SendPM(bot,"You were warned and now ur temporarily banned for not registering!")
				user:TempBan()
				RegLogs[user.sName]["warns"]=nil
			else
				RegLogs[user.sName]["warns"]=RegLogs[user.sName]["warns"]+1
				user:SendPM(bot,"Please register by using !regme or after 3 warns u will get kicked  this is ur "..RegLogs[user.sName]["warns"].." warning!")
			end
		end	
		
 	end	
end

function OnExit()
local function SaveToFile(file , table , tablename)
	local handle = io.open(file,"w+")
        handle:write(Serialize(table, tablename))
	handle:flush()
        handle:close()
end
	SaveToFile(fUnreg , RegLogs , "RegLogs")
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

Ignorance is Bliss.

Doobert

Thanks mate youre a real star especially for people like me who are not scripting wizards.
Ill try it out tonight when I get home from work.
Thanks again:)

Dessamator

Ignorance is Bliss.

Doobert

Dessamator everything sems ok at the moment and its doing what i want. But could I just ask two final things.
as it stands can anyone use the !reglogs command and get the list as I would like it to be just Ops and is it easy to display the results as a PM in the bot rather than in main?
They are my very last 2 things and I will be eternally grateful. also I am sure other will find this script useful.

Dessamator

QuoteOriginally posted by Doobert
Dessamator everything sems ok at the moment and its doing what i want. But could I just ask two final things.
as it stands can anyone use the !reglogs command and get the list as I would like it to be just Ops and is it easy to display the results as a PM in the bot rather than in main?
They are my very last 2 things and I will be eternally grateful. also I am sure other will find this script useful.

Done, Post edited,  ;)
Ignorance is Bliss.

Doobert

mate what can i say?
You have made this hub owner happy even if the unregistered users wont be:)
I will leave you in peace now and once again I am really grateful.
I believe threre are those of us who can write the scripts and those of us who use them and I know what category I belong to:)

Dessamator

QuoteOriginally posted by Doobert
mate what can i say?
You have made this hub owner happy even if the unregistered users wont be:)
I will leave you in peace now and once again I am really grateful.
I believe threre are those of us who can write the scripts and those of us who use them and I know what category I belong to:)

hmm there are more categories, those who can write , those who use them, those that edit them, and those that are willing to learn to write and futhermore those who teach others , now from that which do u belong to ,

btw ur welcome, :)
Ignorance is Bliss.

Doobert

I am willing to learn but it all looks like a foreign language to me. :D

Dessamator

QuoteOriginally posted by Doobert
I am willing to learn but it all looks like a foreign language to me. :D

yap in the beggining it looks like that to every1(who doesnt have programming knowledge), but with time u'll learn, but its mostly in english, :)
Ignorance is Bliss.

Yorkieland

Hi
I've just tried out your script but i'm getting this error  

[19:22] Syntax [string "code:
..."]:9: function arguments expected near `='

Could you give ma any idea what the problem could be?

Cheers

p.s i'm running 0.3.3.1 debug

SMF spam blocked by CleanTalk