PtokaX forum

Archive => Archived 5.0 boards => Help with scripts => Topic started by: Braum on 26 May, 2006, 07:04:53

Title: Help please with script Filter PM
Post by: Braum on 26 May, 2006, 07:04:53
Hi, I call for your help. The script have a failure. It works very well, avoid the private messages to not registered users, but it does not send them the answer message. Please I need your help in order to solve it. Thank you so very much.

--PM Filter 1.0 LUA 5
--
--by Mutor 7/6/05
--
--
-- Filter PM's by profiles
--
--User Settings-------------------------------------------------------------------------------------
Bot = frmHub:GetHubBotName()
-- Adjust to your profiles
--profile_idx, PM send is filtered [0=PM Filter is bypassed / 1=PM's are filtered]
CanSendPm = {
[-1] = 1, --Unregistered User
[0] = 0, --Master
[1] = 0, --Operator
[2] = 0, --Vip
[3] = 1, --Registered User
[4] = 0, --Moderator
[5] = 0, --NetFounder
}
-- Adjust to your profiles
--profile_idx, PM Permission level
--Sender may only PM profiles equal to or greater than their own profile setting.
CanGetPm = {
[-1] = 0, --Unregistered User
[0] = 6, --Master
[1] = 3, --Operator
[2] = 2, --Vip
[3] = 1, --Registered User
[4] = 4, --Moderator
[5] = 5, --NetFounder
}
--End User Settings----------------------------------------------------------------------------------
function ToArrival(user, data)
if CanSendPm[user.iProfile] == 1 then
local s,e,who = string.find(data,"$To:%s+(%S+)%s+From:")
local userprof = GetProfileName(user.iProfile)
local nick = GetItemByName(who)
if not nick then
local OfflineMsg = "The user "..who.." is not online. Check your spelling."
SendPmToNick(user.sName,Bot,OfflineMsg)
return 1
end
if CanGetPm[user.iProfile] >= CanGetPm[nick.iProfile] then
return 1
else
local nickprof = GetProfileName(nick.iProfile)
local FilterMsg = "\r\n\r\n\t***Your Private Message To "..nick.sName.." Was Blocked.***\r\n"..
"\t"..userprof.."'s are currently not allowed to PM "..nickprof.."'s.\r\n\r\n"
SendPmToNick(user.sName,nick.sName,Bot.." 8( ...Sorry "..user.sName..FilterMsg)
return 1
end
end
end


Please, Send Pm message ***Your Private Message To "..nick.sName.." Was Blocked.***  to Unregistered User

Thank
Title: Re: Help please with script Filter PM
Post by: bastya_elvtars on 27 May, 2006, 13:52:47
user:SendPM(nick.sName, Bot.." 8( ...Sorry "..user.sName..FilterMsg)
Title: Re: Help please with script Filter PM
Post by: Braum on 27 May, 2006, 15:46:01
Quote from: bastya_elvtars on 27 May, 2006, 13:52:47
user:SendPM(nick.sName, Bot.." 8( ...Sorry "..user.sName..FilterMsg)

help, but it does not send them the answer message
Title: Re: Help please with script Filter PM
Post by: bastya_elvtars on 27 May, 2006, 15:48:52
Then the hub bot name isn't filled, I cannot think of anything else right now.
Title: Re: Help please with script Filter PM
Post by: Braum on 27 May, 2006, 16:48:01
Quote from: bastya_elvtars on 27 May, 2006, 15:48:52
Then the hub bot name isn't filled, I cannot think of anything else right now.

I need that blocked message reach non registered users that try to send a private message, because it does not works
Title: Re: Help please with script Filter PM
Post by: jiten on 28 May, 2006, 14:34:53
Replace your ToArrival function with this one and post your progress:

ToArrival = function(user,data)
if CanSendPm[user.iProfile] == 1 then
local s,e,who = string.find(data,"$To:%s+(%S+)%s+From:")
local nick = GetItemByName(who)
if nick then
if CanGetPm[user.iProfile] < CanGetPm[nick.iProfile] then
local FilterMsg = "\r\n\r\n\t***Your Private Message To "..nick.sName.." Was Blocked.***\r\n\t"..
(GetProfileName(user.iProfile) or "Unreg").."'s are currently not allowed to PM "..
(GetProfileName(nick.iProfile) or "Unreg").."'s.\r\n\r\n"
return SendPmToNick(user.sName, nick.sName, Bot.." 8( ...Sorry "..user.sName..FilterMsg), 1
end
else
local OfflineMsg = "The user "..who.." is not online. Check your spelling."
return SendPmToNick(user.sName, Bot, OfflineMsg), 1
end
end
end
Title: Re: Help please with script Filter PM
Post by: Braum on 29 May, 2006, 16:26:14
The messages does not reach the non registered users, but yes for registered
Title: Re: Help please with script Filter PM
Post by: jiten on 29 May, 2006, 16:56:43
Quote from: Braum on 29 May, 2006, 16:26:14
The messages does not reach the non registered users, but yes for registered

What do you mean with that?

Do you want to allow messages only sent to profiles higher than the sender's?

If that's so, just replace:

if CanGetPm[user.iProfile] < CanGetPm[nick.iProfile] then

with:

if CanGetPm[user.iProfile] >= CanGetPm[nick.iProfile] then