PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Doobert on 15 May, 2005, 18:04:56

Title: Reg to stay Bot
Post by: Doobert on 15 May, 2005, 18:04:56
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
Title:
Post by: Dessamator on 15 May, 2005, 19:17:23
-- 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] user:SendPM(bot,"Please register by using !regme or after 3 warns u will get kicked  this is ur "..warns[user.sName].." warning!")
else
user:SendPM(bot,"You were warned and now ur temporarily banned for not registering!")
user:TempBan()
kicks[user.sName]=1
end
end
end


Done !
Title:
Post by: Doobert on 15 May, 2005, 20:14:54
thanks mate ill try it later youre a star:)))
Title:
Post by: Dessamator on 15 May, 2005, 20:39:10
ur welcome !
Title:
Post by: Doobert on 15 May, 2005, 22:18:32
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:))))
Title:
Post by: catwo on 16 May, 2005, 08:12:18
?(  it banned everyone in my hub including me and OPs?
Title:
Post by: Doobert on 16 May, 2005, 08:20:42
Its still working ok for me. What hubsoft are you using? any other scripts running?
Title:
Post by: Dessamator on 16 May, 2005, 11:52:14
doobert ur request has been added, :)
Title:
Post by: Dessamator on 16 May, 2005, 14:02:16
-- 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

Title:
Post by: Doobert on 16 May, 2005, 14:37:45
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:)
Title:
Post by: Dessamator on 16 May, 2005, 15:42:40
ur welcome :)
Title:
Post by: Doobert on 16 May, 2005, 23:51:13
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.
Title:
Post by: Dessamator on 17 May, 2005, 00:14:53
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,  ;)
Title:
Post by: Doobert on 17 May, 2005, 00:30:57
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:)
Title:
Post by: Dessamator on 17 May, 2005, 00:40:03
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, :)
Title:
Post by: Doobert on 17 May, 2005, 09:28:00
I am willing to learn but it all looks like a foreign language to me. :D
Title:
Post by: Dessamator on 17 May, 2005, 10:14:15
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, :)
Title:
Post by: Yorkieland on 22 July, 2005, 20:29:41
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