PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: catwo on 15 May, 2005, 17:49:58

Title: Self Registration Script
Post by: catwo on 15 May, 2005, 17:49:58
Hi is the following possible?

1.   User Types command !Regme in main chat.
2.   Script kicks in and checks to see if the user is at or below the maximum allowed hubs e.g 10 and if so auto registers the user with their nick including a predifiend prefix [XXX] and also generates a password for them.  (If the max hubs is to high then the script tells the user e.g. "Max hubs allowed here is 10, you are currently in 12 hubs, please reduce to 10 then retype !regme in main chat).  However, if all is ok the script then tells the user to add the registration details to their settings and rejoin hub.

If this is possible? would someone please have a go at writing it for me.  Your help would be most appreciated as my OPs and I are not always at our PCs and users get frustrated as I only allow registered users to search and download.  Thanks in advance for any help or info.
Title:
Post by: Dessamator on 15 May, 2005, 18:14:27
-- By Dessamator
-- Simple Regme bot with hub checker
Prefix ="[XXX]"
bot = frmHub:GetHubBotName()
Maxhubs =10

function ChatArrival(user,data)
local pass=math.random(os.date("%H%M%S"))
data=string.sub(data,1,string.len(data)-1)
s,e,cmd =string.find(data, "%b<>%s+(%S+)")
if cmd=="!regme" then
if not(user.bRegistered) and not(frmHub:isNickRegged(Prefix..user.sName)) and user.iHubs AddRegUser(Prefix..user.sName, pass, 3)
user:SendData(bot,"Uve been registered with the Nick :"..Prefix..user.sName.." and password:"..pass)
elseif user.iHubs>Maxhubs then
user:SendData(bot,"Max hubs allowed here is "..Maxhubs..", you are currently in "..user.iHubs.." hubs, please reduce to "..Maxhubs.." then retype !regme in main chat")
else
user:SendData(bot,"You are Already Registered")
end
return 1
end
end


Done !,
Post Edited
Title:
Post by: catwo on 15 May, 2005, 19:56:33
Thanks again Dessamator for your prompt reply and your script work its much appreciated.  It doesn't seem to work for my hub though, i'm using Ptokax 03.3.0 build 16.9 debug with Esthetic netserver V8-5. Any ideas please? Once again many thanks for your help.
Title:
Post by: Dessamator on 15 May, 2005, 20:20:07
hmm, any errors??, i tested it thoroughly it should work even in that version of the ptokax. i didnt use anything new !
Title:
Post by: catwo on 16 May, 2005, 08:36:20
No error messages just don't work.  :(
Title:
Post by: Dessamator on 16 May, 2005, 09:59:47
well i tested it with ptokax 16.09, it didnt give me any errors, yaps found the prob, its with the xthetic server, it also has a regme command, the way to solve it, is to put "my" script above his, in the ptokax, move it up !!

Good Luck !
Title:
Post by: catwo on 16 May, 2005, 18:47:19
Yes! That solved it m8 many thanks for your help and assistance much appreciated. :D
Title:
Post by: Dessamator on 16 May, 2005, 19:15:13
ur welcome,  :]
Title:
Post by: catwo on 17 May, 2005, 20:44:47
Dessamator any chance of an edit to the script so that if they already have the prefix [XXX] the script doesn't generate another one?  At the moment i have some users with names like [XXX][XXX]Dessamator.  Thanks in advance for any help.
Title:
Post by: Dessamator on 17 May, 2005, 22:12:27
hmm, it shouldnt happen unless the the user isnt regged, but ok ill change the script asap
Title:
Post by: jiten on 17 May, 2005, 22:56:28
Give this a try:
-- By Dessamator
-- Simple Regme bot with hub checker
-- Prefix checker by jiten

bot = frmHub:GetHubBotName()
Maxhubs = 10

function ChatArrival(user,data)
local data = string.sub(data,1,-2)
local s,e,cmd =string.find(data, "%b<>%s+(%S+)")
local Prefix = "[XXX]" -- Set your prefix here
if cmd == "!regme" then
if string.find(string.lower(user.sName),string.lower(Prefix)) then Prefix = "" end
local pass=math.random(os.date("%H%M%S"))
if not(user.bRegistered) and not ( frmHub:isNickRegged(Prefix..user.sName) ) and user.iHubs < Maxhubs then
AddRegUser(Prefix..user.sName, pass, 3)
user:SendData(bot,"U've been registered with the Nick :"..Prefix..user.sName.." and password:"..pass)
elseif user.iHubs > Maxhubs then
user:SendData(bot,"Max hubs allowed here is "..Maxhubs..", you are currently in "..user.iHubs.." hubs, please reduce to "..Maxhubs.." then retype !regme in main chat")
else
user:SendData(bot,"You are Already Registered")
end
return 1
end
end
Title:
Post by: Dessamator on 17 May, 2005, 23:27:54
well done ! saves me the hassle, :)
Title:
Post by: catwo on 18 May, 2005, 07:19:53
Works a treat, thanks jiten & Dessamator for taking the time to help me and other non script writers out, its much appreciated.  :D
Title:
Post by: Dessamator on 18 May, 2005, 09:50:35
ur welcome !
Title:
Post by: jiten on 18 May, 2005, 10:08:54
Anytime catwo... Btw, small update in the code...

Cheers
Title:
Post by: catwo on 19 May, 2005, 19:29:11
Hmmmm getting the odd one registering and in Ptokax Reg list not showing the [XXX] prefix, any ideas? Thanks in advance.
Title:
Post by: Dessamator on 19 May, 2005, 19:39:17
QuoteOriginally posted by catwo
Hmmmm getting the odd one registering and in Ptokax Reg list not showing the [XXX] prefix, any ideas? Thanks in advance.

hmm?, i didnt understand ur post, the "odd one registering "?????
Title:
Post by: catwo on 19 May, 2005, 19:53:49
Sorry m8 i'll try again.  I get the odd user registering in hub but they dont have the [XXX] prefix.  e.g. when i look in the registered users list i see catwo instead of [XXX]catwo and catwo is showing as (REG) in the user list.
Title:
Post by: jiten on 19 May, 2005, 20:10:42
QuoteOriginally posted by catwo
Sorry m8 i'll try again.  I get the odd user registering in hub but they dont have the [XXX] prefix.  e.g. when i look in the registered users list i see catwo instead of [XXX]catwo and catwo is showing as (REG) in the user list.
Testing it some minutes ago with both type of nicks and it's working well.
Btw, did that user reconnect with the new nick or just registered himself?

Cheers
Title:
Post by: catwo on 19 May, 2005, 20:21:16
They are showing in user list as {REG} without the prefix and when i look in Ptokax OPs/Bans registered users they are showing in the list without the [XXX] prefix?
Title:
Post by: Dessamator on 19 May, 2005, 21:11:56
hmm, i also tested it try copying the script again, the last one shouldnt have any bugs