PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: 6Marilyn6Manson6 on 06 May, 2005, 14:36:16

Title: PASSWORD CHANGER BOT
Post by: 6Marilyn6Manson6 on 06 May, 2005, 14:36:16
--## PASSWORD CHANGER BOT
--## Request by 6Marilyn6Manson6
--## Made by nErBoS
--## Converted in LUA 5 by 6Marilyn6Manson6 at 06/05/2005
--## Commands:
--## +changepass - Changes your password

sBot = "PC-Bot"

function Main()
frmHub:RegBot(sBot)
end

function ChatArrival(user, data)
if (string.sub(data,1,1) == "<" or string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot) then
data = string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if (cmd == "+changepass") then
local s,e,sPass = string.find(data, "%b<>%s+%S+%s+(%S+)")
if (sPass == nil) then
user:SendPM(sBot, "Syntax Error, +changepass , you must write a password.")
elseif (user.iProfile == -1) then
user:SendPM(sBot, "You aren't regged, so you don't have a password.")
elseif (string.find(sPass, "[%c|\n\r]")) then
user:SendPM(sBot, "Invalid Password. Try Again.")
elseif (string.find(user.sName, "[%c|\n\r]")) then
user:SendPM(sBot, "Your nick is invalid. Please choose a new one.")
else
AddRegUser(user.sName,sPass,user.iProfile)
user:SendPM(sBot, "Your password has been changed to: "..sPass.." . Please recconect to make effect.")
end
return 1
end
end
end

c ya
Title:
Post by: jiten on 06 May, 2005, 14:43:49
There's no need for this in Lua 5:
if (string.sub(data,1,1) == "<" or string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot) thenThe $To part is related to ToArrival so, changing the password in PM won't work while u don't remove that part and add this:
function ToArrival(user, data)
local s,e,to,from,text = string.find(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == sBot then
-- your code
end
end

Best regards
Title:
Post by: 6Marilyn6Manson6 on 06 May, 2005, 14:51:17
QuoteOriginally posted by jiten
There's no need for this in Lua 5:
if (string.sub(data,1,1) == "<" or string.sub(data,1,5+string.len(sBot)) == "$To: "..sBot) thenThe $To part is related to ToArrival so, changing the password in PM won't work while u don't remove that part and add this:
function ToArrival(user, data)
local s,e,to,from,text = string.find(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == sBot then
-- your code
end
end

Best regards


Yes... but... work ;)
Title:
Post by: kepp on 06 May, 2005, 14:55:41
Ofcorse it works, but you are parsing things that are not needed
Title:
Post by: jiten on 06 May, 2005, 15:04:37
QuoteOriginally posted by kepp
Ofcorse it works, but you are parsing things that are not needed
Indeed, but, that was just an example, as I just stripped the code and modded it fastly and didn't notice I was parsing unnecessary stuff ;)

Btw Marilyn, in PM it won't.

Cheers
Title:
Post by: 6Marilyn6Manson6 on 06 May, 2005, 15:05:58
QuoteOriginally posted by jiten
QuoteOriginally posted by kepp
Ofcorse it works, but you are parsing things that are not needed
Indeed, but, that was just an example, as I just stripped the code and modded it fastly and didn't notice I was parsing unnecessary stuff ;)

Btw Marilyn, in PM it won't.

Cheers

I don't have test it in pm :P test now hiihhihi
Title:
Post by: 6Marilyn6Manson6 on 06 May, 2005, 15:13:03
--## PASSWORD CHANGER BOT
--## Request by 6Marilyn6Manson6
--## Made by nErBoS
--## Converted in LUA 5 by 6Marilyn6Manson6 at 06/05/2005
--## Fixed Bug with ChangePass in PM (tnk Jiten)
--## Commands:
--## +changepass - Changes your password

sBot = "PC-Bot"

function Main()
frmHub:RegBot(sBot)
end

function ChatArrival(user, data)
data = string.sub(data,1,string.len(data)-1)
local s,e,cmd = string.find(data, "%b<>%s+(%S+)")
if (cmd == "+changepass") then
local s,e,sPass = string.find(data, "%b<>%s+%S+%s+(%S+)")
if (sPass == nil) then
user:SendPM(sBot, "Syntax Error, +changepass , you must write a password.")
elseif (user.iProfile == -1) then
user:SendPM(sBot, "You aren't regged, so you don't have a password.")
elseif (string.find(sPass, "[%c|\n\r]")) then
user:SendPM(sBot, "Invalid Password. Try Again.")
elseif (string.find(user.sName, "[%c|\n\r]")) then
user:SendPM(sBot, "Your nick is invalid. Please choose a new one.")
else
AddRegUser(user.sName,sPass,user.iProfile)
user:SendPM(sBot, "Your password has been changed to: "..sPass.." . Please recconect to make effect.")
end
return 1
end
end

function ToArrival(user, data)
local s,e,to,from,text = string.find(data, "%$To:%s(%S+)%sFrom:%s(%S+)%s$(.*)$")
if to == sBot then
ChatArrival(user, data)
end
end

now work in pm hiihihih [tnk jiten ;)] c ya