PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: exlepra on 05 January, 2005, 13:11:40

Title: allow certain prefixes only for Reg users
Post by: exlepra on 05 January, 2005, 13:11:40
Hello scripters,
 I need a script which only allows users to log in with certain prefixes for example, [Friend] [Reg] [VIP] if they are registered users of the hub.


thx in advance
Title:
Post by: DJ Bert on 05 January, 2005, 19:34:29
I think this is it
--Description Tag by ??????Hawk?????? 05-07-2004
-- Modified by Troubadour & DJ Bert

--===Sets the tag to be shown in reg's descriptions=================

regTagInDescription = "{Reg}"   --\\ Tag

--==================================================================
--===Sets the tag to be shown in Vip's descriptions=================

VipTagInDescription = "{Vip}"   --\\ Tag

--==================================================================
--===Sets the tag to be shown in op's descriptions==================

OpsTagInDescription = "{Op}"   --\\ Tag

--==================================================================
--===Sets the tag to be shown in masters's descriptions=============

MastersTagInDescription = "{Admin}"   --\\ Tag

--==================================================================
--===Sets the tag to be shown in Net Founder descriptions===========

netTagInDescription = "{Networkmember}"   --\\ Tag

--==================================================================
--===Sets the tag to be shown in Moderator's descriptions=============

modTagInDescription = "{Moderator}"   --\\ Tag

--==================================================================
--===Sets the tag to be shown in Moderator's descriptions=============

modTagInDescription = "{Friends}"   --\\ Tag

--==================================================================
--===Sets the time for the tags to be updated=======================

Mins =  1

--==================================================================



timer = 60000 * Mins
function Main()
SetTimer(timer)
StartTimer()
end

function OnTimer()
TagInDescription()
end

function TagInDescription()
local aux,usr
for aux, usr in GetUsersByProfile("vip") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = strfind(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..VipTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("operator") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = strfind(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..OpsTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("master") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = strfind(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..MastersTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("reg") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = strfind(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..regTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("Moderator") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = strfind(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..modTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("Networkmember") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = strfind(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..netTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
for aux, usr in GetUsersByProfile("Friends") do
if (GetItemByName(usr) ~= nil) then
local userToShow = GetItemByName(usr)
if (userToShow.sMyInfoString ~= nil) then
local s,e,name,desc,speed,email,share = strfind(userToShow.sMyInfoString, "$MyINFO $ALL (%S+)%s+([^$]*)$ $([^$]*)$([^$]*)$([^$]+)")
SendToAll( "$MyINFO $ALL "..name.." "..netTagInDescription.." "..desc.."$ $"..speed.."$"..email.."$"..share.."$")
end
end
end
end




Grtzzz

DJ Bert
Title:
Post by: exlepra on 05 January, 2005, 20:53:35
Not quite, this one checks description If I understood properly.

What I need is something like protected prefixes in nicknames, eg if user  tries to enter with  [VIP]anyone nick for example the hub shouldnt let him in if that [VIP]anyone nick is not registered.
Title:
Post by: Madman on 05 January, 2005, 21:52:34
-- Made by dEFiNE
-- Mod by nErBoS asked by Robban
-- Modded by Madman on request by exlepra

BotName = "-Bot-"

ISP = {
"[Friend]",
"[Reg]",
"[VIP]",
}

CheckProfiles = { --//Set the profiles you want to check to 1
[-1] = 0, -- Users (Unregged)
[0] = 0, -- Masters
[1] = 0, -- Operators
[2] = 1, -- VIP
[3] = 1, -- Reg
[4] = 0, -- Moderator
[5] = 0, -- NetFounder
}

function Main()
frmHub:RegBot(BotName)
end

function NewUserConnected(curUser)
if CheckProfiles[curUser.iProfile]==1 then
for key, value in ISP do
if (strlen(curUser.sName) >= strlen(value) and strsub(strlower(curUser.sName),1,strlen(value)) == strlower(value)) then
return 1
end
end
curUser:SendData(BotName, "Your nick should include one of this Prefix")
ISPList(curUser)
curUser:SendData(BotName, "For Example [REG]" ..curUser.sName)
curUser:Disconnect()
end
end

OpConnected = NewUserConnected

function ISPList(curUser)
local names = ""
for index, value in ISP do
names = names.." "..value.."\r\n\t"
end
curUser:SendData("\r\n\t" ..names)
end

This should work...
Title:
Post by: exlepra on 05 January, 2005, 23:02:03
Well, this ^ does the other way :)   cos if a vip logs in without vip prefix he gets a warning to use the prefix but it will never happen cos vip is registered with [VIP]nick and not just nick.
Title:
Post by: Madman on 06 January, 2005, 00:07:43
QuoteOriginally posted by exlepra
Well, this ^ does the other way :)   cos if a vip logs in without vip prefix he gets a warning to use the prefix but it will never happen cos vip is registered with [VIP]nick and not just nick.
Well.. that is easy change..
just change
[2] = 1,-- VIP
to
[2] = 0,-- VIP
and vip wont be checked....
That is what the CheckProfiles  is for...
thoose with 1 will be checked... and 0 wont be checked =)
But as you said.. it wont happen, since they are registed with [VIP]nick =)
Title:
Post by: exlepra on 06 January, 2005, 09:46:36
It still doesnt work as it should, because it lets
  [VIP]blablabla enter to the hub even if that nick is not registered.
Title:
Post by: [UK]Madman on 06 January, 2005, 13:58:24
This might work...


-- by [UK]Madman
-- Cut down version of a profile/username checker by nErBoS


sBot = "-=Bot=-" -- enter any botname between the ""

prefix = {
"[VIP]",   -- Add any forbidden prefixes here between ""
"[OP]",
"[FRIEND]",
"[More]",
}

function Main()
frmHub:RegBot(sBot)
end

function NewUserConnected(curUser)

if curUser == -1 then

for key,value in prefix do
if (strlen(curUser.sName) >= strlen(value) and strsub(strlower(curUser.sName),1,strlen(value)) == strlower(value)) then
curUser:SendData(sBot, "You are not registered in this hub, you cannot use have "..value.." in your name!, please return with a corrected username!") -- Enter any message you want the user to recieve here (..value.. will tell them exactly what isnt allowed)
curUser:Disconnect() -- remove this line if you dont want the user disconnected
end
end
end
end

Title:
Post by: exlepra on 06 January, 2005, 16:49:59
yes :),
by removing "," from here:

sBot = "-=Bot=-",

and

using this:

if curUser.iProfile == -1

thanks
Title:
Post by: [UK]Madman on 06 January, 2005, 16:58:02
Thanks you for pointing out silly errors, glad it works :o)
Title:
Post by: Anna on 06 January, 2005, 19:19:15
I dunno what I do wrong, but when I have it disconnect the users with the wrong settings, they dont get the message... just says:

connection reset by server

Any clues? I copy/pasted it from here and made the changes

If I remove the disconnect part they get the message..
Title:
Post by: bastya_elvtars on 06 January, 2005, 19:41:01
thats a client error, they disconnect too fast. sometimes annoying.
Title:
Post by: Anna on 06 January, 2005, 19:54:13
aha, oki :D

any chance to put a delay in script or is it something thats out of control completely?

same client gets the message if I use robo nickchekck, but that timebans for 60 min... a bit 2 long if they just post as vips without being one
Title:
Post by: exlepra on 07 January, 2005, 12:06:40
I assume a for cycle before  curUser:Disconnect()
could solve the problem, but I have no idea how the exact delay time in secs could be set that way.
Title:
Post by: Anna on 10 January, 2005, 13:24:04
ok.. yes some sort of loop that takes time prolly works... but I have no idea how to make one in lua... :D

lua sort of aint my language...
Title:
Post by: NightLitch on 10 January, 2005, 14:19:18
my little coin into it.

-- simple isp tag check / NightLitch

-- have all prefixes in lowcase letters
iTag = {
["[vip]"] = 1,
["[reg]"] = 1,
["[telia]"] = 1,
["[bbb]"] = 1,

-- and so on
}

function NewUserConnected(user)
local TagList = ""
local _,_,UserTag = strfind(user, "^(%p%S+%p)%S+")
if iTag[strlower(UserTag)] == nil or UserTag == nil then
for tag,_ in iTag do TagList = TagList .. tag.."    " end
user:SendData("*** Your ISP Tag is not correct or missing, use one of the following:\r\n\r\n\t"..TagList.."\r\n\r\n\t Lowercase / Uppercase letters is allowed.")
user:Disconnect()
end
end

don't know if it works did it in 3min going out now.