determinate determinate

Author Topic: PM Block 1.0c LUA 5.1 [Strict] [API 2]  (Read 2105 times)

0 Members and 1 Guest are viewing this topic.

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
PM Block 1.0c LUA 5.1 [Strict] [API 2]
« on: June 17, 2009, 01:06:28 am »
Code: [Select]
--[[

PM Block 1.0c LUA 5.1 [Strict] [API 2]

By Mutor 07/14/07

Requested by TwîsTèd-dèvîl


Blocks / Unblocks user PM's by command.
-Provides commands/protection by profile or op nick
-Block auto-cleared after block time elapsed [+/- 1 min.]
-Can block/unblock all [non-protected] online nicks
-Can block / unblock offline nicks
-Cannot block / unblock own nick
-Provides context menu [right click]
-Blocked user list saved to file for hub/script restart

+Changes from 1.0
+Added auto clear after interval

+Changes from 1.0b
~Converted to API 2 strict


PM Block Command Help

Command Description
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+pmbhelp        PM Block Command Help
+block          Block This User's PM's
+blockall       Block All User's PM's
+unblock        Unblock This User's PM
+unblockall     Unblock All User's PM's
+pmblist        List PM Blocked Users

ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

]]

PbCfg = {
-- Botname pulled from the hub or use "CustomName"
Bot = SetMan.GetString(21),
-- Should bot have a key?
BotIsOp = true,
-- Bot description
BotDesc = "Private Message Blocker",
-- Bot Email address
BotMail = "user@domain.com",
-- Admins nick for status/error messages
OpNick = "Mutor",
-- Send verbose script messages to OpNick? ["yes","no"]
Verbose = "yes",
-- File to save config/user table
File = "Blocked.dat",
-- Context Menu Title
Menu = SetMan.GetString(0),
-- Context Submenu Title
SubMenu = "PM Block",
--Block time [in minutes] after which users will be automatically unblocked.
BlockTime = 30,
--Set your profiles permissions here.
--[profile #] = {Commands enabled? [0=no 1=yes], "Custom Profile Name"}
Profiles = {
[-1] = {false,"Unregistered User"},
[0] = {true,"Master"},
[1] = {true,"Operator"},
[2] = {false,"Vip"},
[3] = {false,"Registered User"},
[4] = {false,"Moderator"},
[5] = {true,"NetFounder"},
[6] = {true,"Owner"},
},
Exclude = {"Nick1","Nick2"},
}

local Script = "PM Block 1.0c"
OnStartup = function()
Timer = TmrMan.AddTimer(6000)
if loadfile(PbCfg.File) then
dofile(PbCfg.File)
else
PbCfg.Blocked = {}
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
end
if PbCfg.Bot ~= SetMan.GetString(21) then
Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,PbCfg.BotIsOp)
end
local hc = {SetMan.GetOpChat().sNick,Core.GetHubSecAlias()}
for i,v in ipairs(hc) do
if not CheckExclude(v) then
table.insert(PbCfg.Exclude,v)
end
end
OnError(Script.." for ".._VERSION.." by Mutor has been started.")
end

OnTimer =  function()
local Now,Change = os.time()
for i,v in ipairs(PbCfg.Blocked) do
if ((Now - v[2]) / 60) > PbCfg.BlockTime then
Change = true
if PbCfg.Verbose:lower() == "yes" then
OnError(v[1].." has been removed from blocked pm users.")
end
table.remove(PbCfg.Blocked,i)
end
end
if Change then
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
end
end

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

OnError = function(msg)
local user = Core.GetUser(PbCfg.OpNick)
if user then
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..msg.."|")
end
end

UserConnected = function(user,data)
if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] or
user.sNick:lower() == PbCfg.OpNick:lower() then
local Profile = PbCfg.Profiles[user.iProfile][2] or "Undefined Profile"
SendBlockCmds(user)
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..Profile.."'s "..Script.." commands enabled. "..
"Right click hub tab or user list for a command menu.|")
end
end
OpConnected,RegConnected = UserConnected,UserConnected

ChatArrival = function(user, data)
local _,_,to = data:find("^$To: (%S+) From:")
if to and CheckBlock(user.sNick) then
local msg = "Your PM's are blocked! It is senseless to try to speak."
return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
elseif to and CheckBlock(to) then
if not CheckExclude(to) then
local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! "..
to.." may receive a message but cannot respond."
return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
end
else
if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] or
user.sNick:lower() == PbCfg.OpNick:lower() then
local _,_,cmd = data:find("%b<> %p(%w+)")
if cmd and BlockCmds[cmd] then
if to and to:lower() == PbCfg.Bot:lower() then
Core.SendPmToUser(user,PbCfg.Bot,BlockCmds[cmd](user,data).."|")
else
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data).."|")
end
return true
end
end
end
end
ToArrival = ChatArrival

CheckBlock = function(nick)
for i,v in ipairs(PbCfg.Blocked) do
if v[1]:lower() == nick:lower() then
return i
end
end
return nil
end

CheckExclude = function(nick)
if next(PbCfg.Exclude) then
for i,v in ipairs(PbCfg.Exclude) do
if v:lower() == nick:lower() then
return i
end
end
end
return nil
end

BlockCmds = {
block = function(user,data)
if user then
local _,_,nick = data:find("%b<> %p%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..SetMan.GetString(29):sub(1,1)..
"block <nick>"
else
if nick == user.sNick then
return "You cannot block yourself "..user.sNick..". Dont be a fool!"
end
local usr = Core.GetUser(nick)
if usr and PbCfg.Profiles[usr.iProfile] and PbCfg.Profiles[usr.iProfile][1] == 1 then
return "You cannot block "..PbCfg.Profiles[usr.iProfile][2].." "..usr.sNick..
", "..PbCfg.Profiles[usr.iProfile][2].."'s are protected from block."
end
if usr and usr.sNick:lower() == PbCfg.OpNick:lower() then
return PbCfg.OpNick.." is protected and may not be blocked."
end
if CheckBlock(nick) then
return "The user: "..nick.." has already been blocked."
else
table.insert(PbCfg.Blocked,{nick,os.time()})
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
local status = "offline"
if usr then
status,nick = "online",usr.sNick
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. "..
"You may not speak in private message.")
end
return "The "..status.." user: "..nick.." is now "..
"blocked and cannot speak in private message."
end
end
else
return "Block This User's PM's"," %[line:Nickname]"," %[nick]"
end
end,
blockall = function(user,data)
if user then
local Now,Count,Change = os.time(),0,false
for i,usr in ipairs(Core.GetOnlineUsers()) do
if not PbCfg.Profiles[usr.iProfile] or not PbCfg.Profiles[usr.iProfile][1] then
if usr.sNick:lower() ~= PbCfg.OpNick:lower() then
Count = Count + 1
Change = true
local x = CheckBlock(usr.sNick)
if x then
PbCfg.Blocked[x][2] = Now
else
table.insert(PbCfg.Blocked,{usr.sNick,Now})
end
end
end
end
if Change then
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
end
local status = "No"
if Count > 0 then
status = Count
end
return status.." users were added to or updated in the pm block table."
else
return "Block All User's PM's","",""
end
end,
unblock = function(user,data)
if user then
local _,_,nick = data:find("%b<> %p%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..SetMan.GetString(29):sub(1,1)..
"unblock <nick>"
else
if nick:lower() == user.sNick:lower() then
return "You cannot unblock yourself "..user.sNick..
". What fun would that be?"
end
local Block = CheckBlock(nick)
if not Block then
return "The user: "..nick.." has not been blocked."
else
table.remove(PbCfg.Blocked,Block)
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
local status,usr = "offline",Core.GetUser(nick)
if usr then
status = "online"
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been "..
"unblocked. You may now speak in private message again.")
end
return "The "..status.." user: "..nick.." is unblocked "..
"and can now speak in private message again."
end
end
else
return "Unblock This User's PM"," %[line:Nickname]"," %[nick]"
end
end,
unblockall = function(user,data)
if user then
PbCfg.Blocked = {}
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
return "All user PM's are now unblocked"
else
return "Unblock All User's PM's","",""
end
end,
pmblist = function(user,data)
if user then
if next(PbCfg.Blocked) then
local Count = 0
local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n"..
"\t"..string.rep("Ż",40).."\r\n"
for i,v in ipairs(PbCfg.Blocked) do
reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n"
end
return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n"
else
return "There are no users blocked at this time."
end
else
return "List PM Blocked Users","",""
end
end,
pmbhelp = function(user,data)
if user then
local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
"\t"..string.rep("Ż",40).."\r\n"
for i,v in pairs(BlockCmds) do
local desc,args = BlockCmds[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 "PM Block Command Help","",""
end
end,
}

SendBlockCmds = function(user)
for i,v in pairs(BlockCmds) do
local desc,arg1,arg2 = BlockCmds[i]()
Core.SendToUser(user,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToUser(user,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
collectgarbage("collect")
end
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in ipairs(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:flush() hFile:close()
collectgarbage("collect")
end
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline †StIfFLEr†™

  • Lord
  • ***
  • Posts: 272
  • Karma: +15/-62
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #1 on: June 17, 2009, 09:34:26 am »
Quote
Mutor there is a script made by you which Blocks the PM of User.
I have been using it.If a User's PM is Blocked by and operator,The user can,t PM any of the Hub Users.
Can it be added with a Function where in a User's PM is Blocked to only a user Who has blocked that users PM whereafter user can PM any other User but not the one who has Blocked it.

----
For Reged Users can a function be added where in they can request to Operators and masters to Block the PM of a User for them.After the request a message should be sent to all operators and Masters.
----

Unblock the Individual PM block option.
And...
All the above configuration once made should be saving to a file
Can The above script be updated with the required Function.

Offline †StIfFLEr†™

  • Lord
  • ***
  • Posts: 272
  • Karma: +15/-62
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #2 on: June 18, 2009, 07:17:55 pm »
No Reply Sadness. ???

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
PM Block 1.0d LUA 5.1 [Strict] [API 2]
« Reply #3 on: June 21, 2009, 09:46:24 pm »
Tested some, but not a great deal.

Code: [Select]
--[[

PM Block 1.0d LUA 5.1 [Strict] [API 2]

By Mutor 07/14/07

Requested by TwîsTèd-dèvîl


Blocks / Unblocks user PM's by command.
-Provides commands/protection by profile or op nick
-Block auto-cleared after block time elapsed [+/- 1 min.]
-Can block/unblock all [non-protected] online nicks
-Can block / unblock offline nicks
-Cannot block / unblock own nick
-Provides context menu [right click]
-Blocked user list saved to file for hub/script restart

+Changes from 1.0
+Added auto clear after interval

+Changes from 1.0b
~Converted to API 2 strict

+Changes from 1.0c 06/21/09
+Added commands/function to support blocking pm's from specific nicks


PM Block Command Help

Command Description
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+pmbhelp        PM Block Command Help
+block          Block This User's PM's
+blockall       Block All User's PM's
+unblock        Unblock This User's PM
+unblockall     Unblock All User's PM's
+pmblist        List PM Blocked Users

ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

]]

PbCfg = {
-- Name for bot ["" = Hub Bot]
Bot = "",
-- Should bot have a key?
BotIsOp = true,
-- Bot description
BotDesc = "Private Message Blocker",
-- Bot Email address
BotMail = "user@domain.com",
-- Admins nick for status/error messages
OpNick = "Mutor",
-- Send verbose script messages to OpNick? ["yes","no"]
Verbose = "yes",
-- File to save config/user table
File = "Blocked.dat",
-- File to save nickname table
NickFile = "BlockedNicks.dat",
-- Command Menu Title ["" = Hub Name]
Menu = "",
-- Command SubMenu Title ["" = Script Name]
SubMenu = "",
--Block time [in minutes] after which users will be automatically unblocked.
BlockTime = 30,
--Set your profiles permissions here.
--[profile #] = {Commands enabled? [true/false], "Profile Name"}
Profiles = {
[-1] = {false,"Unregistered User"},
[0] = {true,"Master"},
[1] = {true,"Operator"},
[2] = {false,"Vip"},
[3] = {false,"Registered User"},
},
Exclude = {"Nick1","Nick2"},
}


OnStartup = function()
Path,Script = Core.GetPtokaXPath().."scripts/","PM Block 1.0d"
PbCfg.Pfxs = SetMan.GetString(29)
PbCfg.Pfx = PbCfg.Pfxs:sub(1,1)
Timer = TmrMan.AddTimer(6000)
if PbCfg.Bot == "" then PbCfg.Bot = SetMan.GetString(21) end
if PbCfg.Menu == "" then PbCfg.Menu = SetMan.GetString(0) end
if PbCfg.SubMenu == "" then PbCfg.SubMenu = Script end
if not PbCfg.File:find("^"..Path,1,true) then PbCfg.File = Path..PbCfg.File end
if not PbCfg.NickFile:find("^"..Path,1,true) then PbCfg.NickFile = Path..PbCfg.NickFile end
if loadfile(PbCfg.File) then
dofile(PbCfg.File)
else
PbCfg.Blocked = {}
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
end
if loadfile(PbCfg.NickFile) then
dofile(PbCfg.NickFile)
else
PbCfg.Nicks = {}
Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
end
if PbCfg.Bot ~= SetMan.GetString(21) then
Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,PbCfg.BotIsOp)
end
local hc = {SetMan.GetOpChat().sNick,Core.GetHubSecAlias()}
for i,v in ipairs(hc) do
if not CheckExclude(v) then
table.insert(PbCfg.Exclude,v)
end
end
OnError(Script.." for ".._VERSION.." by Mutor has been started.")
end

OnTimer =  function()
local Now,Change = os.time()
for i,v in ipairs(PbCfg.Blocked) do
if ((Now - v[2]) / 60) > PbCfg.BlockTime then
Change = true
if PbCfg.Verbose:lower() == "yes" then
OnError(v[1].." has been removed from blocked pm users.")
end
table.remove(PbCfg.Blocked,i)
end
end
if Change then
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
end
end

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

OnError = function(msg)
local user = Core.GetUser(PbCfg.OpNick)
if user then
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..msg.."|")
end
end

UserConnected = function(user,data)
if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] or
user.sNick:lower() == PbCfg.OpNick:lower() then
local Profile = PbCfg.Profiles[user.iProfile][2] or "Undefined Profile"
SendBlockCmds(user)
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..Profile.."'s "..Script.." commands enabled. "..
"Right click hub tab or user list for a command menu.|")
end
end
OpConnected,RegConnected = UserConnected,UserConnected

ChatArrival = function(user, data)
local _,_,to = data:find("^$To: (%S+) From:")
if to then
if CheckNick(to,user.sNick) then
local msg = to.." has blocked private messages from you."
return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
end
if CheckBlock(user.sNick) then
local msg = "Your PM's are blocked! It is senseless to try to speak."
return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
end
if CheckBlock(to) and not CheckExclude(to) then
local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! "..
to.." may receive a message but cannot respond."
return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
end
end
if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] or
user.sNick:lower() == PbCfg.OpNick:lower() then
local _,_,cmd = data:find("%b<> ["..PbCfg.Pfxs.."](%w+)")
if cmd and BlockCmds[cmd] then
if to and to:lower() == PbCfg.Bot:lower() then
Core.SendPmToUser(user,PbCfg.Bot,BlockCmds[cmd](user,data).."|")
else
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data).."|")
end
return true
end
end
end
ToArrival = ChatArrival

CheckBlock = function(nick)
for i,v in ipairs(PbCfg.Blocked) do
if v[1]:lower() == nick:lower() then
return i
end
end
end

CheckNick = function(op,nick)
for i,v in ipairs(PbCfg.Nicks) do
if v[1]:lower() == op:lower() then
if v[2]:lower() == nick:lower() then
return i
end
end
end
end

CheckExclude = function(nick)
if next(PbCfg.Exclude) then
for i,v in ipairs(PbCfg.Exclude) do
if v:lower() == nick:lower() then
return i
end
end
end
return nil
end

BlockCmds = {
block = function(user,data)
if user then
local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..PbCfg.Pfx..
"block <nick>"
else
if nick == user.sNick then
return "You cannot block yourself "..user.sNick..". Dont be a fool!"
end
local usr = Core.GetUser(nick)
if usr and PbCfg.Profiles[usr.iProfile] then
return "You cannot block "..PbCfg.Profiles[usr.iProfile][2].." "..usr.sNick..
", "..PbCfg.Profiles[usr.iProfile][2].."'s are protected from block."
end
if usr and usr.sNick:lower() == PbCfg.OpNick:lower() then
return PbCfg.OpNick.." is protected and may not be blocked."
end
if CheckBlock(nick) then
return "The user: "..nick.." has already been blocked."
else
table.insert(PbCfg.Blocked,{nick,os.time()})
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
local status = "offline"
if usr then
status,nick = "online",usr.sNick
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. "..
"You may not speak in private message.")
end
return "The "..status.." user: "..nick.." is now "..
"blocked and cannot speak in private message."
end
end
else
return "Block This User's PM's"," %[line:Nickname]"," %[nick]"
end
end,
blocknick = function(user,data)
if user then
local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..PbCfg.Pfx..
"block <nick>"
else
if nick == user.sNick then
return "You cannot block yourself "..user.sNick..". Dont be a fool!"
end
local usr = Core.GetUser(nick)
if usr and PbCfg.Profiles[usr.iProfile] and PbCfg.Profiles[usr.iProfile][1] == 1 then
return "You cannot block "..PbCfg.Profiles[usr.iProfile][2].." "..usr.sNick..
", "..PbCfg.Profiles[usr.iProfile][2].."'s are protected from block."
end
if usr and usr.sNick:lower() == PbCfg.OpNick:lower() then
return PbCfg.OpNick.." is protected and may not be blocked."
end
if CheckNick(user.sNick,nick) then
return "The user: "..nick.." has already been blocked."
else
table.insert(PbCfg.Nicks,{user.sNick,nick,os.time()})
Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
local status = "offline"
if usr then
status,nick = "online",usr.sNick
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. "..
"You may not speak to "..user.sNick.." in private message.")
end
return "The "..status.." user: "..nick.." is now "..
"blocked and cannot speak to you in private message."
end
end
else
return "Block PM's From This User To You"," %[line:Nickname]"," %[nick]"
end
end,
unblocknick = function(user,data)
if user then
local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..PbCfg.Pfx..
"unblock <nick>"
else
if nick:lower() == user.sNick:lower() then
return "You cannot unblock yourself "..user.sNick..
". What fun would that be?"
end
local Block = CheckNick(user.sNick,nick)
if not Block then
return "The user: "..nick.." has not been blocked."
else
table.remove(PbCfg.Nicks,Block)
Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
local status,usr = "offline",Core.GetUser(nick)
if usr then
status = "online"
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been unblocked. "..
"You may now speak to "..user.sNick.." in private message again.")
end
return "The "..status.." user: "..nick.." is unblocked "..
"and can now speak in private message to you once more."
end
end
else
return "Unblock PM's From This User To You"," %[line:Nickname]"," %[nick]"
end
end,
blockall = function(user,data)
if user then
local Now,Count,Change = os.time(),0,false
for i,usr in ipairs(Core.GetOnlineUsers()) do
if not PbCfg.Profiles[usr.iProfile] or not PbCfg.Profiles[usr.iProfile][1] then
if usr.sNick:lower() ~= PbCfg.OpNick:lower() then
Count = Count + 1
Change = true
local x = CheckBlock(usr.sNick)
if x then
PbCfg.Blocked[x][2] = Now
else
table.insert(PbCfg.Blocked,{usr.sNick,Now})
end
end
end
end
if Change then
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
end
local status = "No"
if Count > 0 then
status = Count
end
return status.." users were added to or updated in the pm block table."
else
return "Block All User's PM's","",""
end
end,
unblock = function(user,data)
if user then
local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..PbCfg.Pfx..
"unblock <nick>"
else
if nick:lower() == user.sNick:lower() then
return "You cannot unblock yourself "..user.sNick..
". What fun would that be?"
end
local Block = CheckBlock(nick)
if not Block then
return "The user: "..nick.." has not been blocked."
else
table.remove(PbCfg.Blocked,Block)
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
local status,usr = "offline",Core.GetUser(nick)
if usr then
status = "online"
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been "..
"unblocked. You may now speak in private message again.")
end
return "The "..status.." user: "..nick.." is unblocked "..
"and can now speak in private message again."
end
end
else
return "Unblock This User's PM"," %[line:Nickname]"," %[nick]"
end
end,
unblockall = function(user,data)
if user then
PbCfg.Blocked = {}
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
return "All user PM's are now unblocked"
else
return "Unblock All User's PM's","",""
end
end,
pmblist = function(user,data)
if user then
if next(PbCfg.Blocked) then
local Count = 0
local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n"..
"\t"..string.rep("Ż",40).."\r\n"
for i,v in ipairs(PbCfg.Blocked) do
reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n"
end
return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n"
else
return "There are no users blocked at this time."
end
else
return "List PM Blocked Users","",""
end
end,
pmbhelp = function(user,data)
if user then
local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
"\t"..string.rep("Ż",40).."\r\n"
for i,v in pairs(BlockCmds) do
local desc,args = BlockCmds[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 "PM Block Command Help","",""
end
end,
}

SendBlockCmds = function(user)
for i,v in pairs(BlockCmds) do
local desc,arg1,arg2 = BlockCmds[i]()
Core.SendToUser(user,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToUser(user,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
collectgarbage("collect")
end
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in ipairs(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:flush() hFile:close()
collectgarbage("collect")
end
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline Yahoo

  • Lord
  • ***
  • Posts: 265
  • Karma: +32/-14
  • People Say "I Dont Know English"
    • Yahoo
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #4 on: June 28, 2009, 06:41:02 pm »
Great Work Mutor

Keep the good working Going
"BoRN FIGhTEr"

Offline P_pan

  • Double Ace
  • *
  • Posts: 120
  • Karma: +1/-3
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #5 on: December 23, 2009, 01:07:49 pm »
. it is so that you can and get pm blocks so that it is not timed, but that may delite blocks myself manually?

can this be done mutor?

thank you..... and a merry xmass!

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
PM Block 1.0e LUA 5.1 [Strict] [API 2]
« Reply #6 on: December 24, 2009, 04:34:57 am »
Code: [Select]
--[[

PM Block 1.0e LUA 5.1 [Strict] [API 2]

By Mutor 07/14/07

Requested by TwîsTèd-dèvîl


Blocks / Unblocks user PM's by command.
-Provides commands/protection by profile or op nick
-Block auto-cleared after block time elapsed [+/- 1 min.]
-Can block/unblock all [non-protected] online nicks
-Can block / unblock offline nicks
-Cannot block / unblock own nick
-Provides context menu [right click]
-Blocked user list saved to file for hub/script restart

+Changes from 1.0
+Added auto clear after interval

+Changes from 1.0b
~Converted to API 2 strict

+Changes from 1.0c 06/21/09
+Added commands/function to support blocking pm's from specific nicks

+Changes from 1.0d 12/23/09
+Added option to disable auto-clear [Set BlockTime = 0], requested by P_pan



PM Block Command Help

Command Description
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
+pmbhelp        PM Block Command Help
+block          Block This User's PM's
+blockall       Block All User's PM's
+unblock        Unblock This User's PM
+unblockall     Unblock All User's PM's
+pmblist        List PM Blocked Users

ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

]]

PbCfg = {
-- Name for bot ["" = Hub Bot]
Bot = "",
-- Should bot have a key?
BotIsOp = true,
-- Bot description
BotDesc = "Private Message Blocker",
-- Bot Email address
BotMail = "user@domain.com",
-- Admins nick for status/error messages
OpNick = "Mutor",
-- Send verbose script messages to OpNick? [true/false]
Verbose = true,
-- File to save config/user table
File = "Blocked.dat",
-- File to save nickname table
NickFile = "BlockedNicks.dat",
-- Command Menu Title ["" = Hub Name]
Menu = "",
-- Command SubMenu Title ["" = Script Name]
SubMenu = "",
--Block time [in minutes] after which users will be automatically unblocked. [0 = disable]
BlockTime = 30,
--Set your profiles permissions here.
--[profile #] = {Commands enabled? [true/false], Protection enabled? [true/false], "Custom Profile Name"}
Profiles = {
[-1] = {false,false,"Unregistered User"},
[0] = {true,true,"Master"},
[1] = {true,true,"Operator"},
[2] = {false,false,"Vip"},
[3] = {false,false,"Registered User"},
},
Exclude = {"Nick1","Nick2"},
}


OnStartup = function()
Path,Script = Core.GetPtokaXPath().."scripts/","PM Block 1.0e"
PbCfg.Pfxs = SetMan.GetString(29)
PbCfg.Pfx = PbCfg.Pfxs:sub(1,1)
if PbCfg.BlockTime > 0 then Timer = TmrMan.AddTimer(60000) end
if PbCfg.Bot == "" then PbCfg.Bot = SetMan.GetString(21) end
if PbCfg.Menu == "" then PbCfg.Menu = SetMan.GetString(0) end
if PbCfg.SubMenu == "" then PbCfg.SubMenu = Script end
if not PbCfg.File:find("^"..Path,1,true) then PbCfg.File = Path..PbCfg.File end
if not PbCfg.NickFile:find("^"..Path,1,true) then PbCfg.NickFile = Path..PbCfg.NickFile end
if loadfile(PbCfg.File) then
dofile(PbCfg.File)
else
PbCfg.Blocked = {}
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
end
if loadfile(PbCfg.NickFile) then
dofile(PbCfg.NickFile)
else
PbCfg.Nicks = {}
Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
end
if PbCfg.Bot ~= SetMan.GetString(21) then
Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,PbCfg.BotIsOp)
end
local hc = {SetMan.GetOpChat().sNick,Core.GetHubSecAlias()}
for i,v in ipairs(hc) do if not CheckExclude(v) then table.insert(PbCfg.Exclude,v) end end
OnError(Script.." for ".._VERSION.." by Mutor has been started.")
end

OnTimer =  function()
local Now,Change = os.time()
for i,v in ipairs(PbCfg.Blocked) do
if ((Now - v[2]) / 60) > PbCfg.BlockTime then
if not Change then Change = true end
if PbCfg.Verbose then OnError(v[1].." has been removed from blocked pm users.") end
table.remove(PbCfg.Blocked,i)
end
end
if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end
end

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

OnError = function(msg)
local user = Core.GetUser(PbCfg.OpNick)
if user then
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..msg.."|")
end
end

UserConnected = function(user,data)
if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] then
local Profile = PbCfg.Profiles[user.iProfile][3] or "Undefined Profile"
SendBlockCmds(user)
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..Profile.."'s "..Script.." commands enabled. "..
"Right click hub tab or user list for a command menu.|")
end
end
OpConnected,RegConnected = UserConnected,UserConnected

ChatArrival = function(user, data)
local _,_,to = data:find("^$To: (%S+) From:")
if to then
if CheckNick(to,user.sNick) then
local msg = to.." has blocked private messages from you."
return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
end
if CheckBlock(user.sNick) then
local msg = "Your PM's are blocked! It is senseless to try to speak."
return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
end
if CheckBlock(to) and not CheckExclude(to) then
local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! "..
to.." may receive a message but cannot respond."
return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
end
end
if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] then
local _,_,pfx,cmd = data:find("%b<> (["..PbCfg.Pfxs.."])(%a+)")
if pfx and cmd and BlockCmds[cmd] then
cmd = cmd:lower()
if to and to:lower() == PbCfg.Bot:lower() then
Core.SendPmToUser(user,PbCfg.Bot,BlockCmds[cmd](user,data,pfx..cmd).."|")
else
Core.SendToUser(user,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data,pfx..cmd).."|")
end
return true
end
end
end
ToArrival = ChatArrival

CheckBlock = function(nick)
for i,v in ipairs(PbCfg.Blocked) do
if v[1]:lower() == nick:lower() then
return i
end
end
end

CheckNick = function(op,nick)
for i,v in ipairs(PbCfg.Nicks) do
if v[1]:lower() == op:lower() then
if v[2]:lower() == nick:lower() then return i end
end
end
end

CheckExclude = function(nick)
if next(PbCfg.Exclude) then
for i,v in ipairs(PbCfg.Exclude) do
if v:lower() == nick:lower() then return i end
end
end
return nil
end

BlockCmds = {
block = function(user,data,cmd)
if user then
local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..PbCfg.Pfx..
"block <nick>"
else
if nick == user.sNick then
return "You cannot block yourself "..user.sNick..". Dont be a fool!"
end
local usr = Core.GetUser(nick)
if usr then
if PbCfg.Profiles[usr.iProfile][2] then
return "You cannot block "..PbCfg.Profiles[usr.iProfile][3].." "..usr.sNick..
", "..PbCfg.Profiles[usr.iProfile][3].."'s are protected from block."
end
if usr.sNick:lower() == PbCfg.OpNick:lower() then
return PbCfg.OpNick.." is protected and may not be blocked."
end
end
if CheckBlock(nick) then
return "The user: "..nick.." has already been blocked."
else
table.insert(PbCfg.Blocked,{nick,os.time()})
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
local status = "offline"
if usr then
status,nick = "online",usr.sNick
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. "..
"You may not speak in private message.")
end
return "The "..status.." user: "..nick.." is now "..
"blocked and cannot speak in private message."
end
end
else
return "Block This User's PM's"," %[line:Nickname]"," %[nick]"
end
end,
blocknick = function(user,data,cmd)
if user then
local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..PbCfg.Pfx..
"block <nick>"
else
if nick == user.sNick then
return "You cannot block yourself "..user.sNick..". Dont be a fool!"
end
local usr = Core.GetUser(nick)
if usr then
if PbCfg.Profiles[usr.iProfile][2] then
return "You cannot block "..PbCfg.Profiles[usr.iProfile][3].." "..usr.sNick..
", "..PbCfg.Profiles[usr.iProfile][3].."'s are protected from block."
end
if usr.sNick:lower() == PbCfg.OpNick:lower() then
return PbCfg.OpNick.." is protected and may not be blocked."
end
end
if CheckNick(user.sNick,nick) then
return "The user: "..nick.." has already been blocked."
else
table.insert(PbCfg.Nicks,{user.sNick,nick,os.time()})
Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
local status = "offline"
if usr then
status,nick = "online",usr.sNick
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. "..
"You may not speak to "..user.sNick.." in private message.")
end
return "The "..status.." user: "..nick.." is now "..
"blocked and cannot speak to you in private message."
end
end
else
return "Block PM's From This User To You"," %[line:Nickname]"," %[nick]"
end
end,
unblocknick = function(user,data,cmd)
if user then
local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..PbCfg.Pfx..
"unblock <nick>"
else
if nick:lower() == user.sNick:lower() then
return "You cannot unblock yourself "..user.sNick..
". What fun would that be?"
end
local Block = CheckNick(user.sNick,nick)
if not Block then
return "The user: "..nick.." has not been blocked."
else
table.remove(PbCfg.Nicks,Block)
Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
local status,usr = "offline",Core.GetUser(nick)
if usr then
status = "online"
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been unblocked. "..
"You may now speak to "..user.sNick.." in private message again.")
end
return "The "..status.." user: "..nick.." is unblocked "..
"and can now speak in private message to you once more."
end
end
else
return "Unblock PM's From This User To You"," %[line:Nickname]"," %[nick]"
end
end,
blockall = function(user,data,cmd)
if user then
local Now,Count,Change = os.time(),0,false
for i,usr in ipairs(Core.GetOnlineUsers()) do
if not PbCfg.Profiles[usr.iProfile] or not PbCfg.Profiles[usr.iProfile][1] then
if usr.sNick:lower() ~= PbCfg.OpNick:lower() then
Count = Count + 1
Change = true
local x = CheckBlock(usr.sNick)
if x then
PbCfg.Blocked[x][2] = Now
else
table.insert(PbCfg.Blocked,{usr.sNick,Now})
end
end
end
end
if Change then
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
end
local status = "No"
if Count > 0 then
status = Count
end
return status.." users were added to or updated in the pm block table."
else
return "Block All User's PM's","",""
end
end,
unblock = function(user,data,cmd)
if user then
local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
if not nick then
return "Error!, Usage: "..PbCfg.Pfx..
"unblock <nick>"
else
if nick:lower() == user.sNick:lower() then
return "You cannot unblock yourself "..user.sNick..
". What fun would that be?"
end
local Block = CheckBlock(nick)
if not Block then
return "The user: "..nick.." has not been blocked."
else
table.remove(PbCfg.Blocked,Block)
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
local status,usr = "offline",Core.GetUser(nick)
if usr then
status = "online"
Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been "..
"unblocked. You may now speak in private message again.")
end
return "The "..status.." user: "..nick.." is unblocked "..
"and can now speak in private message again."
end
end
else
return "Unblock This User's PM"," %[line:Nickname]"," %[nick]"
end
end,
unblockall = function(user,data,cmd)
if user then
PbCfg.Blocked = {}
Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
return "All user PM's are now unblocked"
else
return "Unblock All User's PM's","",""
end
end,
pmblist = function(user,data,cmd)
if user then
if next(PbCfg.Blocked) then
local Count = 0
local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n"..
"\t"..string.rep("Ż",40).."\r\n"
for i,v in ipairs(PbCfg.Blocked) do
reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n"
end
return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n"
else
return "There are no users blocked at this time."
end
else
return "List PM Blocked Users","",""
end
end,
pmbhelp = function(user,data,cmd)
if user then
local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
"\t"..string.rep("Ż",40).."\r\n"
for i,v in pairs(BlockCmds) do
local desc,args = BlockCmds[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 "PM Block Command Help","",""
end
end,
}

SendBlockCmds = function(user)
for i,v in pairs(BlockCmds) do
local desc,arg1,arg2 = BlockCmds[i]()
Core.SendToUser(user,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
Core.SendToUser(user,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
collectgarbage("collect")
end
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
sTab = sTab or "";
hFile:write(sTab..sTableName.." = {\n" )
for key, value in ipairs(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:flush() hFile:close()
collectgarbage("collect")
end
« Last Edit: December 27, 2009, 03:08:24 am by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline P_pan

  • Double Ace
  • *
  • Posts: 120
  • Karma: +1/-3
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #7 on: December 26, 2009, 08:03:21 pm »
Thank You Mutor :)



Code: [Select]
Profiles = {
[-1] = {false,"Unregistered User"},
[0] = {true,"Master"},
[1] = {true,"Operator"},
[2] = {false,"Vip"},
[3] = {false,"Registered User"},
},


with this settings i cant block VIP  the msg does say : vip are protected....

what im doing wrong now?

cause i dont want that VIP and REG can use this blocks

but when i enable it for VIP then i can blck vips

that correct????
« Last Edit: December 26, 2009, 11:03:58 pm by P_pan »

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #8 on: December 27, 2009, 03:06:58 am »
I've added a field for you in the profiles table.
The first value enables the commands for a profile, the second enabled the protection.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline P_pan

  • Double Ace
  • *
  • Posts: 120
  • Karma: +1/-3
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #9 on: December 27, 2009, 10:30:06 pm »
that was the trick Mutor.....

many thanks for this script.....it rocks! ;D

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
PM Block 1.0f LUA 5.1 [Strict] [API 2]
« Reply #10 on: September 21, 2010, 12:32:54 am »
New version...
Code: [Select]
--[[

    PM Block 1.0f LUA 5.1 [Strict] [API 2]

    By Mutor    07/14/07

    Requested by    TwîsTèd-dèvîl


    Blocks / Unblocks user PM's by command.
    -Provides commands/protection by profile or op nick
    -Block auto-cleared after block time elapsed [+/- 1 min.]
    -Can block/unblock all [non-protected] online nicks
    -Can block / unblock offline nicks
    -Cannot block / unblock own nick
    -Provides context menu [right click]
    -Blocked user list saved to file for hub/script restart
   
    +Changes from 1.0
        +Added auto clear after interval

    +Changes from 1.0b
        ~Converted to API 2 strict

    +Changes from 1.0c    06/21/09
        +Added commands/function to support blocking pm's from specific nicks

    +Changes from 1.0d    12/23/09
        +Added option to disable auto-clear [Set BlockTime = 0], requested by P_pan

    +Changes from 1.0e    09/20/10
        +Added report user pm to bot in OpChat. Requested by For_Ever_MeXxX
        +Added option, block main chat for unregistered users for 'x' minutes. Requested by For_Ever_MeXxX
        +Added option, block private message for unregistered users for 'x' minutes. Requested by For_Ever_MeXxX



    PM Block Command Help

    Command        Description
    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
    +pmbhelp        PM Block Command Help
    +block          Block This User's PM's
    +blockall       Block All User's PM's
    +unblock        Unblock This User's PM
    +unblockall     Unblock All User's PM's
    +pmblist        List PM Blocked Users

    ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ

]]

PbCfg = {
-- Name for bot ["" = Hub Bot]
Bot = "",
-- Should bot have a key?
BotIsOp = true,
-- Bot description
BotDesc = "Private Message Blocker",
-- Bot Email address
BotMail = "user@domain.com",
-- Admins nick for status/error messages
OpNick = "Mutor",
-- Send verbose script messages to OpNick? [true/false]
Verbose = true,
-- File to save config/user table
File = "Blocked.dat",
-- File to save nickname table
NickFile = "BlockedNicks.dat",
-- Command Menu Title ["" = Hub Name]
Menu = "",
-- Command SubMenu Title ["" = Script Name]
SubMenu = "",
--PM Block time [in minutes] after which users will be automatically unblocked. [0 = disable]
BlockTime = 30,
--Main Chat block time [in minutes] after which unregistered users may chat in main. [0 = disable]
MainBlockTime = 5,
--Pm block time [in minutes] after which unregistered users may speak in pm. [0 = disable]
PmBlockTime = 5,
-- Block true/false
--Set your profiles permissions here.
--[profile #] = {Commands enabled? [true/false], Protection enabled? [true/false], "Custom Profile Name"}
Profiles = {
    [-1] = {false,false,"Unregistered User"},
    [0] = {true,true,"Master"},
    [1] = {true,true,"Operator"},
    [2] = {false,false,"Vip"},
    [3] = {false,false,"Registered User"},
    },
Exclude = {"Nick1","Nick2"},
}


OnStartup = function()
    Path,Script = Core.GetPtokaXPath().."scripts/","PM Block 1.0f"
    PbCfg.Pfxs,PbCfg.HubBot,PbCfg.MainBlock,PbCfg.PmBlock = SetMan.GetString(29),SetMan.GetString(21),{},{}
    PbCfg.Pfx = PbCfg.Pfxs:sub(1,1),SetMan.GetString(21)
    if PbCfg.BlockTime > 0 or PbCfg.MainBlockTime > 0 then Timer = TmrMan.AddTimer(1000) end
    if PbCfg.Bot == "" then PbCfg.Bot = SetMan.GetString(21) end
    if PbCfg.Menu == "" then PbCfg.Menu = SetMan.GetString(0) end
    if PbCfg.SubMenu == "" then PbCfg.SubMenu = Script end
    if not PbCfg.File:find("^"..Path,1,true) then PbCfg.File = Path..PbCfg.File end
    if not PbCfg.NickFile:find("^"..Path,1,true) then PbCfg.NickFile = Path..PbCfg.NickFile end
    if loadfile(PbCfg.File) then
        dofile(PbCfg.File)
    else
        PbCfg.Blocked = {}
        Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
    end
    if loadfile(PbCfg.NickFile) then
        dofile(PbCfg.NickFile)
    else
        PbCfg.Nicks = {}
        Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
    end
    if PbCfg.Bot ~= SetMan.GetString(21) then
        Core.RegBot(PbCfg.Bot,PbCfg.BotDesc,PbCfg.BotMail,PbCfg.BotIsOp)
    end
    local hc = {SetMan.GetOpChat().sNick,Core.GetHubSecAlias()}
    for i,v in ipairs(hc) do if not CheckExclude(v) then table.insert(PbCfg.Exclude,v) end end
    if PbCfg.MainBlockTime > 0 and next(Core.GetOnlineUsers(-1)) then
        local pl = "s"
        if PbCfg.MainBlockTime == 1 then pl = "" end
        for _,user in ipairs(Core.GetOnlineUsers(-1)) do
            PbCfg.MainBlock[user.sNick] = os.time()
        end
        Core.SendToProfile(-1,"<"..PbCfg.Bot.."> Main block enabled. You may "..
        "not speak in main chat for "..tostring(PbCfg.MainBlockTime).." minute"..pl..".|")
    end
    if PbCfg.PmBlockTime > 0 and next(Core.GetOnlineUsers(-1)) then
        local pl = "s"
        if PbCfg.MainBlockTime == 1 then pl = "" end
        for _,user in ipairs(Core.GetOnlineUsers(-1)) do
            PbCfg.PmBlock[user.sNick] = os.time()
        end
        Core.SendToProfile(-1,"<"..PbCfg.Bot.."> PM block enabled. You may "..
        "not speak in private message for "..tostring(PbCfg.MainBlockTime).." minute"..pl..".|")
    end
    OnError(Script.." for ".._VERSION.." by Mutor has been started.")
end

OnTimer =  function()
    local Now,Change = os.time()
    for i,v in ipairs(PbCfg.Blocked) do
        if ((Now - v[2]) / 60) > PbCfg.BlockTime then
            if not Change then Change = true end
            if PbCfg.Verbose then OnError(v[1].." has been removed from blocked pm users.") end
            table.remove(PbCfg.Blocked,i)
        end
    end
    if PbCfg.MainBlockTime > 0 then
        for i,v in pairs(PbCfg.MainBlock) do
            if ((Now - v) / 60) > PbCfg.MainBlockTime then
                local user = Core.GetUser(i)
                PbCfg.MainBlock[i] = nil
                if user then
                    Core.SendToUser(user,"<"..PbCfg.Bot.."> Block time has expired you may now chat in main.|")
                end
            end
        end
    end
    if PbCfg.PmBlockTime > 0 then
        for i,v in pairs(PbCfg.PmBlock) do
            if ((Now - v) / 60) > PbCfg.PmBlockTime then
                PbCfg.PmBlock[i] = nil
            end
        end
    end
    if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end
end

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

OnError = function(msg)
    local user = Core.GetUser(PbCfg.OpNick)
    if user then
        Core.SendToUser(user,"<"..PbCfg.Bot.."> "..msg.."|")
    end
end

UserConnected = function(user,data)
    if PbCfg.MainBlockTime > 0 and user.iProfile == -1 then
        if not PbCfg.MainBlock[user.sNick] then PbCfg.MainBlock[user.sNick] = os.time() end
        local pl = "s"
        if PbCfg.MainBlockTime == 1 then pl = "" end
        Core.SendToUser(user,"<"..PbCfg.Bot.."> "..user.sNick..", You may not speak in "..
        "main chat for "..tostring(PbCfg.MainBlockTime).." minute"..pl..".|")
    end
    if PbCfg.PmBlockTime > 0 and user.iProfile == -1 then
        if not PbCfg.PmBlock[user.sNick] then PbCfg.PmBlock[user.sNick] = os.time() end
        local pl = "s"
        if PbCfg.PmBlockTime == 1 then pl = "" end
        Core.SendToUser(user,"<"..PbCfg.Bot.."> "..user.sNick..", You may not speak in "..
        "private message for "..tostring(PbCfg.PmBlockTime).." minute"..pl..".|")
    end
    if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] then
        local Profile = PbCfg.Profiles[user.iProfile][3] or "Undefined Profile"
        SendBlockCmds(user)
        Core.SendToUser(user,"<"..PbCfg.Bot.."> "..Profile.."'s "..Script.." commands enabled. "..
        "Right click hub tab or user list for a command menu.|")
    end
end
OpConnected,RegConnected = UserConnected,UserConnected

UserDisconnected = function(user)
    if PbCfg.MainBlockTime > 0 and user.iProfile == -1 then
        if PbCfg.MainBlock[user.sNick] then PbCfg.MainBlock[user.sNick] = nil end
    end
    if PbCfg.PmBlockTime > 0 and user.iProfile == -1 then
        if PbCfg.PmBlock[user.sNick] then PbCfg.PmBlock[user.sNick] = nil end
    end
end

ChatArrival = function(user, data)
    local _,_,to = data:find("^$To: (%S+) From:")
    if to then
        if to and to == PbCfg.HubBot then
            local _,_,msg = data:find("%b<> ([^|]+)")
            if msg then
                local s = "<"..PbCfg.Bot.."> "..GetProf(user.iProfile).." "..user.sNick..
                " from IP: "..user.sIP.." sent a message to "..PbCfg.HubBot..": "..msg
                return Core.SendToOpChat(s),true
            end
        end
        if PbCfg.PmBlock[user.sNick] then
            local x,n = PbCfg.PmBlock[user.sNick] + PbCfg.PmBlockTime*60,os.time()
            if x > n then
                local tl = Convert(x)
                if tl then
                    return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> You may not "..
                    "speak in private for another "..tl.."|"),true
                end
            end
        end
        if CheckNick(to,user.sNick) then
            local msg = to.." has blocked private messages from you."
            return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
        end
        if CheckBlock(user.sNick) then
            local msg = "Your PM's are blocked! It is senseless to try to speak."
            return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
        end
        if CheckBlock(to) and not CheckExclude(to) then
            local msg = "Sorry "..user.sNick..", "..to.."'s PM's are blocked! "..
            to.." may receive a message but cannot respond."
            return Core.SendPmToUser(user,to,"<"..PbCfg.Bot.."> "..msg),true
        end
    else
        if PbCfg.MainBlock[user.sNick] then
            local x,n = PbCfg.MainBlock[user.sNick] + PbCfg.MainBlockTime*60,os.time()
            if x > n then
                local tl = Convert(x)
                if tl then
                    return Core.SendToUser(user,"<"..PbCfg.Bot.."> You may not "..
                    "speak in main chat for another "..tl.."|"),true
                end
            end
        end
    end
    if PbCfg.Profiles[user.iProfile] and PbCfg.Profiles[user.iProfile][1] then
        local _,_,pfx,cmd = data:find("%b<> (["..PbCfg.Pfxs.."])(%a+)")
        if pfx and cmd and BlockCmds[cmd] then
            cmd = cmd:lower()
            if to and to:lower() == PbCfg.Bot:lower() then
                Core.SendPmToUser(user,PbCfg.Bot,BlockCmds[cmd](user,data,pfx..cmd).."|")
            else
                Core.SendToUser(user,"<"..PbCfg.Bot.."> "..BlockCmds[cmd](user,data,pfx..cmd).."|")
            end
            return true
        end
    end
end
ToArrival = ChatArrival

CheckBlock = function(nick)
    for i,v in ipairs(PbCfg.Blocked) do
        if v[1]:lower() == nick:lower() then
            return i
        end
    end
end

CheckNick = function(op,nick)
    for i,v in ipairs(PbCfg.Nicks) do
        if v[1]:lower() == op:lower() then
            if v[2]:lower() == nick:lower() then return i end
        end
    end
end

CheckExclude = function(nick)
    if next(PbCfg.Exclude) then
        for i,v in ipairs(PbCfg.Exclude) do
            if v:lower() == nick:lower() then return i end
        end
    end
    return nil
end

BlockCmds = {
    block = function(user,data,cmd)
        if user then
            local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
            if not nick then
                return "Error!, Usage: "..PbCfg.Pfx..
                "block <nick>"
            else
                if nick == user.sNick then
                    return "You cannot block yourself "..user.sNick..". Dont be a fool!"
                end
                local usr = Core.GetUser(nick)
                if usr then
                    if PbCfg.Profiles[usr.iProfile][2] then
                        return "You cannot block "..PbCfg.Profiles[usr.iProfile][3].." "..usr.sNick..
                        ", "..PbCfg.Profiles[usr.iProfile][3].."'s are protected from block."
                    end
                    if usr.sNick:lower() == PbCfg.OpNick:lower() then
                        return PbCfg.OpNick.." is protected and may not be blocked."
                    end
                end
                if CheckBlock(nick) then
                    return "The user: "..nick.." has already been blocked."
                else
                    table.insert(PbCfg.Blocked,{nick,os.time()})
                    Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
                    local status = "offline"
                    if usr then
                        status,nick = "online",usr.sNick
                        Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. "..
                        "You may not speak in private message.")
                    end
                    return "The "..status.." user: "..nick.." is now "..
                    "blocked and cannot speak in private message."
                end
            end
        else
            return "Block This User's PM's"," %[line:Nickname]"," %[nick]"
        end
    end,
    blocknick = function(user,data,cmd)
        if user then
            local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
            if not nick then
                return "Error!, Usage: "..PbCfg.Pfx..
                "block <nick>"
            else
                if nick == user.sNick then
                    return "You cannot block yourself "..user.sNick..". Dont be a fool!"
                end
                local usr = Core.GetUser(nick)
                if usr then
                    if PbCfg.Profiles[usr.iProfile][2] then
                        return "You cannot block "..PbCfg.Profiles[usr.iProfile][3].." "..usr.sNick..
                        ", "..PbCfg.Profiles[usr.iProfile][3].."'s are protected from block."
                    end
                    if usr.sNick:lower() == PbCfg.OpNick:lower() then
                        return PbCfg.OpNick.." is protected and may not be blocked."
                    end
                end
                if CheckNick(user.sNick,nick) then
                    return "The user: "..nick.." has already been blocked."
                else
                    table.insert(PbCfg.Nicks,{user.sNick,nick,os.time()})
                    Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
                    local status = "offline"
                    if usr then
                        status,nick = "online",usr.sNick
                        Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been blocked. "..
                        "You may not speak to "..user.sNick.." in private message.")
                    end
                    return "The "..status.." user: "..nick.." is now "..
                    "blocked and cannot speak to you in private message."
                end
            end
        else
            return "Block PM's From This User To You"," %[line:Nickname]"," %[nick]"
        end
    end,
    unblocknick = function(user,data,cmd)
        if user then
            local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
            if not nick then
                return "Error!, Usage: "..PbCfg.Pfx..
                "unblock <nick>"
            else
                if nick:lower() == user.sNick:lower() then
                    return "You cannot unblock yourself "..user.sNick..
                    ". What fun would that be?"
                end
                local Block = CheckNick(user.sNick,nick)
                if not Block then
                    return "The user: "..nick.." has not been blocked."
                else
                    table.remove(PbCfg.Nicks,Block)
                    Save_File(PbCfg.NickFile,PbCfg.Nicks,"PbCfg.Nicks")
                    local status,usr = "offline",Core.GetUser(nick)
                    if usr then
                        status = "online"
                        Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been unblocked. "..
                        "You may now speak to "..user.sNick.." in private message again.")
                    end
                    return "The "..status.." user: "..nick.." is unblocked "..
                    "and can now speak in private message to you once more."
                end
            end
        else
            return "Unblock PM's From This User To You"," %[line:Nickname]"," %[nick]"
        end
    end,
    blockall = function(user,data,cmd)
        if user then
            local Now,Count,Change = os.time(),0,false
            for i,usr in ipairs(Core.GetOnlineUsers()) do
                if not PbCfg.Profiles[usr.iProfile] or not PbCfg.Profiles[usr.iProfile][1] then
                    if usr.sNick:lower() ~= PbCfg.OpNick:lower() then
                        Count = Count + 1
                        Change = true
                        local x = CheckBlock(usr.sNick)
                        if x then
                            PbCfg.Blocked[x][2] = Now
                        else
                            table.insert(PbCfg.Blocked,{usr.sNick,Now})
                        end
                    end
                end
            end
            if Change then Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked") end
            local status = "No"
            if Count > 0 then status = Count end
            return status.." users were added to or updated in the pm block table."
        else
            return "Block All User's PM's","",""
        end
    end,
    unblock = function(user,data,cmd)
        if user then
            local _,_,nick = data:find("%b<> ["..PbCfg.Pfxs.."]%w+ (%S+)|$")
            if not nick then
                return "Error!, Usage: "..PbCfg.Pfx..
                "unblock <nick>"
            else
                if nick:lower() == user.sNick:lower() then
                    return "You cannot unblock yourself "..user.sNick..
                    ". What fun would that be?"
                end
                local Block = CheckBlock(nick)
                if not Block then
                    return "The user: "..nick.." has not been blocked."
                else
                    table.remove(PbCfg.Blocked,Block)
                    Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
                    local status,usr = "offline",Core.GetUser(nick)
                    if usr then
                        status = "online"
                        Core.SendToUser(usr,"<"..PbCfg.Bot.."> You have been "..
                        "unblocked. You may now speak in private message again.")
                    end
                    return "The "..status.." user: "..nick.." is unblocked "..
                    "and can now speak in private message again."
                end
            end
        else
            return "Unblock This User's PM"," %[line:Nickname]"," %[nick]"
        end
    end,
    unblockall = function(user,data,cmd)
        if user then
            PbCfg.Blocked = {}
            Save_File(PbCfg.File,PbCfg.Blocked,"PbCfg.Blocked")
            return "All user PM's are now unblocked"
        else
            return "Unblock All User's PM's","",""
        end
    end,
    pmblist = function(user,data,cmd)
        if user then
            if next(PbCfg.Blocked) then
                local Count = 0
                local reply = "Listing PM Blocked Users...\r\n\r\n\tNumber\t\tUser Nick\r\n"..
                "\t"..string.rep("Ż",40).."\r\n"
                for i,v in ipairs(PbCfg.Blocked) do
                    reply = reply.."\t"..string.format("[ %-3s ]",i).."\t\t"..v[1].."\r\n"
                end
                return reply.."\n\t"..string.rep("Ż",40).."\r\n\r\n"
            else
                return "There are no users blocked at this time."
            end
        else
            return "List PM Blocked Users","",""
        end
    end,
    pmbhelp = function(user,data,cmd)
        if user then
            local reply = "PM Block Command Help\r\n\r\n\tCommand\t\tDescription\r\n"..
            "\t"..string.rep("Ż",40).."\r\n"
            for i,v in pairs(BlockCmds) do
                local desc,args = BlockCmds[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 "PM Block Command Help","",""
        end
    end,
}

SendBlockCmds = function(user)
    for i,v in pairs(BlockCmds) do
        local desc,arg1,arg2 = BlockCmds[i]()
        Core.SendToUser(user,"$UserCommand 1 1 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
        desc.."$<%[mynick]> +"..i..arg1.."&#124;|")
        Core.SendToUser(user,"$UserCommand 1 2 "..PbCfg.Menu.."\\"..PbCfg.SubMenu.."\\"..
        desc.."$$To: "..PbCfg.Bot.." From: %[mynick] $<%[mynick]> +"..i..arg2.."&#124;|")
        collectgarbage("collect")
    end
end

GetProf = function(i)
    local Prof = "Unregistered User"
    if i ~= -1 then Prof = ProfMan.GetProfile(i).sProfileName end
    return Prof
end

Convert = function(time)
    if time then
        local s,x,n = "",0,os.time()
        local tab = {{31556926,"year"},{2592000,"month"},{604800,"week"},
        {86400,"day"},{3600,"hour"},{60,"minute"},{1,"second"}}
        if time > 0 then
            if time < 2145876659 then
                if n > time then
                    time = n - time
                elseif n < time then
                    time = time - n
                end
                for i,v in ipairs(tab) do
                    if time > v[1] then
                        x = math.floor(time/v[1])
                        if x > 1 then v[2] = v[2].."s" end
                        if x > 0 then
                            s = s..x.." "..v[2]..", "
                            time = time-x*v[1]
                        end
                    end
                end
                collectgarbage("collect")
                return s:sub(1,-3)
            else
                return "Invalid date or time supplied. [must be pre 12/31/2037]"
            end
        else
            return "Invalid date or time supplied. [must be post 01/01/1970]"
        end
    else
        return "Invalid date or time supplied."
    end
end

Save_Serialize = function(tTable, sTableName, hFile, sTab)
    sTab = sTab or "";
    hFile:write(sTab..sTableName.." = {\n" )
    for key, value in ipairs(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:flush() hFile:close()
    collectgarbage("collect")
end
« Last Edit: September 22, 2010, 11:16:44 pm by Mutor »
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline sky202_how89

  • Junior Member
  • **
  • Posts: 21
  • Karma: +0/-0
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #11 on: September 21, 2010, 04:11:48 pm »
Mutor, Please help

[22:11] Syntax ...2\scripts\PM Block 1.0f LUA 5.1 [Strict] [API 2].lua:485: attempt to index global 'user' (a nil value)
[22:12] Syntax ...2\scripts\PM Block 1.0f LUA 5.1 [Strict] [API 2].lua:485: attempt to index global 'user' (a nil value)

/Regards
SKy

Offline For_Ever_MeXxX

  • Junior Member
  • **
  • Posts: 22
  • Karma: +0/-0
  • Gamato™
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #12 on: September 21, 2010, 05:09:41 pm »
You did somethink remove from this script i can find nothing in line 485 it is just a space...

it is good to post the line to help mutor...
« Last Edit: September 21, 2010, 05:11:35 pm by For_Ever_MeXxX »
For_Ever_MeXxX ;)

Offline sky202_how89

  • Junior Member
  • **
  • Posts: 21
  • Karma: +0/-0
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #13 on: September 21, 2010, 05:47:29 pm »
You did somethink remove from this script i can find nothing in line 485 it is just a space...

it is good to post the line to help mutor...

Thanks for your reminder =) I get it..

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #14 on: September 22, 2010, 12:10:21 am »
There was indeed, a bug. Found. fixed and script updated.
Thank you sky202_how89 for the report.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline sky202_how89

  • Junior Member
  • **
  • Posts: 21
  • Karma: +0/-0
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #15 on: September 23, 2010, 12:12:46 am »
 :) You're welcome.. Mutor.
However, I'm Sorry to disappoint you that another little buggy here.

PM Block 1.0 LUA 5.1 [Strict] [API 2]and OmniBlocker 1.0 LUA 5.1x [Strict][API 2] are crashing each other.

Although there is nothing error for the script, but whenever the script are running at the same time, only one of the script is functioning.
(Depends on which one of script is the priority)

Sorry for my bad English. I'm hoping that the problem can be fixed.

My Best Regards,
SKy

Offline Mutor

  • Global Moderator
  • Forum God
  • *****
  • Posts: 3 854
  • Karma: +395/-18
  • To err is human, to arr is pirate...
    • PxDev
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #16 on: September 23, 2010, 11:18:52 pm »
That's not crashing, nor is it a bug. The first script has priority.
If the first script does not return true on the common arrival
the second script will continue to process the arrival.
Respectfully,

Mutor

=-=-=-=-=-=-=-==-=-=-=
[ Ptokax Admins Hub ] Ptokax Help Hub
[ Mutor's Ptokax Archive Website ] Scripting Forum
[ Dynamic Downloads ] API 2
[ Microsoft IIS serving PxWeb 1.0d ] API 2
[ WebReg 1.1.2.0 ] Web Based Hub Reg

Offline sky202_how89

  • Junior Member
  • **
  • Posts: 21
  • Karma: +0/-0
Re: PM Block 1.0c LUA 5.1 [Strict] [API 2]
« Reply #17 on: September 24, 2010, 11:58:52 am »
Hmm.. Sound like It's work...

Thanks, Mutor =)

Regards.
« Last Edit: September 24, 2010, 12:15:46 pm by sky202_how89 »

 

determinate determinate
guestbook