PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: bastya_elvtars on 03 April, 2005, 19:53:10

Title: Clonebot 1.1
Post by: bastya_elvtars on 03 April, 2005, 19:53:10
Very-very preparation stage. Seems to work howeva. :P Please test carefully! ;)

-- Clone Alert 1.1
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch

OpChatName = "opschat" --Rename to opchatbot
Bot = "[Sentry]" --Rename to you main Px bot
PmOps = "1" --Should Ops be notified 1=yes 0=no (STRONGLY recommended to leave enabled!)



function NewUserConnected(curUser,sdata)
for _,Nick in frmHub:GetOnlineUsers() do
if curUser.sIP==Nick.sIP and not (curUser.bOperator and Nick.bOperator) then
if curUser.iShare==Nick.iShare then
curUser:SendPM(Bot,"This hub does not allow the use of clones. Hit the bricks, ya leecher!")
curUser:Disconnect()
Nick:SendPM(Bot,"This hub does not allow the use of clones. Hit the bricks, ya leecher!")
Nick: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
else
SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..nick.sName.." but with different share, please check.")
end
end
end
end

Title:
Post by: jiten on 03 April, 2005, 20:37:06
Well, it's working ok with me  :D
Btw, i found a little bug, nothing much.
It should be:

if PmOps == "1" then

or

PMOps = "1"

Thanks for this one.

Cheers
Title:
Post by: jiten on 04 April, 2005, 09:52:02
Made some mods in this Clonebot. Here it is:

-- Clone Alert 1.1
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten

OpChatName = "OpChat" --Rename to opchatbot
Bot = "?bot?" --Rename to you main Px bot
PmOps = "1" --Should Ops be notified 1=yes 0=no (STRONGLY recommended to leave enabled!)

--imunity stuff
fimmune= "logs/cloneimmune.txt"
immunetbl = {}

function Main()
--imunity stuff
LoadFromFile(fimmune)
end

function NewUserConnected(curUser,sdata)
for _,Nick in frmHub:GetOnlineUsers() do
if not(immunetbl[curUser.sName]== 1 or immunetbl[Nick.sName]== 1) and not (curUser.bOperator or Nick.bOperator) and curUser.sIP==Nick.sIP then
if curUser.iShareSize==Nick.iShareSize then
curUser:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..Nick.sName)
curUser:SendPM(Bot,"You're being timebanned. Your IP: "..curUser.sIP)
curUser:TimeBan(5)
Nick:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..curUser.sName)
if PmOps == "1" then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and timebanned for 5 minutes. User is a clone of <"..Nick.sName..">")
else
SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..nick.sName.." but with different share, please check.")
end
end
end
end
end

----------------------------->Immunity Stuff<---------------------------------
function immune(user,data)
local s,e,cmd,Name = string.find( data, "%b<>%s+(%S+)%s+(%S+)" )
if (Name == nil) then
user:SendData(Bot, "*** Error: Type !addclone nick")
else
victim = GetItemByName(Name)  
if victim==nil then  
user:SendData(Bot, "*** Error: User is not online.")
elseif immunetbl[victim.sName] == nil then
immunetbl[victim.sName] = 1
saveimmune()
user:SendData(Bot, victim.sName.." is now immune to clone checks!")
else
user:SendData("nope")
end
end
end

function delimmune(user,data)
local s,e,Name = string.find(data, "%b<>%s+%S+%s+(.+)")
if (Name == nil) then
user:SendData(Bot, "*** Error: Type !delclone nick")
else
victim =GetItemByName(Name)
if victim==nil then  
user:SendData(Bot, "*** Error: That user is not online.")
elseif immunetbl[victim.sName] == 1 then
immunetbl[victim.sName] = nil
saveimmune()
user:SendData(Bot,"Now "..victim.sName.." is not no longer immune to clone checks!")
else
user:SendData(Bot,"The user "..victim.sName.." is not immune!")
end
end
end

function showimmune(user)
if isEmpty(immunetbl) then
user:SendPM(Bot,"*** Error: There aren't any immuned users")
else
local Tmp,usr,table1 = "\r\n\t\ These are the Clone Immuned User(s):\r\n\r\n"  
for usr, table1 in immunetbl do
if GetItemByName(usr) then
Tmp = Tmp.."\t".."  ? (Online)   "..usr.." \r\n"
else
Tmp = Tmp.."\t".."  ? (Offline)  "..usr.." \r\n"
end
end
user:SendPM(Bot,Tmp)
end
end

-------------------save immune
function saveimmune(user,data)  
local fimmune = io.open("logs/cloneimmune.txt", "w+")
assert(fimmune, "logs/cloneimmune.txt")
fimmune:write("immunetbl = {");  
for a,b in immunetbl do  
if b then  
fimmune:write(string.format("[%q]=",a)..b..",");  
end  
end  
fimmune:write("}" );  
fimmune:close()
end  

function ChatArrival (user,data)
if (user.bOperator) then
data = string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find( data, "%b<>%s+(%S+)" )
if cmd=="!addclone" then
immune(user,data)
return 1
elseif cmd=="!delclone" then
delimmune(user,data)
return 1
elseif cmd=="!showclone" then
showimmune(user,data)
return 1
end
end
end

ToArrival = ChatArrival

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

-------------table checker by herodes
--- for an associative table, like ["smth"] = "smth else",
function isEmpty(t)
for i,v in t do
return false;
end
return true;
end;

*EDIT - Corrected typos (imune to immune)
Best regards,

jiten
Title:
Post by: bastya_elvtars on 04 April, 2005, 13:09:17
Nice job, now it's like it's lua4 brother. My point was: I make the detector, others make the decorations. :D Thx, jiten, good job there!
Title:
Post by: jiten on 04 April, 2005, 15:13:26
QuoteOriginally posted by bastya_elvtars
Nice job, now it's like it's lua4 brother. My point was: I make the detector, others make the decorations. :D Thx, jiten, good job there!

yw m8  :]
Title:
Post by: DEEP-GOA on 08 April, 2005, 01:21:23
error:

Syntax C:\0.3.3.0.b16.06.nt.dgb\scripts\CloneAlert1.1.lua:46: attempt to index global `immunetbl' (a nil value)

maybe a bug?

greetz & zakaboom
Title:
Post by: bastya_elvtars on 08 April, 2005, 01:26:47
Thats seems a typo to me. replace to imunetbl and it must work. :)
Title:
Post by: jiten on 08 April, 2005, 10:38:48
QuoteOriginally posted by DEEP-GOA
error:

Syntax C:\0.3.3.0.b16.06.nt.dgb\scripts\CloneAlert1.1.lua:46: attempt to index global `immunetbl' (a nil value)

maybe a bug?

greetz & zakaboom

Yups, was a typo  :D
First post updated.
Title:
Post by: DEEP-GOA on 08 April, 2005, 22:17:43
hiho

mmany thanks,, now works fine,,   deepy8) should read the code lol

zakagreetings
Title:
Post by: jiten on 08 April, 2005, 23:20:26
QuoteOriginally posted by DEEP-GOA
hiho

mmany thanks,, now works fine,,   deepy8) should read the code lol

zakagreetings

yw m8  :]
Title:
Post by: Typhoon on 09 April, 2005, 10:36:13
as i can see theres no real advantage to have the 3 serialize functions in the script... just use dofile() instead ..

makes the script shorter :)

Typhoon?
Title:
Post by: jiten on 09 April, 2005, 11:00:06
QuoteOriginally posted by Typhoon?
as i can see theres no real advantage to have the 3 serialize functions in the script... just use dofile() instead ..

makes the script shorter :)

Typhoon?

Well, in fact there's no need for the SaveToFile and Serialize function except for the LoadFromFile.
For the last one, if I used only dofile(filename) in the main function, I'd always get a error when starting the server for the first time because the file didn't exist. I guess u get it  ;)

Btw, removed those 2 functions to have a shorter one.

Cheers
Title:
Post by: Typhoon on 09 April, 2005, 11:26:18
QuoteOriginally posted by jiten
QuoteOriginally posted by Typhoon?
as i can see theres no real advantage to have the 3 serialize functions in the script... just use dofile() instead ..

makes the script shorter :)

Typhoon?

Well, in fact there's no need for the SaveToFile and Serialize function except for the LoadFromFile.
For the last one, if I used only dofile(filename) in the main function, I'd always get a error when starting the server for the first time because the file didn't exist. I guess u get it  ;)

Btw, removed those 2 functions to have a shorter one.

Cheers

oh yeah forgot if file is nil :)

Typhoon?
Title:
Post by: jiten on 09 April, 2005, 12:03:31
:D
Title:
Post by: ??????Hawk?????? on 09 April, 2005, 18:40:52
hi

QuoteWell, in fact there's no need for the SaveToFile and Serialize function except for the LoadFromFile.
For the last one, if I used only dofile(filename) in the main function, I'd always get a error when starting the server for the first time because the file didn't exist. I guess u get it  



maby use something like this for loading...
function LoadFile(file)
local r,e = io.open(file,"r")
if r then
f = assert(loadfile(file), " ")
else
r,e = io.open(file, "w" )
r:write("|")
r:close()
end
end


??????Hawk??????
Title:
Post by: bastya_elvtars on 10 April, 2005, 12:40:32
QuoteOriginally posted by Mutor
QuoteI make the detector, others make the decorations

Who made what?   :P

-peace

:)

I gave credits to you, and I made the new way detector. Are you satisfied now? ;)
Title:
Post by: Fruitbat? on 15 April, 2005, 16:38:54
soz for newbie questions but what i am i doing wrong

running :-
PtokaX DC Hub 0.3.3.0 build 16.09
 Robocop 10.01c
FunScript Version 6.3 Made by Madman

but when i added this script it works some times and not others plus if i open ptokax/Advanced to check memory used by scripts i have 3 or 4 of this script running.This happens when i refresh scripts.

testing this in a mirror image of my hub ( as always test settings first before i apply to main hub)

ne input would be grateful

Thx
Fruitbat?
Title:
Post by: Dessamator on 15 April, 2005, 17:33:01
nop, tested it with the same ptokax, no errors here, and no extra scripts in ptokax !!
Title:
Post by: jiten on 15 April, 2005, 18:26:59
Yups, no errors here. Maybe u're doing something wrong there. Try copying the script all over again and then change the script loading order. Don't know if this will help, but, it's worth a try.
Title:
Post by: ConejoDelMal on 16 April, 2005, 06:03:50
well....i tested this script, and in a hub with 150 users the script is eating memory.... i checked ptokax and this script alone was using 800kb....dont know if i have something wrong, or if its the code

*edited*
But it didnt multiply itself... :P
Title:
Post by: Dessamator on 17 April, 2005, 21:45:59
hmmm, well mayb herodes can help, hes good with memory related "bugs" !!
Title:
Post by: bastya_elvtars on 17 April, 2005, 22:30:41
As it has to work with all users' all properties on a connect, it should not be surprising. however, it would be nice if you pasted a result of !stat here.
Title:
Post by: Herodes on 18 April, 2005, 01:22:14
gave it a touch .. syntax errors checked only ..
runs on 46/62:Mem/GC with an empty table on my family pc .. :)-- Clone Alert 1.5
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten
--- -- touched by Herodes
-- heavily optimised
-- moved to 1.5

OpChatName = "OpChat"  -- Rename to opchatbot
Bot = "?bot?" -- Rename to you main Px bot
PmOps = true -- true:enables / false:disables , operator notifincation (STRONGLY recommended to leave enabled!)

function Main()
tImmune = {}
if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end
end

function OnExit()
collectgarbage()
local f = io.open("logs/cloneimmune.txt", "w+")
local m = "tImmune = { "
for a, b in tImmune do m = m..string.format("%q, ", string.gsub( a, "\"", "\"" )); end
m = m.." }"
f:write( m ); f:close();
end

function NewUserConnected( user, data )
for _, nick in frmHub:GetOnlineUsers() do
if not ( user.bOperator or nick.bOperator ) then
if not ( tImmune[user.sName] or tImmune[nick.sName] ) then
if (user.sIP == nick.sIP) then
user:SendPM( Bot, "Double Login is not allowed. You are already connected to this hub with this nick: "..nick.sName )
nick:SendPM( Bot, "Double Login is not allowed. You are already connected to this hub with this nick: "..user.sName )
if ( PmOps ) then
SendPmToOps(OpChatName, "*** User "..user.sName.." logged in, with same IP as "..nick.sName.." but with different share, please check.")
elseif (user.iShareSize == nick.iShareSize) then
SendPmToOps(OpChatName, "*** Cloned user <"..user.sName.."> ("..user.sIP..") logged in and timebanned for 5 minutes. User is a clone of <"..nick.sName..">")
user:SendPM( Bot, "You're being timebanned. Your IP: "..user.sIP )
user:TimeBan( 5 )
end
end
end
end
end
end

function ChatArrival (user,data)
if (user.bOperator) then
local data = string.sub( data, 1, -2 )
local s,e,cmd = string.find( data, "%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse( user, cmd, data, false )
end
end
end

function ToArrival ( user, data )
if ( user.bOperator ) then
local data = string.sub( data , 1, -2 )
local s,e, cmd = string.find( data , "%$%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse ( user, cmd , data , true )
end
end
end

function Parse( user, cmd, data, how )

local function SendBack( user, msg , from, how )
if how then user:SendPM( from or Bot , msg );return 1; end;
user:SendData( from or Bot, msg );return 1;
end

local t = {
--- Add to cloneList
["+clone"] = function ( user , data , how )
local s,e, name = string.find( data, "%b<>%s+%S+%s+(%S+)" )

if not name then user:SendData(Bot, "*** Error: Type !addclone nick") end
if tImmune[name] then user:SendData("nope") end

local nick = GetItemByName(name)
if not nick then user:SendData(Bot, "*** Error: User is not online.") end

tImmune[name] = 1
OnExit()
user:SendData(Bot, name.." is now immune to clone checks!")
return 1
end ,
--- Remove from cloneList
["-clone"] = function ( user , data , how )
local s,e, name = string.find(data, "%b<>%s+%S+%s+(%S+)")
if not name then user:SendData(Bot, "*** Error: Type !delclone nick") end
if not tImmune[name] then user:SendData(Bot,"The user "..victim.sName.." is not immune!")  end

local nick = GetItemByName( name )
if not nick then user:SendData(Bot, "*** Error: That user is not online.") end

tImmune[name] = nil
OnExit()
user:SendData(Bot,"Now "..name.." is not no longer immune to clone checks!")
return 1
end,
--- Show cloneList
["?clone"] = function ( user , data, how )
local m = ""
collectgarbage()
for nick, _ in tImmune do
local s = "Offline"
if GetItemByName(nick) then s = "Online"; end
m = m.."\r\n\t  ? ("..s..")  "..nick
end
if m == "" then return SendBack( user, "There are no users that can have a clone", Bot, how ) end
m = "\r\nThe following users can have clones in this hub:"..m
return SendBack( user, m , Bot, how )
end,
--- Show cloneBot help
["?clonehelp"] = function ( user, data , how )
local m = "\r\n\r\nHere are the commands for the CloneBot:"
m = m.."\r\n\t+clone \t allows to have a clone"
m = m.."\r\n\t-clone \t removes from the clone list"
m = m.."\r\n\t?clone\t\t shows the users allowed to have a clone"
m = m.."\r\n\t?clonehelp \t allows to have a clone"
return SendBack( user, m, Bot, how )
end, }

if t[cmd] then return t[cmd]( user, data, how ) end
end
Title:
Post by: bastya_elvtars on 18 April, 2005, 01:52:00
function Main()

tImmune = {}

if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end

end

I used this method and works...
Title:
Post by: ConejoDelMal on 18 April, 2005, 19:00:48
i will test it later today, and this time i try not to forget the !stat ..  :P
Title:
Post by: jiten on 18 April, 2005, 19:15:03
Nice to know.
Let us know how did it go, as I haven't tested Herodes' version.

Cheers
Title:
Post by: ConejoDelMal on 19 April, 2005, 00:42:28
well...working good, memory usage droped to almost 400kb
------------------------------------------------------------
Current stats:
------------------------------------------------------------
Version: PtokaX DC Hub 0.3.3.0 build 16.09 [debug] built on Mar 28 2005 22:54:36
Uptime: 0 days, 0 hours, 5 minutes
Users (Max/Actual Peak (Max Peak)/Logged) : 400 / 126 (167) / 126
Chat messages: 52 x
Unknown commands: 0 x
PM commands: 3 x
Key commands: 1104 x
Supports commands: 673 x
MyINFO commands: 1238 x
ValidateNick commands: 1082 x
GetINFO commands: 325 x
Password commands: 64 x
Version commands: 968 x
UserIP commands: 0 x
GetNickList commands: 971 x
Search commands: 345 x
SR commands: 703 x
CTM commands: 1808 x
RevCTM commands: 881 x
BotINFO commands: 0 x
------------------------------------------------------------
CPU usage (All processes 60 seconds average): 63.8%
CPU time: 0:01:37
Mem usage (Old style): 3794 kB
Mem usage (Peak): 12.99 MB (18.41 MB)
VM size (Peak): 12.48 MB (14.29 MB)
------------------------------------------------------------
SendRests (Peak): 0 (0)
RecvRests (Peak): 0 (1)
SendBytes: 2.23 MB
RecvBytes: 86.37 kB

But i cant imunize nobody...cmd's arent working...or i'm already too tired...

*edited*
Cmd's really dont work, did some more testing, and tried bastya's way... no way i can imunize a user...
And even if the share isnt the same, it bans the "clone"..
Title:
Post by: Dessamator on 19 April, 2005, 15:03:15
QuoteOriginally posted by [AT]conejodelmal
well...working good, memory usage droped to almost 400kb
------------------------------------------------------------
Current stats:
------------------------------------------------------------
Version: PtokaX DC Hub 0.3.3.0 build 16.09 [debug] built on Mar 28 2005 22:54:36
Uptime: 0 days, 0 hours, 5 minutes
Users (Max/Actual Peak (Max Peak)/Logged) : 400 / 126 (167) / 126
Chat messages: 52 x
Unknown commands: 0 x
PM commands: 3 x
Key commands: 1104 x
Supports commands: 673 x
MyINFO commands: 1238 x
ValidateNick commands: 1082 x
GetINFO commands: 325 x
Password commands: 64 x
Version commands: 968 x
UserIP commands: 0 x
GetNickList commands: 971 x
Search commands: 345 x
SR commands: 703 x
CTM commands: 1808 x
RevCTM commands: 881 x
BotINFO commands: 0 x
------------------------------------------------------------
CPU usage (All processes 60 seconds average): 63.8%
CPU time: 0:01:37
Mem usage (Old style): 3794 kB
Mem usage (Peak): 12.99 MB (18.41 MB)
VM size (Peak): 12.48 MB (14.29 MB)
------------------------------------------------------------
SendRests (Peak): 0 (0)
RecvRests (Peak): 0 (1)
SendBytes: 2.23 MB
RecvBytes: 86.37 kB

But i cant imunize nobody...cmd's arent working...or i'm already too tired...

*edited*
Cmd's really dont work, did some more testing, and tried bastya's way... no way i can imunize a user...
And even if the share isnt the same, it bans the "clone"..

yap ur tired c the commands here ::
QuoteHere are the commands for the CloneBot:
   +clone     allows to have a clone
   -clone     removes from the clone list
   ?clone       shows the users allowed to have a clone
   ?clonehelp     allows to have a clone

u can change them if u know how to, but i think its not necessary !!!
Title:
Post by: ConejoDelMal on 19 April, 2005, 15:31:31
well, thx for the reply, dont know what happened yesterday, but it really didnt work.. today it's working (or i'm working :P)
anyway, still got some problems, when i try to imunize a clone, i get an error:
 Syntax ...abalho\LusoLeader Hub 16.09 dbg\scripts\NoClones.lua:29: bad argument #1 to `sub' (string expected, got nil)

And when i restart the hub, or the scripts, the table doesnt save, so i have to imunize all users again
Title:
Post by: Dessamator on 19 April, 2005, 15:54:14
yap ur right, [AT]conejodelmal ,
theres something wrong with the file handling
::::::::

 
function OnExit()
collectgarbage()
local f = io.open("logs/cloneimmune.txt", "w+")
local m = "tImmune = { "
for nick , _ in tImmune do m = m..string.format("%q, ", string.sub( a, "\"", "\"" )); end
m = m.." }"
f:write( m ); f:close();
end


to be exact here ::
for nick , _ in tImmune do m = m..string.format("%q, ", string.sub( a, "\"", "\"" )); end

ps. the tables arent being saved,
Title:
Post by: Herodes on 19 April, 2005, 15:56:21
QuoteOriginally posted by [AT]conejodelmal
well, thx for the reply, dont know what happened yesterday, but it really didnt work.. today it's working (or i'm working :P)
anyway, still got some problems, when i try to imunize a clone, i get an error:
 Syntax ...abalho\LusoLeader Hub 16.09 dbg\scripts\NoClones.lua:29: bad argument #1 to `sub' (string expected, got nil)

And when i restart the hub, or the scripts, the table doesnt save, so i have to imunize all users again
my script is now updated .. fixing that immune saving error ...and adding the way bastya_elvtars is doing his loading ;)
Title:
Post by: jiten on 19 April, 2005, 16:01:45
Well, now there's another problem:
Syntax ...en\16.09.tst\scripts\clonealert.lua:25: bad argument #2 to `sub' (number expected, got string)Cheers
Title:
Post by: Herodes on 19 April, 2005, 16:05:47
QuoteOriginally posted by jiten
Well, now there's another problem:
Syntax ...en\16.09.tst\scripts\clonealert.lua:25: bad argument #2 to `sub' (number expected, got string)Cheers
yep sorted that one too.. my post (http://board.univ-angers.fr/thread.php?threadid=4127&boardid=26&styleid=1&page=3#24) has been edited once more ...
Title:
Post by: ConejoDelMal on 19 April, 2005, 16:13:48
Getting error when I imunize:
Syntax ...abalho\LusoLeader Hub 16.09 dbg\scripts\NoClones.lua:90: attempt to index global `victim' (a nil value)

Getting error when I remove from Imune List:
Syntax ...abalho\LusoLeader Hub 16.09 dbg\scripts\NoClones.lua:104: attempt to index global `victim' (a nil value)

Not saving the tables...
And even if the share isnt the same, it bans the clone
Title:
Post by: Herodes on 19 April, 2005, 16:20:41
QuoteOriginally posted by [AT]conejodelmal
Getting error when I imunize:
Syntax ...abalho\LusoLeader Hub 16.09 dbg\scripts\NoClones.lua:90: attempt to index global `victim' (a nil value)

Getting error when I remove from Imune List:
Syntax ...abalho\LusoLeader Hub 16.09 dbg\scripts\NoClones.lua:104: attempt to index global `victim' (a nil value)

Not saving the tables...
And even if the share isnt the same, it bans the clone
tx for the bug-rain,... post edited yet once more ..
Title:
Post by: ConejoDelMal on 19 April, 2005, 16:29:23
well...found a couple more things which dont work/fit :P

when share isnt the same, it allows user to get in, but it sends the wrong message to Op's:
Private message from OpChat: *** Cloned user <[AT]conejodelmal> (10.6.0.16) logged in and timebanned for 5 minutes. User is a clone of <-=Anti-Fakers=->

when i add a clone (no errors now), and i restart the scripts, it saves only numbers:
   Before restart of scripts
   The following users can have clones in this hub:
     ? (Offline)  1
     ? (Offline)  2
     ? (Offline)  3
     ? (Online)  [AT]conejodelmal

   After restart of scripts:
   The following users can have clones in this hub:
     ? (Offline)  1
     ? (Offline)  2
     ? (Offline)  3
     ? (Offline)  4
Title:
Post by: Herodes on 19 April, 2005, 16:36:03
thats the virtues of on-the-fly degugging... :(

re-re-re-edited post ...
Title:
Post by: ConejoDelMal on 19 April, 2005, 16:39:07
well...message is correct now, but still saves numbers after restarting...
sorry to be such a pain :P

*edited*
And the clone with different share gets the message:
[16:39:30] Private message from ?bot?: Double Login is not allowed. You are already connected to this hub with this nick: [AT]conejodelmal
Title:
Post by: Dessamator on 19 April, 2005, 17:05:04
QuoteOriginally posted by [AT]conejodelmal
well...message is correct now, but still saves numbers after restarting...
sorry to be such a pain :P

*edited*
And the clone with different share gets the message:
[16:39:30] Private message from •bot•: <•bot•> Double Login is not allowed. You are already connected to this hub with this nick: [AT]conejodelmal

well, just replace the previous onexit function with this ::
   
function OnExit()
collectgarbage()
local f = io.open("logs/cloneimmune.txt", "w+")
local m = "tImmune = { "
for a, b in tImmune do m = m..(string.format("[%q]=",a)..b..","); end
m = m.." }"
f:write( m ); f:close();
end
Title:
Post by: ConejoDelMal on 19 April, 2005, 17:16:29
great work u guys, script is almost perfect, just 2 or 3 details:

 Private message from ?bot?: Double Login is not allowed. You are already connected to this hub with this nick: [AT]conejodelmal

this message shouldnt be sent to both users if share size isnt the same, just the notification to the Op's

and:
if not name then user:SendData(Bot, "*** Error: Type !delclone nick") end

should be changed to:
if not name then user:SendData(Bot, "*** Error: Type -clone nick") end

the same with other cmd's syntax error messages
Title:
Post by: Dessamator on 19 April, 2005, 17:21:43
QuoteOriginally posted by [AT]conejodelmal
great work u guys, script is almost perfect, just 2 or 3 details:

 Private message from •bot•: <•bot•> Double Login is not allowed. You are already connected to this hub with this nick: [AT]conejodelmal

this message shouldnt be sent to both users if share size isnt the same, just the notification to the Op's


replace the previous newuserconnected with this :::

function NewUserConnected(curUser,sdata)
for _,Nick in frmHub:GetOnlineUsers() do
if not(tImmune[curUser.sName]== 1 or tImmune[Nick.sName]== 1) and not (curUser.bOperator or Nick.bOperator) and curUser.sIP==Nick.sIP then
if curUser.iShareSize==Nick.iShareSize then
curUser:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..Nick.sName)
curUser:SendPM(Bot,"You're being timebanned. Your IP: "..curUser.sIP)
curUser:TimeBan(5)
Nick:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..curUser.sName)
if PmOps == "1" then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and timebanned for 5 minutes. User is a clone of <"..Nick.sName..">")
else
SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..Nick.sName.." but with different share, please check.")
end
end
end
end
end




it should work, hopefully !!!

and:
if not name then user:SendData(Bot, "*** Error: Type !delclone nick") end

should be changed to:
if not name then user:SendData(Bot, "*** Error: Type -clone nick") end

the same with other cmd's syntax error messages          


well, thats just a simple thing to correct, even u can do that, and that depends on the script u could change the commands triggers , so its not that big of a prob !!
Title:
Post by: ConejoDelMal on 19 April, 2005, 17:26:18
Not sending message to users anymore, but not sending Op notification either  :P

and about the cmd's syntax messages, i was only warning so that others dont get problems...i already corrected it for myself :)
Title:
Post by: Dessamator on 19 April, 2005, 17:34:28
QuoteOriginally posted by [AT]conejodelmal
Not sending message to users anymore, but not sending Op notification either  :P

and about the cmd's syntax messages, i was only warning so that others dont get problems...i already corrected it for myself :)

u obviously did something wrong, anyways, heres the full script :::

 
-- Clone Alert 1.5
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten
--- -- touched by Herodes
-- heavily optimised
-- moved to 1.5

OpChatName = "OpChat"  -- Rename to opchatbot
Bot = "•bot•" -- Rename to you main Px bot
PmOps = true -- true:enables / false:disables , operator notifincation (STRONGLY recommended to leave enabled!)

function Main()
tImmune = {}
if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end
end

function OnExit()
collectgarbage()
local f = io.open("logs/cloneimmune.txt", "w+")
local m = "tImmune = { "
for a, b in tImmune do m = m..(string.format("[%q]=",a)..b..","); end
m = m.." }"
f:write( m ); f:close();
end

function NewUserConnected(curUser,sdata)
for _,Nick in frmHub:GetOnlineUsers() do
if not(tImmune[curUser.sName]== 1 or tImmune[Nick.sName]== 1) and not (curUser.bOperator or Nick.bOperator) and curUser.sIP==Nick.sIP then
if curUser.iShareSize==Nick.iShareSize then
curUser:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..Nick.sName)
curUser:SendPM(Bot,"You're being timebanned. Your IP: "..curUser.sIP)
curUser:TimeBan(5)
Nick:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..curUser.sName)
if PmOps == "1" then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and timebanned for 5 minutes. User is a clone of <"..Nick.sName..">")
else
SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..Nick.sName.." but with different share, please check.")
end
end
end
end
end

function ChatArrival (user,data)
if (user.bOperator) then
local data = string.sub( data, 1, -2 )
local s,e,cmd = string.find( data, "%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse( user, cmd, data, false )
end
end
end



function ToArrival ( user, data )
if ( user.bOperator ) then
local data = string.sub( data , 1, -2 )
local s,e, cmd = string.find( data , "%$%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse ( user, cmd , data , true )
end
end
end

function Parse( user, cmd, data, how )

local function SendBack( user, msg , from, how )
if how then user:SendPM( from or Bot , msg );return 1; end;
user:SendData( from or Bot, msg );return 1;
end

local t = {
--- Add to cloneList
["+clone"] = function ( user , data , how )
local s,e, name = string.find( data, "%b<>%s+%S+%s+(%S+)" )

if not name then user:SendData(Bot, "*** Error: Type !addclone nick") end
if tImmune[name] then user:SendData("nope") end

local nick = GetItemByName(name)
if not nick then user:SendData(Bot, "*** Error: User is not online.") end

tImmune[name] = 1
OnExit()
user:SendData(Bot, name.." is now immune to clone checks!")
return 1

end ,

--- Remove from cloneList
["-clone"] = function ( user , data , how )
local s,e, name = string.find(data, "%b<>%s+%S+%s+(%S+)")

if not name then user:SendData(Bot, "*** Error: Type !delclone nick") end
if not tImmune[name] then user:SendData(Bot,"The user "..victim.sName.." is not immune!")  end

local nick = GetItemByName( name )
if not nick then user:SendData(Bot, "*** Error: That user is not online.") end

tImmune[name] = nil
OnExit()
user:SendData(Bot,"Now "..name.." is not no longer immune to clone checks!")
return 1

end,

--- Show cloneList
["?clone"] = function ( user , data, how )

local m = ""
collectgarbage()
for nick, _ in tImmune do
local s = "Offline"
if GetItemByName(nick) then s = "Online" end
m = m.."\r\n\t  • ("..s..")  "..nick
end
if m == "" then return SendBack( user, "There are no users that can have a clone", Bot, how ) end
m = "\r\nThe following users can have clones in this hub:"..m
return SendBack( user, m , Bot, how )
end,
--- Show cloneBot help

["?clonehelp"] = function ( user, data , how )

local m = "\r\n\r\nHere are the commands for the CloneBot:"
m = m.."\r\n\t+clone \t allows to have a clone"
m = m.."\r\n\t-clone \t removes from the clone list"
m = m.."\r\n\t?clone\t\t shows the users allowed to have a clone"
m = m.."\r\n\t?clonehelp \t allows to have a clone"
return SendBack( user, m, Bot, how )

end, }

if t[cmd] then return t[cmd]( user, data, how ) end
end


ps  the warning to the user ::

 
 [17:34] Private message from •bot•: <•bot•> Double Login is not allowed. You are already connected to this hub with this nick: vipgg
[17:34] Private message from •bot•: <•bot•> You're being timebanned. Your IP: 127.0.0.1
Title:
Post by: jiten on 19 April, 2005, 17:40:22
QuoteOriginally posted by [AT]conejodelmal
And the clone with different share gets the message:
[16:39:30] Private message from ?bot?: Double Login is not allowed. You are already connected to this hub with this nick: [AT]conejodelmal
This happened because "Bot" wasn't registered.
U had to put an extra line in Function Main() with this and that would be solved:
frmHub:RegBot(Bot)Cheers
Title:
Post by: Dessamator on 19 April, 2005, 17:50:32
QuoteOriginally posted by jiten
QuoteOriginally posted by [AT]conejodelmal
And the clone with different share gets the message:
[16:39:30] Private message from •bot•: <•bot•> Double Login is not allowed. You are already connected to this hub with this nick: [AT]conejodelmal
This happened because "Bot" wasn't registered.
U had to put an extra line in Function Main() with this and that would be solved:
frmHub:RegBot(Bot)Cheers

lol, i thought that was obvious, silly me,  :D
Title:
Post by: ConejoDelMal on 19 April, 2005, 17:58:48
I feel so misunderstood .... :P

I'll explain...
When a user gets in with different share and same Ip, does no longer gets a pm saying it is not allowed (solved by Dessamator) but i want the Op's to get it, and they arent

When a user gets in with same Ip and Share size, the users gets timebanned, but the Op's dont get any notification about it.

So, in the end, everything is working good, just not the Pm2Ops in both cases
Title:
Post by: jiten on 19 April, 2005, 18:05:59
Try this:
function NewUserConnected(curUser,sdata)
for _,Nick in frmHub:GetOnlineUsers() do
if not(tImmune[curUser.sName]== 1 or tImmune[Nick.sName]== 1) and not (curUser.bOperator or Nick.bOperator) and curUser.sIP==Nick.sIP then
if curUser.iShareSize==Nick.iShareSize then
curUser:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..Nick.sName)
curUser:SendPM(Bot,"You're being timebanned. Your IP: "..curUser.sIP)
curUser:TimeBan(5)
Nick:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..curUser.sName)
-- Nick:TimeBan(5) -- If u want both to be timebanned
if PmOps == "1" then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and timebanned for 5 minutes. User is a clone of <"..Nick.sName..">")
else
end
else
SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..Nick.sName.." but with different share, please check.")
end
end
end
end


and change this:
PmOps = trueto
PmOps = falseCheers
Title:
Post by: ConejoDelMal on 19 April, 2005, 18:12:19
now it is a perfect script! Tested and recommended!
the final corrected version of it:
-- Clone Alert 1.5
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten
--- -- touched by Herodes
-- heavily optimised
-- moved to 1.5

OpChatName = "OpChat"  -- Rename to opchatbot
Bot = "botname" -- Rename to you main Px bot
PmOps = false -- true:enables / false:disables , operator notifincation (STRONGLY recommended to leave enabled!)

function Main()
tImmune = {}
if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end
end

function OnExit()
collectgarbage()
local f = io.open("logs/cloneimmune.txt", "w+")
local m = "tImmune = { "
for a, b in tImmune do m = m..(string.format("[%q]=",a)..b..","); end
m = m.." }"
f:write( m ); f:close();
end

function NewUserConnected(curUser,sdata)
for _,Nick in frmHub:GetOnlineUsers() do
if not(tImmune[curUser.sName]== 1 or tImmune[Nick.sName]== 1) and not (curUser.bOperator or Nick.bOperator) and curUser.sIP==Nick.sIP then
if curUser.iShareSize==Nick.iShareSize then
curUser:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..Nick.sName)
curUser:SendPM(Bot,"You're being timebanned. Your IP: "..curUser.sIP)
curUser:TimeBan(5)
Nick:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..curUser.sName)
-- Nick:TimeBan(5) -- If u want both to be timebanned
if PmOps == "1" then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and timebanned for 5 minutes. User is a clone of <"..Nick.sName..">")
else
end
else
SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..Nick.sName.." but with different share, please check.")
end
end
end
end


function ChatArrival (user,data)
if (user.bOperator) then
local data = string.sub( data, 1, -2 )
local s,e,cmd = string.find( data, "%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse( user, cmd, data, false )
end
end
end



function ToArrival ( user, data )
if ( user.bOperator ) then
local data = string.sub( data , 1, -2 )
local s,e, cmd = string.find( data , "%$%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse ( user, cmd , data , true )
end
end
end

function Parse( user, cmd, data, how )

local function SendBack( user, msg , from, how )
if how then user:SendPM( from or Bot , msg );return 1; end;
user:SendData( from or Bot, msg );return 1;
end

local t = {
--- Add to cloneList
["+clone"] = function ( user , data , how )
local s,e, name = string.find( data, "%b<>%s+%S+%s+(%S+)" )

if not name then user:SendData(Bot, "*** Error: Type +clone nick") end
if tImmune[name] then user:SendData("nope") end

local nick = GetItemByName(name)
if not nick then user:SendData(Bot, "*** Error: User is not online.") end

tImmune[name] = 1
OnExit()
user:SendData(Bot, name.." is now immune to clone checks!")
return 1

end ,

--- Remove from cloneList
["-clone"] = function ( user , data , how )
local s,e, name = string.find(data, "%b<>%s+%S+%s+(%S+)")

if not name then user:SendData(Bot, "*** Error: Type -clone nick") end
if not tImmune[name] then user:SendData(Bot,"The user "..victim.sName.." is not immune!")  end

local nick = GetItemByName( name )
if not nick then user:SendData(Bot, "*** Error: That user is not online.") end

tImmune[name] = nil
OnExit()
user:SendData(Bot,"Now "..name.." is not no longer immune to clone checks!")
return 1

end,

--- Show cloneList
["?clone"] = function ( user , data, how )

local m = ""
collectgarbage()
for nick, _ in tImmune do
local s = "Offline"
if GetItemByName(nick) then s = "Online" end
m = m.."\r\n\t  • ("..s..")  "..nick
end
if m == "" then return SendBack( user, "There are no users that can have a clone", Bot, how ) end
m = "\r\nThe following users can have clones in this hub:"..m
return SendBack( user, m , Bot, how )
end,
--- Show cloneBot help

["?clonehelp"] = function ( user, data , how )

local m = "\r\n\r\nHere are the commands for the CloneBot:"
m = m.."\r\n\t+clone \t allows to have a clone"
m = m.."\r\n\t-clone \t removes from the clone list"
m = m.."\r\n\t?clone\t\t shows the users allowed to have a clone"
m = m.."\r\n\t?clonehelp \t allows to have a clone"
return SendBack( user, m, Bot, how )

end, }

if t[cmd] then return t[cmd]( user, data, how ) end
end

Thx a lot to all that helped!
Title:
Post by: Dessamator on 19 April, 2005, 18:25:21
at last it(the anti clone) is  finished, a masterpiece(after dusting off the bugs)
:D
Title:
Post by: bastya_elvtars on 19 April, 2005, 19:10:29
QuoteOriginally posted by Dessamator
at last it(the anti clone) is  finished

Nope. :D

-- Clone Alert 1.6
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten
--- -- touched by Herodes
-- heavily optimised
-- moved to 1.5
-- now it's 1.6, after bastya_elvtars did some more optimization to the detector. :P


OpChatName = "OpChat"  -- Rename to opchatbot
Bot = "botname" -- Rename to you main Px bot
kick=0 -- 0 to only disconnect, otherwise enter a number, and user will be kicked for that amount of minutes.
kick_other_too=0 -- 1 to disconnect/kick the already logged in user, 0 to not
PmOps = false -- true:enables / false:disables , operator notifincation (STRONGLY recommended to leave enabled!)


function Main()
tImmune = {}
if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end
end


function OnExit()
collectgarbage()
local f = io.open("logs/cloneimmune.txt", "w+")
local m = "tImmune = { "
for a, b in tImmune do m = m..(string.format("[%q]=",a)..b..","); end
m = m.." }"
f:write( m ); f:flush(); f:close();
end


function NewUserConnected(curUser,sdata)
for _,Nick in frmHub:GetOnlineUsers() do
if curUser.sIP==Nick.sIP then
local det=function (User)
curUser:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..Nick.sName)
if kick~=0 then
User:SendPM(Bot,"You're being timebanned. Your IP: "..User.sIP)
User:TimeBan(kick)
if PmOps == "1" then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and timebanned for "..kick.." minutes. User is a clone of <"..Nick.sName..">")
end
else
User:SendPM(Bot,"You're being disconnected.")
user:Disconnect()
if PmOps == "1" then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and disconnected. User is a clone of <"..Nick.sName..">")
end
end
end
if not(tImmune[curUser.sName]== 1 or tImmune[Nick.sName]== 1) then -- and not (curUser.bOperator or Nick.bOperator)  <--- in NewUserConected it's always false
if curUser.iShareSize==Nick.iShareSize then
det(curUser)
if kick_other_too==1 then
det(Nick)
end
end
end
end
end
end




function ChatArrival (user,data)
if (user.bOperator) then
local data = string.sub( data, 1, -2 )
local s,e,cmd = string.find( data, "%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse( user, cmd, data, false )
end
end
end






function ToArrival ( user, data )
if ( user.bOperator ) then
local data = string.sub( data , 1, -2 )
local s,e, cmd = string.find( data , "%$%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse ( user, cmd , data , true )
end
end
end


function Parse( user, cmd, data, how )


local function SendBack( user, msg , from, how )
if how then user:SendPM( from or Bot , msg );return 1; end;
user:SendData( from or Bot, msg );return 1;
end


local t = {
--- Add to cloneList
["+clone"] = function ( user , data , how )
local s,e, name = string.find( data, "%b<>%s+%S+%s+(%S+)" )


if not name then user:SendData(Bot, "*** Error: Type +clone nick") end
if tImmune[name] then user:SendData("nope") end


local nick = GetItemByName(name)
if not nick then user:SendData(Bot, "*** Error: User is not online.") end


tImmune[name] = 1
OnExit()
user:SendData(Bot, name.." is now immune to clone checks!")
return 1


end ,


--- Remove from cloneList
["-clone"] = function ( user , data , how )
local s,e, name = string.find(data, "%b<>%s+%S+%s+(%S+)")


if not name then user:SendData(Bot, "*** Error: Type -clone nick") end
if not tImmune[name] then user:SendData(Bot,"The user "..victim.sName.." is not immune!")  end


local nick = GetItemByName( name )
if not nick then user:SendData(Bot, "*** Error: That user is not online.") end


tImmune[name] = nil
OnExit()
user:SendData(Bot,"Now "..name.." is not no longer immune to clone checks!")
return 1


end,


--- Show cloneList
["?clone"] = function ( user , data, how )


local m = ""
collectgarbage()
for nick, _ in tImmune do
local s = "Offline"
if GetItemByName(nick) then s = "Online" end
m = m.."\r\n\t  • ("..s..")  "..nick
end
if m == "" then return SendBack( user, "There are no users that can have a clone", Bot, how ) end
m = "\r\nThe following users can have clones in this hub:"..m
return SendBack( user, m , Bot, how )
end,
--- Show cloneBot help


["?clonehelp"] = function ( user, data , how )


local m = "\r\n\r\nHere are the commands for the CloneBot:"
m = m.."\r\n\t+clone \t allows to have a clone"
m = m.."\r\n\t-clone \t removes from the clone list"
m = m.."\r\n\t?clone\t\t shows the users allowed to have a clone"
m = m.."\r\n\t?clonehelp \t allows to have a clone"
return SendBack( user, m, Bot, how )


end, }


if t[cmd] then return t[cmd]( user, data, how ) end
end
Title:
Post by: Dessamator on 19 April, 2005, 20:13:21
lol, damn here we go again !!!, im sure some1 will find bugs, :D
Title:
Post by: bastya_elvtars on 19 April, 2005, 20:36:22
QuoteOriginally posted by Dessamator
lol, damn here we go again !!!, im sure some1 will find bugs, :D

Me too, as I only tested for syntax errors. :P
Title:
Post by: ConejoDelMal on 19 April, 2005, 22:15:05
dont worry, i will test it :P

got this when a clone is connecting with the same share, and nothing happens:
Syntax ...abalho\LusoLeader Hub 16.09 dbg\scripts\noclones.lua:50: attempt to index global `user' (a nil value)

if users have different share's, nothing happens, and the Op's arent notified

if user is in an allowed clone, he is accepted without errors, tables save fine....all cmd's work normal

i think thats it for now...
Title:
Post by: bastya_elvtars on 19 April, 2005, 22:57:59
Find this:

user:Disconnect()
and edit so it will be

User:Disconnect()
:D
Title:
Post by: Dessamator on 19 April, 2005, 23:59:51
QuoteOriginally posted by [AT]conejodelmal

if users have different share's, nothing happens, and the Op's arent notified


change this ::
if PmOps == "1" then

to this::
if PmOps == true then
Title:
Post by: ConejoDelMal on 20 April, 2005, 13:55:57
edited like both said, testing report:

kick_other_too=1 , not working

If a clone from an Op who is in the hub tries to get in, gets disconnected, Op's never get disconnected (i just think that there is no reason to disconnect clones from an Op)

And isnt it better to notify Op's when there are clones with different share sizes? (for security reasons i mean)
Title:
Post by: Dessamator on 20 April, 2005, 15:24:21
QuoteOriginally posted by [AT]conejodelmal
edited like both said, testing report:

kick_other_too=1 , not working

well that works fine here, mayb u did something wrong
QuoteIf a clone from an Op who is in the hub tries to get in, gets disconnected, Op's never get disconnected (i just think that there is no reason to disconnect clones from an Op)

And isnt it better to notify Op's when there are clones with different share sizes? (for security reasons i mean)

well both of those solved

just change this::


if not(tImmune[curUser.sName]== 1 or tImmune[Nick.sName]== 1) then -- and not (curUser.bOperator or Nick.bOperator)  <--- in NewUserConected it's always false
if curUser.iShareSize==Nick.iShareSize then
det(curUser)
if kick_other_too==1 then
det(Nick)
end
end
end
     


to this :::

       
if not(tImmune[curUser.sName]== 1 or tImmune[Nick.sName]== 1)  and not(Nick.bOperator)  then if curUser.iShareSize==Nick.iShareSize then
det(curUser)
if kick_other_too==1 then
det(Nick)
end
else
if PmOps == true then
SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..Nick.sName.." but with different share, please check.")
end
end
end



ps. each op can only have 1 clone, otherwise ull just have to add "immunity" to the other nicks !!
Title:
Post by: jiten on 20 April, 2005, 17:37:32
Can u guys post the final modded script so that other users don't have to look for pieces here and there? :D

Cheers
Title:
Post by: Dessamator on 20 April, 2005, 18:08:58
QuoteOriginally posted by jiten
Can u guys post the final modded script so that other users don't have to look for pieces here and there? :D

Cheers

lol, ok here it goes ::


-- Clone Alert 1.6
-- 1.0b by Mutor The Ugly
-- PM Clone login to Opchat
-- Applied to latest PtokaX by bastya_elvtars
-- Also added share checking, if different, only notifies ops.
--thx NightLitch
-- Added: Clone check immunity (add, remove and list immune users) by jiten
--- -- touched by Herodes
-- heavily optimised
-- moved to 1.5
-- now it's 1.6, after bastya_elvtars did some more optimization to the detector. :P


OpChatName = "OpChat"  -- Rename to opchatbot
Bot = "botname" -- Rename to you main Px bot
kick=0 -- 0 to only disconnect, otherwise enter a number, and user will be kicked for that amount of minutes.
kick_other_too=0 -- 1 to disconnect/kick the already logged in user, 0 to not
PmOps = false -- true:enables / false:disables , operator notifincation (STRONGLY recommended to leave enabled!)


function Main()
tImmune = {}
if loadfile("logs/cloneimmune.txt") then dofile("logs/cloneimmune.txt"); end
end


function OnExit()
collectgarbage()
local f = io.open("logs/cloneimmune.txt", "w+")
local m = "tImmune = { "
for a, b in tImmune do m = m..(string.format("[%q]=",a)..b..","); end
m = m.." }"
f:write( m ); f:flush(); f:close();
end


function NewUserConnected(curUser,sdata)
for _,Nick in frmHub:GetOnlineUsers() do
if curUser.sIP==Nick.sIP then
local det=function (User)
curUser:SendPM(Bot,"Double Login is not allowed. You are already connected to this hub with this nick: "..Nick.sName)
if kick~=0 then
User:SendPM(Bot,"You're being timebanned. Your IP: "..User.sIP)
User:TimeBan(kick)
if PmOps == true then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and timebanned for "..kick.." minutes. User is a clone of <"..Nick.sName..">")
end
else
User:SendPM(Bot,"You're being disconnected.")
User:Disconnect()
if PmOps == true then
SendPmToOps(OpChatName, "*** Cloned user <"..curUser.sName.."> ("..curUser.sIP..") logged in and disconnected. User is a clone of <"..Nick.sName..">")
end
end
end
if not(tImmune[curUser.sName]== 1 or tImmune[Nick.sName]== 1)  and not(Nick.bOperator)  then
if curUser.iShareSize==Nick.iShareSize then
det(curUser)
if kick_other_too==1 then
det(Nick)
end
else
if PmOps == true then
SendPmToOps(OpChatName, "*** User "..curUser.sName.." logged in, with same IP as "..Nick.sName.." but with different share, please check.")
end
end
end
end
end
end

function ChatArrival (user,data)
if (user.bOperator) then
local data = string.sub( data, 1, -2 )
local s,e,cmd = string.find( data, "%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse( user, cmd, data, false )
end
end
end

function ToArrival ( user, data )
if ( user.bOperator ) then
local data = string.sub( data , 1, -2 )
local s,e, cmd = string.find( data , "%$%b<>%s+([%-%+%?]%S+)" )
if cmd then
return Parse ( user, cmd , data , true )
end
end
end

function Parse( user, cmd, data, how )

local function SendBack( user, msg , from, how )
if how then user:SendPM( from or Bot , msg );return 1; end;
user:SendData( from or Bot, msg );return 1;
end

local t = {
--- Add to cloneList
["+clone"] = function ( user , data , how )
local s,e, name = string.find( data, "%b<>%s+%S+%s+(%S+)" )


if not name then user:SendData(Bot, "*** Error: Type +clone nick") end
if tImmune[name] then user:SendData("nope") end


local nick = GetItemByName(name)
if not nick then user:SendData(Bot, "*** Error: User is not online.") end


tImmune[name] = 1
OnExit()
user:SendData(Bot, name.." is now immune to clone checks!")
return 1


end ,


--- Remove from cloneList
["-clone"] = function ( user , data , how )
local s,e, name = string.find(data, "%b<>%s+%S+%s+(%S+)")


if not name then user:SendData(Bot, "*** Error: Type -clone nick") end
if not tImmune[name] then user:SendData(Bot,"The user "..victim.sName.." is not immune!")  end


local nick = GetItemByName( name )
if not nick then user:SendData(Bot, "*** Error: That user is not online.") end


tImmune[name] = nil
OnExit()
user:SendData(Bot,"Now "..name.." is not no longer immune to clone checks!")
return 1


end,


--- Show cloneList
["?clone"] = function ( user , data, how )


local m = ""
collectgarbage()
for nick, _ in tImmune do
local s = "Offline"
if GetItemByName(nick) then s = "Online" end
m = m.."\r\n\t  • ("..s..")  "..nick
end
if m == "" then return SendBack( user, "There are no users that can have a clone", Bot, how ) end
m = "\r\nThe following users can have clones in this hub:"..m
return SendBack( user, m , Bot, how )
end,
--- Show cloneBot help


["?clonehelp"] = function ( user, data , how )


local m = "\r\n\r\nHere are the commands for the CloneBot:"
m = m.."\r\n\t+clone \t allows to have a clone"
m = m.."\r\n\t-clone \t removes from the clone list"
m = m.."\r\n\t?clone\t\t shows the users allowed to have a clone"
m = m.."\r\n\t?clonehelp \t allows to have a clone"
return SendBack( user, m, Bot, how )


end, }


if t[cmd] then return t[cmd]( user, data, how ) end
end
       
Title:
Post by: jiten on 20 April, 2005, 18:16:32
;)