PtokaX forum

Archive => Archived 5.1 boards => Request for scripts => Topic started by: swee on 10 August, 2007, 21:16:06

Title: Registered only
Post by: swee on 10 August, 2007, 21:16:06
I would like an script which made it possible for ppl who are on reg hubbs only.
So if I am on a public hub I would get an warning or be kicked.
I dont mind if there are ppl who are on several Reg hubs but if  they  are on one Public.
Would be nice if the script could kick after some seconds.
Iknow it is in the tag but if ops isnt around.
Is it possible ?
Thanx in advance

Thought i seen it around here but couldnt find any.
Regards swee
Title: Re: Registered only
Post by: swee on 11 August, 2007, 18:33:10
thank u very much Mutor for your fast reply.
got it running what does this mean ?
188: attempt to perform arithmetic on a nil value


regards swee
Title: Re: Registered only
Post by: swee on 25 August, 2007, 15:01:39
Oki will give it a go  ::)
And thanx for the script.
reagards swee
Title: Re: Registered only
Post by: ExtreeM on 10 December, 2007, 19:45:09
hmmm i get this error

[19:44] Syntax no p hub.lua:35: attempt to index global 'frmHub' (a nil value)

???

hmmm i use the new Ptokax, maybe this is not made for the new Ptokax yet???
Title: Re: Registered only
Post by: speedX on 10 December, 2007, 20:24:23
Quote from: ExtreeM on 10 December, 2007, 19:45:09
hmmm i get this error

[19:44] Syntax no p hub.lua:35: attempt to index global 'frmHub' (a nil value)

???

hmmm i use the new Ptokax, maybe this is not made for the new Ptokax yet???

This script is Lua 5.x, so if u r using the new PtokaX API thn it wont work.
Title: Re: Registered only
Post by: ExtreeM on 11 December, 2007, 06:31:27

QuoteSo this version is for the old API and won't work for the new API.
I will however, provide one for the new API soon.

Nice m8 i?ll be looking forward to that :D
Title: Re: Registered only
Post by: ExtreeM on 15 December, 2007, 08:01:13
--[[
NoPubHub 1.0d LUA 5.0/5.1

By Mutor        07/18/06

Requested by WingZero

Block connections from users in public hubs

- Messages user before disconnect. [set pubmsg ~line 27]
- Block / Exclude by profile [set Exclude table ~line 18]
- Checks in MyINFOArrival to detect public connections made after login

Changes from 1.0 10/29/06 Request by hund
-Removed disconnect public hub user
+Added check for Cfg.OpChat, enable if disabled
+Added report public hub user login to OpChat

Changes from 1.0b 11/23/06
+Added excluded by nick
+Added option to disconnect/timeban public user(s),  request by Blixten?
+Added context menus [right click]
+Added save excluded nicks table to file for script/hub restarts

Changes from 1.0c 11/24/06 Request by Blixten?
+Added perm ban option for single public hub attempt [not reccommended]
+Added perm ban option for 'x' public hub attempts
+Added save banned table to file for script/hub restarts
]]

Cfg = {
-- Admins nick for status / error messages
OpNick = "Mutor",
-- Botname pulled from the hub or use "#.XXXXXX"
PubBot = frmHub:GetHubBotName(),
-- Should bot have a key?
BotIsOp = 1,
--Bot description
BotDesc = "I check user public hub status",
--Bot Email address
BotMail = "user@domain.com",
--Context Menu Title
Menu = frmHub:GetHubName(),
--Context Submenu Title
SubMenu = "NoPubHub 1.0d",
-- File to save exlusion table
File = "PubExclude.dat",
-- File to save ban table
BanFile = "PubBans.dat",
--User Penalty:
-- 0=None, Inform Ops Only,
-- 1=Disconnect Users, Inform Ops,
-- 2 = TimeBan Users, Inform Ops,
-- 3 = IP ban, inform Ops
Penalty = 3,
--TempBan time in minutes, 0 = default tempban time from GUI
BanTime = 30,
--Permanently ban users after this amount of tempbans [0 = disable permanent ban]
BanCount = 3,
--Allow Commands
-- [#] = 0/1, (0 = Commands Disabled, 1 = Commands Enabled)
Profiles  = {
[-1] = {0,"Unregistered User"},
[0] = {1,"Master"},
[1] = {0,"Operator"},
[2] = {0,"Vip"},
[3] = {0,"Registered User"},
[4] = {0,"Moderator"},
[5] = {0,"NetFounder"},
[6] = {0,"Lord&Maker"},
},
--Exclude Profiles
--[#] = {0=check/1=Cfg.ExcludeProfiles, "Profile Name"},
ExcludeProfiles = {
[-1] = {0,"Unregistered User"},
[0] = {1,"Master"},
[1] = {1,"Operator"},
[2] = {0,"Vip"},
[3] = {0,"Registered User"},
[4] = {0,"Moderator"},
[5] = {0,"NetFounder"},
[6] = {0,"Owner"},
},
--Exclude By NickName
ExcludeNicks = {
["Mutor"] = 0,
["OtherNick"] = 0,
},
}

Main  = function()
Cfg.OpChat = "Cfg.OpChat"
if frmHub:GetOpChat() == 1 then
Cfg.OpChat = frmHub:GetOpChatName()
else
frmHub:SetOpChatData(Cfg.OpChat,"Operators Chat Room",Cfg.BotMail)
frmHub:SetOpChat(1)
RegBot(Cfg.OpChat)
end
if Cfg.PubBot ~= frmHub:GetHubBotName() or frmHub:GetHubBot()== 0 then
frmHub:RegBot(Cfg.PubBot, 1, Cfg.Desc.." PtokaX ".._VERSION, Cfg.Mail)
end
local LuaVer = string.sub(_VERSION,1,7)
if LuaVer == "Lua 5.1" then
gc,no,pat,mem = "collect",table.maxn,string.gmatch,collectgarbage("count")
elseif LuaVer == "Lua 5.0" then
gc,no,pat,mem = nil,table.getn,string.gfind,gcinfo()
else
OnError("This script is incompatible with ".._VERSION)
end
mem = string.format("%-.2f Kb.",mem)
if loadfile(Cfg.File) then
dofile(Cfg.File)
else
Save_File(Cfg.File,Cfg.ExcludeNicks,"Cfg.ExcludeNicks")
end
if loadfile(Cfg.BanFile) then
dofile(Cfg.BanFile)
else
Cfg.Banned = {}
Save_File(Cfg.BanFile,Cfg.Banned,"Cfg.Banned")
end
collectgarbage(gc)
OnError("NoPubHub 1.0d ".._VERSION.." by Mutor has been started, using "..mem.." of memory.")
end

OnExit = function()
OnError("NoPubHub 1.0d for ".._VERSION.." by Mutor has been stopped.")
end

OnError = function(msg)
SendToNick(Cfg.OpNick,"<"..Cfg.PubBot.."> "..msg)
end

function NewUserConnected(user, data)
if Cfg.Profiles[user.iProfile] and Cfg.Profiles[user.iProfile][1] == 1 then
SendPubCmds(user)
local prof = GetProfileName(user.iProfile) or "Unregistered User"
local msg = "Welcome "..user.sName..", "..prof.."'s NoPubHub 1.0d commands "..
"enabled. Right click hub tab or user list for menu."
user:SendData(Cfg.PubBot,msg)
end
end
OpConnected = NewUserConnected

ChatArrival = function(user, data)
if Cfg.Profiles[user.iProfile] and Cfg.Profiles[user.iProfile][1] == 1 then
local s,e,to = string.find(data,"^$To:%s(%S+)%sFrom:")
local s,e,cmd = string.find( data, "%b<>%s%p(%w+)")
if cmd and PubCmds[cmd] then
if to and to == Cfg.PubBot then
user:SendPM(Cfg.PubBot,PubCmds[cmd](user,data,cmd))
else
user:SendData(Cfg.PubBot,PubCmds[cmd](user,data,cmd))
end
return 1
end
end
end
ToArrival = ChatArrival

MyINFOArrival = function(user,data)
local Prof = GetProfileName(user.iProfile) or "Unregistered User"
local PubMsg = frmHub:GetHubName().." asks that you not be connected to public hubs.\r\n\r\n"
local OpMsg = "The "..Prof.." "..user.sName..", is connected to "..user.iNormalHubs.." public hub(s)."
if not Cfg.ExcludeProfiles[user.iprofile] or Cfg.ExcludeProfiles[user.iprofile][1] ~= 1 then
if not Cfg.ExcludeNicks[user.sName] or Cfg.ExcludeNicks[user.sName] ~= 1 then
if user.iNormalHubs ~= 0 then
if Cfg.Penalty == 0 then
PubMsg = PubMsg.."\t***Online operators have been informed of your "..
"public hub connection status.***\r\n\r\n"
return user:SendData(frmHub:GetHubName(),PubMsg),
SendPmToOps(Cfg.OpChat,OpMsg)
elseif Cfg.Penalty == 1 then
PubMsg = PubMsg.."\tYou will now be disconnected. "..
"Please logout of any public hubs before you return.\r\n\r\n"
OpMsg = OpMsg.." "..user.sName.." has been disconnected from the hub."
elseif Cfg.Penalty == 2 then
local Period = Cfg.BanTime
if Period == 0 then
Period = frmHub:GetDefaultTempBanTime()
end
if Cfg.BanCount > 0 then
if not Cfg.Banned[user.sName] then
Cfg.Banned[user.sName] = 1
local limit = Cfg.BanCount - Cfg.Banned[user.sName]
PubMsg = PubMsg.."\tYou will now be disconnected.and temporarily "..
"banned for "..Period.." minutes.\r\n"..
"\tYou have been warned "..Cfg.Banned[user.sName].." times. "..limit..
" more attempts, and you will be perm banned.\r\n\r\n"
OpMsg = OpMsg.." "..user.sName.." has been time banned "..
Cfg.Banned[user.sName].." times. "..limit.." more attempts, and "..
user.sName.." will be perm banned."
TempBan(user.sIP,Period,"Connection To Public Hubs",Cfg.PubBot,0)
else
Cfg.Banned[user.sName] = Cfg.Banned[user.sName] + 1
if Cfg.Banned[user.sName] >= Cfg.BanCount then
Ban(user.sIP,"Attempted Connection To Public Hubs > "..
Cfg.BanCount.." times.",Cfg.PubBot,0)
Cfg.Banned[user.sName] = nil
PubMsg = PubMsg.."\tYou have been warned "..Cfg.BanCount.." times "..
"about connection to public hubs.\r\n"..
"\tYou will now be permanently IP banned.\n\r\n"
OpMsg = OpMsg.." "..user.sName.." has been permanently "..
"IP banned. for connection to public hubs "..
Cfg.BanCount.." times."
else
local limit = Cfg.BanCount - Cfg.Banned[user.sName]
PubMsg = PubMsg.."\tYou will now be disconnected.and temporarily "..
"banned for "..(GetTempBannedItemTime(user.sIP)/60).." minutes.\r\n"..
"\tYou have been warned "..Cfg.Banned[user.sName].." times. "..limit..
" more attempts, and you will be perm banned.\r\n\r\n"
OpMsg = OpMsg.." "..user.sName.." has been time banned "..
Cfg.Banned[user.sName].." times. "..limit.." more attempts, and "..
user.sName.." will be perm banned."
TempBan(user.sIP,Period,"Connection To Public Hubs",Cfg.PubBot,0)
end
end
Save_File(Cfg.BanFile,Cfg.Banned,"Cfg.Banned")
else
OpMsg = OpMsg.." "..user.sName.." has been timebanned for "..Period.." minutes."
end
elseif Cfg.Penalty == 3 then
Ban(user.sIP,"Connection To Public Hubs",Cfg.PubBot,0)
PubMsg = PubMsg.."\tYou will now be permanently IP banned.\n\r\n"
OpMsg = OpMsg.." "..user.sName.." has been permanently "..
"IP banned. for connection to public hubs."
end
return user:SendData(frmHub:GetHubName(),PubMsg),
user:Disconnect(),
SendPmToOps(Cfg.OpChat,OpMsg),1
end
end
end
end

SendPubCmds = function(user)
for i,v in pairs(PubCmds) do
local desc,arg1,arg2 = PubCmds[i]()
user:SendData("$UserCommand 1 1 "..Cfg.Menu.."\\"..Cfg.SubMenu.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;")
user:SendData("$UserCommand 1 2 "..Cfg.Menu.."\\"..Cfg.SubMenu.."\\"..
desc.."$$To: %[nick] From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;")
collectgarbage(gc)
end
end

PubCmds = {
pubadd = function(user,data,cmd)
if user then
local s,e,nick = string.find( data, "%b<>%s%p%w+%s(%S+)|")
if not nick then
return "Error!, Usage: "..frmHub:GetPrefixes()[1]..cmd.." <nick>"
else
if not Cfg.ExcludeNicks[nick] then
Cfg.ExcludeNicks[nick] = 1
Save_File(Cfg.File,Cfg.ExcludeNicks,"Cfg.ExcludeNicks")
return user.sName..", "..nick.." has been added "..
"to the exlusion table, "..Cfg.File.." has been updated."
else
return "Sorry "..user.sName..", "..nick.." is already excluded."
end
end
else
return "Add Excluded User", " %[line:NickName]"," %[nick]"
end
end,
pubdel = function(user,data,cmd)
if user then
local s,e,nick = string.find( data, "%b<>%s%p%w+%s(%S+)|")
if not nick then
return "Error!, Usage: "..frmHub:GetPrefixes()[1]..cmd.." <nick>"
else
if Cfg.ExcludeNicks[nick] then
Cfg.ExcludeNicks[nick] = nil
Save_File(Cfg.File,Cfg.ExcludeNicks,"Cfg.ExcludeNicks")
return user.sName..", "..nick.." has been removed "..
"from the exclusion table, "..Cfg.File.." has been updated."
else
return "Sorry "..user.sName..", "..nick.." does not exist in "..
"the exclusion table."
end
end
else
return "Remove Excluded User", " %[line:NickName]"," %[nick]"
end
end,
publist = function(user,data,cmd)
if user then
local reply = "Auto Block User Exlusions\r\n\t\r\n\t"..string.rep("?",30).."\r\n"
for i,v in pairs(Cfg.ExcludeNicks) do
reply = reply.."\t+"..string.format("%-15s",i).."\r\n"
end
return reply.."\n\t"..string.rep("?",30).."\r\n\r\n"
else
return "List Excluded Users","",""
end
end,
pubhelp = function(user,data,cmd)
if user then
local reply = "NoPubHub Help\n\n\tCommand\t\tDescription\r\n"..
"\t"..string.rep("?",40).."\r\n"
for i,v in pairs(PubCmds) do
local desc,args = PubCmds[i]()
reply = reply.."\t+"..string.format("%-15s",i).."\t"..desc.."\r\n"
end
return reply.."\n\t"..string.rep("?",40).."\r\n\r\n"
else
return "NoPubHub Help [*This Info]","",""
end
end,
}

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in pairs(tTable) do
local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key)
if(type(value) == "table") then
Save_Serialize(value, sKey, hFile, sTab.."\t")
else
local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value)
hFile:write( sTab.."\t"..sKey.." = "..sValue)
end
hFile:write( ",\n")
end
hFile:write( sTab.."}")
end

Save_File = function(file,table, tablename )
local hFile = io.open (file , "wb")
Save_Serialize(table, tablename, hFile)
hFile:close()
collectgarbage(gc)
end


there is no delete command, the script makes a double when reconnecting or is it just me??
Title: Re: Registered only
Post by: ExtreeM on 15 December, 2007, 09:15:53
QuoteWhat do you mean double? Double what?

well when you reconnect the right click menu appears twice, sry for the code, thougt it was me

http://imageshack.dk//viewimage.php?file=/imagesfree/KrV06935.jpg

there is a screenshot :D
Title: Re: Registered only
Post by: ExtreeM on 15 December, 2007, 19:04:01
thx mutor again and again ;)
Title: Re: Registered only
Post by: ExtreeM on 16 December, 2007, 14:23:25
Mutor im still new at this :(

How do the script work, should i put it into all the other scripts or does it work as seperat script? i triyed to add it as a normal script and moved it to the TOP in ptokax script editor, is this the wrong way to do it, it didnt work hehe
Title: Re: Registered only
Post by: ExtreeM on 16 December, 2007, 23:03:56
Mutor i dont now if its me or what, but cant seem to find anything about "clear menu" in PxCommands 1.1b Lite Ed. LUA 5.1 [Strict]
Title: Re: Registered only
Post by: ExtreeM on 16 December, 2007, 23:27:41
ohh my good Mutor im really really sorry, damn i a big noob LOL, i think i need glasses m8, i think im just a little bit confused about the whole thing atm, all of the things is new for me and i always have a 1000 question here at start.