PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: DorianG on 23 January, 2004, 02:51:06

Title: Bot Change-Password
Post by: DorianG on 23 January, 2004, 02:51:06
It's a litle and fine Bot :D
Is a Bot that you can use to all user livel. Is not limitate. But you haven't problem, because the user change only his password. :D


--********************************************************--
--********************************************************--
--**                     **--
--**   In this Bot the users livels are settings:   **--
--**                     **--
--**   Newbie = lvl 0               **--
--**   Reg = lvl 1               **--
--**   Vip = lvl 2               **--
--**                     **--
--**                     **--
--********************************************************--
--********************************************************--

BotName = "Change-Pass"

function Main()
   frmHub:RegBot(BotName)
end

function DataArrival(user, data)
   if (strsub(data,1,1) == "<") then
      data = strsub(data,1,strlen(data)-1)
      local s,e,cmd = nil
      s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
      --//Command ChangePass
      if (cmd=="!changepass" or cmd=="!chpass" or cmd=="!Changepass") then
         if (user.iProfile == nil) then
            user:SendPM(BotName, "You are not registered, so you are not allow to use this command")
         elseif (user.iProfile == 0 or user.iProfile == 1 or user.iProfile == 2) then  --//Here you can change the users livel
            s,e,cmd,pwd = strfind(data, "%b<>%s(%S+)%s(%S+)")
            local usr = user.sName
            local lvl = user.iProfile
            SendToOps(BotName, "The user "..usr.." have change the password in: " ..pwd)
            AddRegUser(usr, pwd, lvl)
            user:SendPM(BotName, "The registration of the new password has stayed effected with success, now your new password is: " ..pwd)
         elseif (user.bOperator) then
            s,e,cmd,pwd = strfind(data, "%b<>%s(%S+)%s(%S+)")
            local usr = user.sName
            local lvl = user.iProfile
            AddRegUser(usr, pwd, lvl)
            user:SendPM(BotName, "The registration of the new password has stayed effected with success, now your new password is: " ..pwd)
         end
      end
   end
end
Title:
Post by: plop on 23 January, 2004, 03:52:19
if (user.iProfile == nil) then
this never happens, unregistered users have the profile number -1.
not a bug or anything bad but master = 0, operator = 1, vip = 2, reg = 3.
some hubowners might be offended if you call them newbies. lol

plop
Title:
Post by: DorianG on 23 January, 2004, 13:48:45
ehehhe.. Sorry Owners or Masters.. ehehe.. I didn't want to offend you. Is only an exaple. You can set the user livel here:

elseif (user.iProfile == 0 or user.iProfile == 1 or user.iProfile == 2) then

:D
Thanks plop. You have save me from a lynching  :D
Title:
Post by: plop on 24 January, 2004, 04:30:12
QuoteOriginally posted by DorianG
ehehhe.. Sorry Owners or Masters.. ehehe.. I didn't want to offend you. Is only an exaple. You can set the user livel here:

elseif (user.iProfile == 0 or user.iProfile == 1 or user.iProfile == 2) then

:D
Thanks plop. You have save me from a lynching  :D
yw.

plop
Title:
Post by: HaL on 28 January, 2004, 12:24:52
hi @all


nice script
 can some 1 change it a littlebit 4me?
1. I don?t want to see the bot in my hub

i did it with

function Main()
-- frmHub:RegBot(BotName)
end

ok and
2.
if i wrote !chpass in mainchat
everyone could see the cmd and passwd ...
could some one change it that the cmd  is not visible in mainchat?

thx
;-) HaL
Title:
Post by: pHaTTy on 28 January, 2004, 12:35:52
no only u still see it, but change the user:SendPM to user:SendData
Title:
Post by: plop on 28 January, 2004, 15:57:04
QuoteOriginally posted by (uk-kingdom)pH?tt?
no only u still see it, but change the user:SendPM to user:SendData
the return 1's were missing so indeed every1 could see it.

fixed and optimized it a little bit.
give it a try.
--********************************************************--
--********************************************************--
--** **--
--** In this Bot the users livels are settings: **--
--** **--
--** Newbie = lvl 5 **--
--** Reg = lvl 3 **--
--** Vip = lvl 2 **--
--** **--
--** **--
--********************************************************--
--********************************************************--

BotName = "Change-Pass"

function Main()
   frmHub:RegBot(BotName)
end

function DataArrival(user, data)
   if (strsub(data,1,1) == "<") then
      data = strsub(data,1,strlen(data)-1)
      local s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
      --//Command ChangePass
      if (cmd=="!changepass" or cmd=="!chpass" or cmd=="!Changepass") then
         if (user.iProfile == -1) then
            user:SendPM(BotName, "You are not registered, so you are not allow to use this command|")
         else
            local s,e,pwd = strfind(data, "%b<>%s%S+%s*(%S*)")
            if pwd == "" then
               user:SendPM(BotName, "Pls give me your new password, i can't fill in blancs|")
               return 1
            elseif (user.bOperator) then
               AddRegUser(user.sName, pwd, user.iProfile)
               user:SendPM(BotName, "The registration of the new password has stayed effected with success, now your new password is: " ..pwd.."|")
               return 1
            elseif (user.iProfile == 3 or user.iProfile == 2) then --//Here you can change the users livel
               SendToOps(BotName, "The user "..user.sName.." have change the password in: " ..pwd.."|")
               AddRegUser(user.sName, pwd, user.iProfile)
               user:SendPM(BotName, "The registration of the new password has stayed effected with success, now your new password is: " ..pwd.."|")
               return 1
            end
         end
      end
   end
end
plop
Title:
Post by: HaL on 28 January, 2004, 19:07:49
hey @all

i tested it on a test drive 4 hub
with one op and one user
!chpass

is visible 4everyone not only 4me, not only 4ops!

and now the last version doesn?t work anymore

Syntax Error: `)' expected (to close `(' at line 61);
  last token read: `return' at line 63 in file `...instellungen\hal\Desktop\PtokaX-0.326.TestDrive4\scripts\chpass.lua'


???
Title:
Post by: pHaTTy on 28 January, 2004, 20:03:19
QuoteOriginally posted by plop
QuoteOriginally posted by (uk-kingdom)pH?tt?
no only u still see it, but change the user:SendPM to user:SendData
the return 1's were missing so indeed every1 could see it.



eheh shows how much attention i payed, its because its not [code]ed
Title:
Post by: HaL on 28 January, 2004, 21:57:20
QuoteOriginally posted by plop

            if pwd == "" then
               user:SendPM(BotName, "Pls give me your new password, i can't fill in blancs|"
               return 1
           



here is the error ;-)

you have to close the
user:SendPM(BotName............       with a )

gretz HaL
Title:
Post by: plop on 28 January, 2004, 23:24:31
QuoteOriginally posted by HaL
QuoteOriginally posted by plop

            if pwd == "" then
               user:SendPM(BotName, "Pls give me your new password, i can't fill in blancs|"
               return 1
           



here is the error ;-)

you have to close the
user:SendPM(BotName............       with a )

gretz HaL
thats what happens if i start coding after only 1 mug of coffee. lol
i've fixed the code above.

plop