PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Requiem on 22 January, 2005, 09:45:34

Title: Clone User Manager
Post by: Requiem on 22 January, 2005, 09:45:34
Hi, I need a clone user manager which can kick clone users but have protected users (our ops enter the hub with another nick to share) and better than kicks = 2

function NewUserConnected(user)
local Connects={}
local Connected={}
TextLoad("Connected.dat",Connects)
for key, value in Connects do
if (value == "") then
local SaveCon={}
TextLoad("Connected.dat",SaveCon)
tinsert(SaveCon,user.sName.." "..user.sIP)
TextSave("Connected.dat",SaveCon)
--else
--POS1=strfind(strlower(value), " ",1,1)
--POS2=strfind(strlower(value), " ",POS1+1,strlen(value))
--Con=strsub(value,POS1+1)
end
if ( strfind(value, user.sIP,1,1) or strfind(value, user.sName,1,1) ) then
--user:SendPM("hmm","Only 1 user from the same IP allowed!")
user:Kick("Only 1 user from the same IP allowed!")
end
end
end


function UserDisconnected(user)
local Connects={}
TextLoad("Connected.dat",Connects)
TextSave("Connected.dat",RemoveUserFromArray(user.sName,Connects))
end


function TextLoad(FILE,ARRAY)
ARRAY[0], TEXT="" local X=0
readfrom(FILE)
repeat  
if (TEXT) then  
TEXT=TEXT..ARRAY[X].."\r\n"  
end  
X=X+1
ARRAY[X]=read()  
until (ARRAY[X]==nil)
readfrom()
end

function RemoveUserFromArray(USERNAME,ARRAY)
local X
local NEWARRAY={}
local POS1
--local POS2
for X=1,getn(ARRAY) do
POS1=strfind(ARRAY[X]," ",1,1)
--POS2=strfind(ARRAY[X]," ",POS1+1,-1)
if (not strfind(ARRAY[X],USERNAME,POS1) ) then
tinsert(NEWARRAY,ARRAY[X])
end
end
return NEWARRAY
end

function TextSave(FILE,ARRAY)
writeto(FILE)
for X=1,getn(ARRAY) do  write(ARRAY[X].."\n")  end
writeto()
end
because as far as I see (I tested it, I don't understand a bit of LUA :) ) this script doesn't (or can't) clear " Connected.dat " when user disconnects.

Thank you..
Title:
Post by: bastya_elvtars on 22 January, 2005, 13:39:38
http://www.plop.nl/ptokaxbots/Mutor.php
Title: protected users
Post by: Requiem on 22 January, 2005, 17:37:54
Thank you bastya_elvtars, you always run for my help but as I said, I need protected users to be defined not to be kicked by a clone kicker script.
Title:
Post by: BoJlk on 22 January, 2005, 19:19:04
i think he meant modifying the Clone Alert.
adding an option to add protected user,
meaning !addclone
adding it to list of user that allowed to be cloned.
Thats a great idea Requiem  :]
Title:
Post by: Requiem on 22 January, 2005, 20:48:11
If I understood you right, I need exactly this. If I couldn't  (and you meant the scripts by Mutor have already these) , I inspected them 2 times after I've read your post and couldn't find any commands. (I believe I understood you  :))  )
Title:
Post by: BoJlk on 22 January, 2005, 21:14:25
The Script:

--Clone Alert 1.0b
--by Mutor The Ugly
--PM Clone login to Opchat
--
--
OpChatName = frmHub:GetOpChatName() --Use this line for inbuilt Px opchat
--OpChatName = "opschat" --Use this line for a scripted opchat
Bot = "[Sentry]" --Rename to you main Px bot
PmOps = "1" --Should Ops be notified 1=yes 0=no
 
function Main()
frmHub:EnableFullData(1)
end

function DataArrival(curUser,sdata)
local _,_, user1 = strfind(sdata,"$GetINFO%s+(%S+)%s+")
if user1 ~= curUser.sName then
Nick = GetItemByName(user1)
if Nick ~= nil then
if Nick.sIP == curUser.sIP    then
curUser:SendPM(Bot,"This hub does not allow the use of clones. Hit the bricks, ya leecher!")
curUser:Disconnect()
SendPmToNick(Nick.sName,Bot,"This hub does not allow the use of clones. Hit the bricks, ya leecher!")
user1:Disconnect()
-- if PMOps == "1" then
-- SendPmToOps(OpChatName, "*** Cloned user = "..curUser.sName.." logged in, Nick is a clone of = "..Nick.sName)
-- SendPmToOps(OpChatName, "***"..curUser.sName.." and "..Nick.sName.." have been disconnected")
-- end
end
end
end
end

What i tried to say that i use this Scripts and i think it needs abit of modification:

1. adding Profile filter (display notice to who)
2. adding a list of Users to be ignored by the script (Cloning safe list)
3. Adding command for adding users (and defining Profile to use the Command)
Title:
Post by: Requiem on 22 January, 2005, 22:23:33
QuoteLastly, most scripters provide the information YOU need to create the function you want, after all THEY already know how to do it 8-)

You can be sure if I have known how to create the function I want, I wouldn't disturb you.. By the way, accessing my host is really hard for me. Can you add a command like " !addclone " for me ?

Thank you..

P.S. : You can pay a visit to my little hub, Uni?Turk (dchub://uniturk.no-ip.com:6226). This is a official invitation to every one here  ;)
Title:
Post by: BoJlk on 22 January, 2005, 23:01:30
QuoteMutor: most scripters provide the information YOU need to create the function you want
thank you for your time and the script modification, but i wouldn't like someone editing my scripts, i f would made one.
Title:
Post by: bastya_elvtars on 23 January, 2005, 00:01:26
QuoteOriginally posted by Requiem
If I understood you right, I need exactly this. If I couldn't  (and you meant the scripts by Mutor have already these) , I inspected them 2 times after I've read your post and couldn't find any commands. (I believe I understood you  :))  )

yep, sorry. i use that script in lawmaker with the function requested by u, just forgot that i added that code myself without using Mutor's one. (At home i had no net writing lawmaker.)
Title:
Post by: bastya_elvtars on 23 January, 2005, 02:43:48
lawmaker is closed source, but Copyware.

if you don't redisrtibute it in 30 days you have to remove it from your compie ;p

btw the reason its still closed src is that i cannot do web serving atm... :(
Title: First trouble is met
Post by: Requiem on 23 January, 2005, 07:41:10
The script works fine, thank you a million times for your help but yesterday I met the first trouble of it.. Some of the universities in our country uses virtual IP systems for the students staying in dorms and even though every client has a unique IP on LAN, they share a single IP on WAN. Is there any way to add some IP ranges to Allowed list? Or these IP ranges can be allowed if the exact share is not equal?
Title:
Post by: bastya_elvtars on 23 January, 2005, 13:24:00
mmm this is a very important thing and as i have to build a network of exactly the same architecture, i have to keep an eye on it.

The best is to have single IPs immuned.
Title:
Post by: bastya_elvtars on 23 January, 2005, 13:42:17
Edited to support single IP exclusion list. Hope its not erroneous, i am  out of practice.

--Clone Alert 1.0e
--by Mutor The Ugly
--
-- Disconnects clone users from hub
-- Provides option for protected nicks
-- Provides option to not check Ops
-- Provide option to report to OpChat
-- bastya_elvtars added IP immune list

--User Settings-------------------------------------------------------------------------------------
--OpChatName = "opschat" --Use this line for a scripted opchat
Bot = frmHub:GetHubBotName() -- Bot name pulled from hub
PmOps = "yes" --Should Ops be notified 'yes/no'
CheckOps = "yes" --Should Ops be checked 'yes/no'
--Note: If alternate nick from Op's IP is not listed in OkClones, Op will also be disconnected when alt nick logs in.
OkClones = {["Pheonix"]=1,["Rizzo"]=1,["Sol"]=1,["Kissel"]=1}
OkIPs={["160.114.118.106"]=1,["127.0.0.1"]=2,}

UserMsg2Send = "This hub does not allow the use of clones. Hit the bricks, ya leecher!"
--End User Settings----------------------------------------------------------------------------------


function Main()
frmHub:EnableFullData(1)
end


function DataArrival(user,sdata)
if CheckOps == "no" and user.bOperator then return 1 end
if not OkClones[user.sName] and not OkIPs[user.sIP] then
local _,_, user1 = strfind(sdata,"$GetINFO%s+(%S+)%s+")
if user1 ~= user.sName then
Nick = GetItemByName(user1)
if Nick ~= nil then
local OpMsg
OpMsg = "\r\n\r\n*** Cloned user = "..user.sName.." logged in, "..user.sName.." is a clone of = "..Nick.sName.."\r\n"
OpMsg = OpMsg.."***"..user.sName.." and "..Nick.sName.." have been disconnected from the hub.\r\n\r\n"
if Nick.sIP == user.sIP    then
user:SendPM(Bot,UserMsg2Send)
user:Disconnect()
SendPmToNick(Nick.sName,Bot,UserMsg2Send)
Nick:Disconnect()
if PmOps == "yes" then
SendPmToOps(Bot,OpMsg)
end
end
end
end
end
end