PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: Themaster on 10 November, 2004, 19:40:27

Title: help me with Hubtag
Post by: Themaster on 10 November, 2004, 19:40:27
Hey ppl.. i have made a regme function on my script.. But it don't past the Hubtag in the ptokax :s...

elseif cmd =="regme" and not user.bOperator then
local _,_,cmd,AddPass = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
if (AddPass ~= nil and strfind(AddPass, "%W") == nil) then
AddRegUser(user.sName, AddPass,3)
user:SendData(BotName," "..user.sName.."  *** You have been succesfull added as new Registred user!! ***")
         user:SendData(BotName, "Your password is:  "..AddPass.."  Reconnect and use that!!")
         user:SendData(BotName, "Your HubTag is: "..HubTag.." Put in to the favorits hub")
else
user:SendData(BotName," Syntax: !regme ***");
end
return 1


;)
Title:
Post by: ((UKSN))shad_dow on 10 November, 2004, 19:51:02
dear TheMaster

heres a regme script i found in my scripts bank , hopefully u get the idea as it does what u wont and inforces the hub tag too

hope it helps

shad

------------------------------------------------------------------
-- Ozzy's
-- __  __  ___  _  _  ___  ___   ___  _____  ___
-- |  \/  ||_ _|| \| ||_ _|| _ ) / _ \|_   _|/ __|
-- | |\/| | | | | .` | | | | _ \| (_) | | |  \__ \
-- |_|  |_||___||_|\_||___||___/ \___/  |_|  |___/
--
-- Minibots are a series of small helper bots for the
-- Ptokax DC hub program (ptokax.box.cz).
-- I write them while trying to understand how the hub works
-- and the language they are written in: Lua (www.lua.org).
-- Better bots can be found at lua.bcs-solutions.de.
------------------------------------------------------------------
--
-- Name: REGGY
-- What: To register users
-- How: Use this code as a standalone minibot or cut and
-- paste the each piece into your main bot.
-- Where: PtokaX Hub 0.3.2.6 TestDrive 4
-- Need: File 'http.mod' in same directory as bot.
--
--                        Ricardo Menezes
--                            ("Ozzy")
--                            JUL/2003
--
--                     ???)(??`erra  (?\_)ova
--
--                  dchub://hub-terranova.no-ip.com
--                  http://web-terranova.no-ip.com
--
--                          Bras?lia, DF
--                             BRASIL
--
------------------------------------------------------------------

sBotName = "Reggy" -- Formal bot name.
bStartOnLine = 1 -- Register bot at startup?
nRegUserIndex = 3 -- Just to make sure it doesn't get mixed up
bForcePrefix = 1 -- Make registered users wear hub prefix?
sHubPrefix = "[???]" -- The hub prefix
aHubMsg = {
BadRegCmd = "Use !regme psw repeatpsw",
PswDontMatch = "Passwords don't match. Try again.",
DupeUser = "Can?t use your nick as it is. Logon again with a different one.",
LogonAgain = "Registration complete. Please logon again using your new nick.",
DoneReg = "Registration complete. Don't forget to use your password when you return.",
RegNickUsed = "Sorry... Only registered users may have a nick like yours. Try a different one."
}

function Main()
------------------------------------------------------------------
if (bStartOnLine) then
frmHub:RegBot(sBotName)
else
frmHub:UnregBot(sBotName)
end
end

function DataArrival(oUser,sData)
------------------------------------------------------------------

local sNick = oUser.sName
local _, _, sCmd, sArg = strfind(sData, "%b<>%s+(%S+)%s*([^|]*)%|$")

if sCmd then
sCmd = strlower(sCmd)
if sCmd == "!regme" then -- Cmd is register me?
-- Don't echo it back.
local _, _, sPsw1, sPsw2 = strfind(sArg, "(%S+)%s+(%S+)")
if sPsw1 and sPsw2 then -- Both passwords present?
if sPsw1 == sPsw2 then -- Both passwords match?
if bForcePrefix then -- Is prefix mandatory?
local sNewNick = sHubPrefix..sNick
local oUserProfile = GetItemByName(sNewNick)
if not oUserProfile then -- Seat taken?
AddRegUser(sNewNick, sPsw1, nRegUserIndex) -- Register with new nick!
oUser:SendData(sBotName, aHubMsg.LogonAgain) -- Tell user to logon again.
oUser:Disconnect() -- This way the user will do as told.
else
oUser:SendData(sBotName, aHubMsg.DupeUser) -- Show user already exists.
end
else
AddRegUser(sNick, sPsw1, nRegUserIndex) -- Register with same nick!
oUser:SendData(sBotName, aHubMsg.DoneReg) -- Tell user it's done.
end
else
oUser:SendData(sBotName, aHubMsg.PswDontMatch) -- Show psws must match.
end
else
oUser:SendData(sBotName, aHubMsg.BadRegCmd) -- Show proper syntax.
end
return 1 -- Quit processing cmds.
end

end

end

function NewUserConnected(oUser)
-------------------------------------------------
local sNick = oUser.sName

if bForcePrefix then -- Is prefix being enforced?
if (strfind(sNick, sHubPrefix)) and
(oUser.iProfile ~= nRegUserIndex) then -- Check nick
oUser:SendData(sBotName, aHubMsg.RegNickUsed) -- Say so
oUser:Disconnect()
return 1
end
end
end

Title:
Post by: Themaster on 10 November, 2004, 20:09:56
now there are 2 thinks that don't work...

  elseif cmd =="regme" and not user.bOperator then
local _,_,cmd,AddPass = strfind( data, "%b<>%s+(%S+)%s+(.+)" )
if (AddPass ~= nil and strfind(AddPass, "%W") == nil) then
AddRegUser(HubTag .."user.sName".. AddPass,3)
         user:SendPM(BotName," "..user.sName.."   You have been succesfull added as new Registred user!! ***")
         user:SendPM(BotName, "Your password is:  "..AddPass.."  Reconnect and use that!!")
         user:SendPM(BotName, "Your HubTag is: "..HubTag.." ")
         user:SendPM(BotName, "Please put the information into the favorits to this hub")
         return 1
else
user:SendData(BotName," Syntax: regme ***");
end
return 1

and i can't get a login check off the hubtag

it is [BLA]nick

I DO NEED HELP
Title:
Post by: ((UKSN))shad_dow on 13 November, 2004, 21:13:39
There ya go all fixed

HubTag = "[test]"

BotName = "Hubtag"
function DataArrival(user,data)

local _,_,cmd,AddPass = strfind( data, "%b<>%s+(%S+)%s+(.+)" )

if cmd =="+regme" and not user.bOperator then

if (AddPass ~= nil and strfind(AddPass, "%W") ~= nil) then
AddRegUser(HubTag..user.sName, AddPass, 3)
         user:SendPM(BotName," "..HubTag..user.sName.."   You have been succesfull added as new Registred user!! ***")
         user:SendPM(BotName, "Your password is:  "..AddPass.."  Reconnect and use that!!")
         user:SendPM(BotName, "Please put the information into the favorits to this hub")
         return 1
else
user:SendData(BotName," Syntax: regme ***");
end
return 1
end
end



yours

shad