PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: BlazeXxX on 31 October, 2003, 03:18:41

Title: Seen Bot
Post by: BlazeXxX on 31 October, 2003, 03:18:41
No Idea who wrote this one, so credit goes to the real owner of this script :)

-- Start Copying from this line
BotName = "LeonBot"

SeenTrigger = "!seen"



minLen = 4

maxLen = 20

seenArray={}



function Main()

frmHub:RegBot(BotName)

end



function NewUserConnected(curUser)

local boolDisc = 0

if strlen(curUser.sName) < minLen then

curUser:SendPM(BotName, "Your nick is to short, a minimum of "..minLen.." chars is required!")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

elseif strlen(curUser.sName) > maxLen then

curUser:SendPM(BotName, "Your nick is to long, a maximum of "..maxLen.." chars is required!")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

elseif ( strfind (curUser.sName, " ", 1, 1) ) then

curUser:SendPM(BotName, "Spaces not allowed in nicknames!")

curUser:SendPM(BotName, "Disconnecting...")

curUser:Disconnect()

boolDisc = 1

end

if (boolDisc == 0) then

seenArray[curUser.sName]=date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")

end

end



function OpConnected(curUser)

seenArray[curUser.sName]=date(curUser.sName.." connected at %d/%m/%Y %T and is still here.")

end



function OpDisconnected(curUser)

seenArray[curUser.sName]=date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")

end



function UserDisconnected(curUser)

seenArray[curUser.sName]=date(curUser.sName.." disconnected at %d/%m/%Y %T and has not been seen since.")

end



function DataArrival(curUser, data)

seenArray[curUser.sName]=date(curUser.sName.." was last seen at %d/%m/%Y %T writing things.")

if( strsub(data, 1, 1) == "<" ) then

data=strsub(data,1,strlen(data)-1)

_,_,cmd,arg = strfind( data, "%b<>%s+(%S+)%s+(%S+)" )

if (cmd == SeenTrigger) then

if (arg == curUser.sName) then

SendToAll(BotName, "You should not do #seen's for yourself ;)" )

elseif (seenArray[arg] ~= nil) then

SendToAll(BotName, "User: "..seenArray[arg] )

else

SendToAll(BotName, "I have not seen "..arg.."!" )

end

end

end

end

-- Finish Copying
Title:
Post by: spurlos on 23 November, 2003, 13:35:38
I like this idea.. But can ? make it with DB in txt file.. Becouse server restarting some time..