PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: D-J Valhala on 20 July, 2004, 15:33:58

Title: script needed :)
Post by: D-J Valhala on 20 July, 2004, 15:33:58
+connect                   -       Show Whan User Connacting To Hub Untill The OP remove the user from the list(All OP's Can Use This CMD And Each OP have diffrent Connect list)

+connectoff               -       Stop Connecting MSG

+connectlist - Show the users that are in connect log

+mypass - Show The User Password to the hub

+myclass  - Show To User the class (No Regged Vip op and so on )  :P

+passwordlist - Will Show Me All REG's/ViP's/SuperViP's/OP's/SuperOp's/Masters Nick ==>password (Only Masters can use this command!)

+repass - Change User PassWord (All Users Can Use This)

+repass - Master Can Change user Password (Only Masters can use this command!)

thenks  :D
Title:
Post by: nErBoS on 20 July, 2004, 23:00:43
Hi,

Didn?t understand the commands...

+connect - Show Whan User Connacting To Hub Untill The OP remove the user from the list(All OP's Can Use This CMD And Each OP have diffrent Connect list)

+connectoff - Stop Connecting MSG

Can you give us examples, and about the +passwordlist i need the number of all of your profiles.

Best regards, nErBoS
Title:
Post by: D-J Valhala on 20 July, 2004, 23:33:57
ok here we go
========================================
+connect DJ-Valhala
<-PsYiBot-> User DJ-Valhala is beed wached by DJ-Valhala

now if i disconnect and reconnect to the hub the bot will send to me in PM

<-PsYiBot-> User DJ-Valhala Connected To The Hub In 11:30 AM

+connectoff DJ-Valhala
<-PsYiBot-> User DJ-Valhala is beed removed from wach!

now to each OP there is a connect list

+connect DJ-Valhala
<-PsYiBot-> User DJ-Valhala is beed wached by GuY

and ONLY GuY will see whan i'm connecting  :D
========================================
Profiles Are
========================================
0|Master
1|Operator
2|VIP
3|Reg
4|Super OP
5|Super VIP
========================================
thanks alot mate  :D  :D  :D  :D  :D
Title:
Post by: nErBoS on 21 July, 2004, 02:30:25
Hi,

Hope it helps...

--## Multi-Function Bot
--## Made by nErBoS
--## Requested by D-J Valhala
--## Commands:
--## +connect - Show Whan User Connacting To Hub Untill The OP remove the user from the list
--## +connectoff - Stop Connecting MSG
--## +connectlist - Show the users that are in connect log
--## +mypass - Show The User Password
--## +myclass - Show To User the class
--## +passwordlist - Will Show All REG's/ViP's/SuperViP's/OP's/SuperOp's/Masters password
--## +repass - Change User PassWord
--## +changepass - Master Can Change user Password


sBot = "Multi-Func"

fRegDat = "../RegisteredUsers.dat"
arrWatch = {}
fWatch = "watch.dat"

--## Configuration ##--

iProfiles = 6 --## The number of how many profiles do you have
verPtokax = 1 --## Choose 0 for ptokax version lower then 0.3.3.0
--## Choose 1 for ptokax versions 0.3.3.0 or higher

--## END of Configuration ##--

function Main()
frmHub:RegBot(sBot)
LoadFromFile(fWatch)
end

function OnExit()
SaveToFile(fWatch , arrWatch , "arrWatch")
end

function NewUserConnected(user)
LogWatched(user, "Logged in  at "..GetTime())
end

function UserDisconnected(user)
LogWatched(user, "Logged out at "..GetTime())
end

function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+connect") then
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sBot, "Syntax Error, +connect , you must write a nick.")
elseif (arrWatch[user.sName] == nil) then
arrWatch[user.sName] = {}
arrWatch[user.sName][strlower(nick)] = "Waiting for something..."
user:SendPM(sBot, "The user "..nick.." is now been watched by you.")
if (verPtokax == 0) then
OnExit()
end
elseif (arrWatch[user.sName][strlower(nick)] ~= nil) then
user:SendPM(sBot, "The user "..nick.." is already been watched.")
else
arrWatch[user.sName][strlower(nick)] = "Waiting for something..."
user:SendPM(sBot, "The user "..nick.." is now been watched by you.")
if (verPtokax == 0) then
OnExit()
end
end
return 1
elseif (cmd == "+connectoff") then
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sBot, "Syntax Error, +connectoff , you must write a nick.")
elseif (arrWatch[user.sName] == nil) then
user:SendPM(sBot, "You don't have anyone to be watched.")
elseif (arrWatch[user.sName][strlower(nick)] == nil) then
user:SendPM(sBot, "The user "..nick.." is not been watched by you.")
else
arrWatch[user.sName][strlower(nick)] = nil
user:SendPM(sBot, "The user "..nick.." is no longer been watched by you.")
if (verPtokax == 0) then
OnExit()
end
end
return 1
elseif (cmd == "+connectlist" and user.bOperator) then
if (arrWatch[user.sName] == nil) then
user:SendPM(sBot, "You don't have anyone to be watched.")
else
ShowWatched(user)
end
return 1
elseif (cmd == "+mypass") then
if (CheckIfRegged(user.sName) == 0) then
user:SendPM(sBot, "You aren't register in this HUB.")
else
user:SendPM(sBot, "Your password is: "..CheckIfRegged(user))
end
return 1
elseif (cmd == "+myclass") then
if (user.iProfile == -1) then
user:SendPM(sBot, "Your Class is: UNREG.")
else
user:SendPM(sBot, "Your Class is: "..GetProfileName(user.iProfile))
end
return 1
elseif (cmd == "+passwordlist" and user.iProfile == 0) then
ShowAllPass(user)
return 1
elseif (cmd == "+repass") then
local s,e,pass = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (pass == nil) then
user:SendPM(sBot, "Syntax Error, +repass , you must write a password.")
elseif (user.iProfile == -1) then
user:SendPM(sBot, "You are not registered in this HUB.")
else
AddRegUser(user.sName, pass, user.iProfile)
user:SendPM(sBot, "Your password as been changed to: "..pass)
end
return 1
elseif (cmd == "+changepass" and user.iProfile == 0) then
local s,e,nick,pass,profile = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)")
if (nick == nil or pass == nil) then
user:SendPM(sBot, "Syntax Error, +changepass , you must write a nick and a password.")
elseif (GetItemByName(nick) == nil) then
if (CheckIfRegged(nick) == 0) then
user:SendPM(sBot, "The user "..nick.." is not registered in this HUB.")
else
nick,profile = CheckForName(nick)
AddRegUser(nick, pass, profile)
user:SendPM(sBot, "The password of the user "..nick.." as been changed to: "..pass)
end
elseif (GetItemByName(nick).iProfile == -1) then
user:SendPM(sBot, "The user "..nick.." is not registered in this HUB.")
else
AddRegUser(GetItemByName(nick).sName, pass, GetItemByName(nick).iProfile)
user:SendPM(sBot, "The password of the user "..nick.." as been changed to: "..pass)
end
return 1
end
end
end

function CheckIfRegged(usr)
readfrom(fRegDat)
while 1 do
local sLine = read()
if (sLine == nil) then
readfrom()
return 0
else
local s,e,nick,pass = strfind(sLine, "(.+)|(.+)|.+")
if (nick ~= nil and pass ~= nil and strlower(nick) == strlower(usr)) then
readfrom()
return pass
end
end
end
end

function CheckForName(nick)
local profile = 0
while profile < iProfiles do
local usr,aux
for aux, usr in GetUsersByProfile(GetProfileName(profile)) do
if (strlower(usr) == strlower(nick)) then
return usr,profile
end
end
profile = profile + 1
end
return "ERROR"
end

function ShowWatched(user)
local sTmp,usr,data = "List of Users watched by you:\r\n\r\n"
for usr, data in arrWatch[user.sName] do
sTmp = sTmp.."User: "..usr.."\tStatus: "..data.."\r\n"
end
user:SendPM(sBot, sTmp)
end

function LogWatched(user, data)
local op,usr,aux,aux2
for op, aux in arrWatch do
for usr, aux2 in arrWatch[op] do
if (usr == strlower(user.sName)) then
arrWatch[op][usr] = data
if (GetItemByName(op) ~= nil) then
GetItemByName(op):SendPM(sBot, "The user has "..data)
end
return
end
end
end
end

function ShowAllPass(user)
local profile,sTmp = 0,"The List of all passwords in the HUB:\r\n\r\n"
while profile < iProfiles do
local usr,aux
sTmp = sTmp.."--## "..GetProfileName(profile).." ##--\r\n\r\n"
for aux, usr in GetUsersByProfile(GetProfileName(profile)) do
sTmp = sTmp.."User: "..usr.."\tPassword: "..CheckIfRegged(usr).."\r\n"
end
sTmp = sTmp.."\r\n"
profile = profile + 1
end
user:SendPM(sBot, sTmp)
end

function GetTime()
s = date("%S")
h = date("%H")
m = date("%M")
d = date("%d")
mm = date("%m")
y = date("%y")
Date = "Day: "..d.."/"..mm.."/20"..y.." Hour: "..h..":"..m..":"..s
return Date
end

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

sTab = sTab or "";
sTmp = ""

sTmp = sTmp..sTab..sTableName.." = {\n"

for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end

sTmp = sTmp..",\n"
end

sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end

Best regards, nErBoS
Title:
Post by: D-J Valhala on 21 July, 2004, 04:32:49
scripts work perfect exept +mypass  :D

can you add +getpass - Masters Get The User Password :D

and can you add a "Total: 12" in +passwordlist and in +connectlist like
=========== Super VIP ===========

User: -=Geta=-   Password: *****
User: charlie   Password: *****
User: Corayzon   Password: *****

Total: 3
==============================
and so on
password with "*****" coz i can't show my users passwords :P

and in +connectlist can you add online/offline

<-PsYiBot-> The user has Logged out at Day: 21/07/2004 Hour: 09:49:49  
where is the user name? :P

and i dont want it to show mypass in the list:)

maybe i send you my addited scripts in the hub? :)
Title:
Post by: nErBoS on 21 July, 2004, 16:34:23
Hi,

Try out this one...

--## Multi-Function Bot
--## Made by nErBoS
--## Requested by D-J Valhala
--## Added a User Imune to see password and change
--## Commands:
--## +connect - Show Whan User Connacting To Hub Untill The OP remove the user from the list
--## +connectoff - Stop Connecting MSG
--## +connectlist - Show the users that are in connect log
--## +mypass - Show The User Password
--## +myclass - Show To User the class
--## +passwordlist - Will Show All REG's/ViP's/SuperViP's/OP's/SuperOp's/Masters password
--## +repass - Change User PassWord
--## +changepass - Master Can Change user Password
--## +getpass - Get The User Password  


sBot = "Multi-Func"

fRegDat = "../RegisteredUsers.dat"
arrWatch = {}
fWatch = "watch.dat"

--## Configuration ##--

iProfiles = 6 --## The number of how many profiles do you have
verPtokax = 1 --## Choose 0 for ptokax version lower then 0.3.3.0
--## Choose 1 for ptokax versions 0.3.3.0 or higher
sImuneUser = "Nick" --## User Imune to show the password

--## END of Configuration ##--

function Main()
frmHub:RegBot(sBot)
LoadFromFile(fWatch)
end

function OnExit()
SaveToFile(fWatch , arrWatch , "arrWatch")
end

function NewUserConnected(user)
LogWatched(user, "Logged in  at "..GetTime().." [ONLINE]")
end

function UserDisconnected(user)
LogWatched(user, "Logged out at "..GetTime().." [OFFLINE]")
end

function DataArrival(user, data)
if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
data = strsub(data,1,strlen(data)-1)
s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "+connect") then
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sBot, "Syntax Error, +connect , you must write a nick.")
elseif (arrWatch[user.sName] == nil) then
arrWatch[user.sName] = {}
arrWatch[user.sName][strlower(nick)] = "Waiting for something..."
user:SendPM(sBot, "The user "..nick.." is now been watched by you.")
if (verPtokax == 0) then
OnExit()
end
elseif (arrWatch[user.sName][strlower(nick)] ~= nil) then
user:SendPM(sBot, "The user "..nick.." is already been watched.")
else
arrWatch[user.sName][strlower(nick)] = "Waiting for something... [ONLINE/OFFLINE]"
user:SendPM(sBot, "The user "..nick.." is now been watched by you.")
if (verPtokax == 0) then
OnExit()
end
end
return 1
elseif (cmd == "+connectoff") then
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sBot, "Syntax Error, +connectoff , you must write a nick.")
elseif (arrWatch[user.sName] == nil) then
user:SendPM(sBot, "You don't have anyone to be watched.")
elseif (arrWatch[user.sName][strlower(nick)] == nil) then
user:SendPM(sBot, "The user "..nick.." is not been watched by you.")
else
arrWatch[user.sName][strlower(nick)] = nil
user:SendPM(sBot, "The user "..nick.." is no longer been watched by you.")
if (verPtokax == 0) then
OnExit()
end
end
return 1
elseif (cmd == "+connectlist" and user.bOperator) then
if (arrWatch[user.sName] == nil) then
user:SendPM(sBot, "You don't have anyone to be watched.")
else
ShowWatched(user)
end
return 1
elseif (cmd == "+mypass") then
if (CheckIfRegged(user.sName) == 0) then
user:SendPM(sBot, "You aren't register in this HUB.")
else
user:SendPM(sBot, "Your password is: "..CheckIfRegged(user.sName))
end
return 1
elseif (cmd == "+myclass") then
if (user.iProfile == -1) then
user:SendPM(sBot, "Your Class is: UNREG.")
else
user:SendPM(sBot, "Your Class is: "..GetProfileName(user.iProfile))
end
return 1
elseif (cmd == "+passwordlist" and user.iProfile == 0) then
ShowAllPass(user)
return 1
elseif (cmd == "+repass") then
local s,e,pass = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (pass == nil) then
user:SendPM(sBot, "Syntax Error, +repass , you must write a password.")
elseif (user.iProfile == -1) then
user:SendPM(sBot, "You are not registered in this HUB.")
else
AddRegUser(user.sName, pass, user.iProfile)
user:SendPM(sBot, "Your password as been changed to: "..pass)
end
return 1
elseif (cmd == "+changepass" and user.iProfile == 0) then
local s,e,nick,pass,profile = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)")
if (nick == nil or pass == nil) then
user:SendPM(sBot, "Syntax Error, +changepass , you must write a nick and a password.")
elseif (GetItemByName(nick) == nil) then
if (CheckIfRegged(nick) == 0) then
user:SendPM(sBot, "The user "..nick.." is not registered in this HUB.")
else
if (strlower(nick) == strlower(sImuneUser)) then
user:SendPM(sBot, "You can't change the password of this user.")
else
nick,profile = CheckForName(nick)
AddRegUser(nick, pass, profile)
user:SendPM(sBot, "The password of the user "..nick.." as been changed to: "..pass)
end
end
elseif (GetItemByName(nick).iProfile == -1) then
user:SendPM(sBot, "The user "..nick.." is not registered in this HUB.")
else
if (strlower(nick) == strlower(sImuneUser)) then
user:SendPM(sBot, "You can't change the password of this user.")
else
AddRegUser(GetItemByName(nick).sName, pass, GetItemByName(nick).iProfile)
user:SendPM(sBot, "The password of the user "..nick.." as been changed to: "..pass)
end
end
return 1
elseif (cmd == "+getpass" and user.iProfile == 0) then
local s,e,nick = strfind(data, "%b<>%s+%S+%s+(%S+)")
if (nick == nil) then
user:SendPM(sBot, "Syntax Error, +getpass , you must write a nick.")
elseif (CheckIfRegged(nick) == 0) then
user:SendPM(sBot, "The user "..nick.." is not registered in the HUB.")
else
if (strlower(nick) == strlower(sImuneUser)) then
user:SendPM(sBot, "You can't see the password of this user.")
else
user:SendOM(sBot, "The password of the user "..nick.." is: "..CheckIfRegged(nick))
end
end
return 1
end
end
end

function CheckIfRegged(usr)
readfrom(fRegDat)
while 1 do
local sLine = read()
if (sLine == nil) then
readfrom()
return 0
else
local s,e,nick,pass = strfind(sLine, "(.+)|(.+)|.+")
if (nick ~= nil and pass ~= nil and strlower(nick) == strlower(usr)) then
readfrom()
return pass
end
end
end
end

function CheckForName(nick)
local profile = 0
while profile < iProfiles do
local usr,aux
for aux, usr in GetUsersByProfile(GetProfileName(profile)) do
if (strlower(usr) == strlower(nick)) then
return usr,profile
end
end
profile = profile + 1
end
return "ERROR"
end

function ShowWatched(user)
local sTmp,usr,data = "List of Users watched by you:\r\n\r\n"
for usr, data in arrWatch[user.sName] do
sTmp = sTmp.."User: "..usr.."\tStatus: "..data.."\r\n"
end
user:SendPM(sBot, sTmp)
end

function LogWatched(user, data)
local op,usr,aux,aux2
for op, aux in arrWatch do
for usr, aux2 in arrWatch[op] do
if (usr == strlower(user.sName)) then
arrWatch[op][usr] = data
if (GetItemByName(op) ~= nil) then
GetItemByName(op):SendPM(sBot, "The user "..usr.." has "..data)
end
return
end
end
end
end

function ShowAllPass(user)
local profile,sTmp = 0,"The List of all passwords in the HUB:\r\n\r\n"
while profile < iProfiles do
local count,usr,aux = 0
sTmp = sTmp.."--## "..GetProfileName(profile).." ##--\r\n\r\n"
for aux, usr in GetUsersByProfile(GetProfileName(profile)) do
if (strlower(usr) ~= strlower(sImuneUser)) then
sTmp = sTmp.."User: "..usr.."\tPassword: "..CheckIfRegged(usr).."\r\n"
count = count + 1
end
end
sTmp = sTmp.."Total: "..count.."\r\n"
sTmp = sTmp.."\r\n"
profile = profile + 1
end
user:SendPM(sBot, sTmp)
end

function GetTime()
s = date("%S")
h = date("%H")
m = date("%M")
d = date("%d")
mm = date("%m")
y = date("%y")
Date = "Day: "..d.."/"..mm.."/20"..y.." Hour: "..h..":"..m..":"..s
return Date
end

function Serialize(tTable, sTableName, sTab)
assert(tTable, "tTable equals nil");
assert(sTableName, "sTableName equals nil");

assert(type(tTable) == "table", "tTable must be a table!");
assert(type(sTableName) == "string", "sTableName must be a string!");

sTab = sTab or "";
sTmp = ""

sTmp = sTmp..sTab..sTableName.." = {\n"

for key, value in tTable do
local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

if(type(value) == "table") then
sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
else
local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
end

sTmp = sTmp..",\n"
end

sTmp = sTmp..sTab.."}"
return sTmp
end

function SaveToFile(file , table , tablename)
writeto(file)
write(Serialize(table, tablename))
writeto()
end

function LoadFromFile(file)
if (readfrom(file) ~= nil) then
readfrom(file)
dostring(read("*all"))
readfrom()
end
end

Best regards, nErBoS
Title:
Post by: D-J Valhala on 21 July, 2004, 18:15:49
hehe perfect  :D
thanks alot :P