PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: DorianG on 22 February, 2004, 19:34:20

Title: Problem with this script :(**
Post by: DorianG on 22 February, 2004, 19:34:20
To test my bot i use Ptokax 0.3.3.0 and for the user profile i use Profile.dat of Gekko. I have set my nick profile to 5. My problem is that the Bot doesn't Reg an user with these profile "5" and "6".
Please Help me :(**

--****************************************************************************--
--****************************************************************************--
--**** Qui puoi cambiare il nome del Bot, l'operazione ? sconsigliata :)  ****--
BotName = "???[Bot]M?GAPLATZ???"
--****************************************************************************--
--****************************************************************************--
--**** Qui potete settare il numero di messaggi random che vengono  ****--
--**** spediti dal bot a delle categorie di utenti quando entrano    ****--
--**** dentro l'hub.  ****--
nummsgop = 9
nummsgvip = 6
--**** Qui puoi settare i prefissi dei comandi  ****--
prefix = "!" --//Utilizzate questo prefisso solo per i comandi che non sono previsti dal ptokax
prefix2 = "+"
--**** Qui puoi settare le parole chiavi per lanciare i vari comandi  ****--
help = prefix2.."HELP" --//Comando di aiuto
network = prefix.."NETWORK" --//Comando che da informazioni sul network
report = prefix.."REPORT" --//Spedisce un PM a tutti gli Op
infouser = prefix.."INFOUSER" --//Spedisce informazioni su un utente
flood = prefix.."FLOOD" --//Floodi un messaggio
ban = prefix.."BAN" --//Banna un utente dall'hub
regme = prefix.."REGME" --//Permette ai non registrati di diventare newbie
chgpass = prefix.."CHANGEPASS" --//Permette ai registrati di cambiare la loro password
hubinfo = prefix.."HUBINFO" --//Informazioni dettagliate sull'hub
addreg = prefix.."ADDREG" --//Registrazione di un utente
disconnect = prefix.."DISCONNECT" --//Disconnette un utente
tban = prefix.."TBAN" --//Banna per 20 minuti un utente
--**** Messaggi Settabili per tutte le occasioni  ****--
reporterrormsg = "Il comando digitato ? sbagliato "..report.." "
mess5 = "L'utente"
because = "perch?:  "
Ban1 = "Non puoi toccare questo utente"
Ban2 = "Non puoi autodistruggerti"
Ban3 = "Hai sbagliato a digitare il comando digita "..ban.." "
Ban4 = "? stato bannato da:  "
Ban5 = "sei stato bannato da: "
mess1= "non ? presente nell'hub"
mess2= "si ? appena inserito nella lista dei newbie, contattalo per una regolare registrazione"
mess3= "? felice di comunicarti che presto verrai contattato da un Operatore per una registrazione regolare"
mess4= "Sei gi? registrato"
regme1= "hai sbagliato a digitare il comando digita "..regme.." "
changepass1 = "Non sei registrato, quindi nn hai l'autorizzazione ad utilizzare questo comando"
changepass2 = "ha cambiato la password in: "
changepass3 = "La registrazione della nuova password ? stata effetuata con successo, ora la tua nuova password ?: "
hubinfo1 = "Nome dell'hub:  "
hubinfo2 = "Descrizione dell'hub:  "
hubinfo3 = "In questo momento ci sono  "
hubinfo4 = "Il minimo share che devi possedere ?:  "
hubinfo5 = "In questo momento sono condivisi nell'hub:  "
hubinfo6 = "Il massimo numero di Hubs ai queli ? permesso connettersi ?:  "
hubinfo7 = "Il numero minimo di slots da tenere aperti ?:  "
hubinfo8 = "Il numero massimo di slots da tenere aperti ?:  "
hubinfo9 = "Numero consentito di slots aperti in relazione agli Hubs connessi ?:  "
hubinfo10 = "Il redirect ? puntato su:  "
hubinfo11 = "Il redirect nel caso in cui l'hub ? pieno ? puntato su:  "
hubinfo12 = "Indirizzo del server di registrazione dell'hub ?:  "
addreg1 = "? stato Registrato da: "
addreg2 = "? gi? registrato."
addreg3 = "hai sbagliato a digitare il comando digita "..addreg.." "
addreg4 = "Non hai l'autorizzazzione a registrare questo livello di utente"
disconnect1 = "sei stato disconnesso perch?:"
disconnect2 = "? stato sconnesso da"
disconnect3 = "Hai sbagliato a digitare il comando, digita "..disconnect.." "
timeban1 = "? stato bannato temporaneamente"
timeban2 = "Sei stato temporaneamente bannato per"
timeban3 = "Hai sbagliato a digitare il comando, devi digitare "..tban.." "
minutes = "minuti"
--****************************************************************************--
--**** Categorie protette  ****--
--****************************************************************************--
Protect1 = ""
Protect2 = ""
Protect3 = ""

RegOp = {"6", "5"} --//Qui puoi inserire i livelli di utente che un Op pu? registrare

TBan = 20 --//Setta il tempo del Ban Temporaneo

dofile("files/MsgOp.lua")
dofile("files/MsgVip.lua")

function Main()
frmHub:RegBot(BotName)
SendToAll(BotName.." "..date("lanciato il %d %B %Y alle ore %X"))
end

function OpConnected(user)
reply = RandomOpMsg(user)
SendToAll(BotName,reply)
end

function NewUserConnected(user)
if (user.iProfile == 5) then
reply = RandomVipMsg(user)
SendToAll(BotName,reply)
end
end

function ReadLine(user)
while 1 do
local line = read()
if line == nil then
break
else
user:SendPM(BotName, line)
end
end
readfrom()
end

function Flood(user, data)
s,e,cmd,str,num,msg = strfind(data, "%b<>%s(%S+)%s(%S+)%s(%S+)%s(%S+)")
if cmd ~= nil and str ~= nil and num ~= nil and msg ~= nil then
SendToNick(user.sName, BotName, "Hai floodato "..str.." per "..num.." volte con il messaggio  "..msg)
count = tonumber(num)
for z = 1, count do
SendPmToNick(str, BotName, msg)
end
elseif str == user.sName then
SendToNick(user.sName, "Non puoi auto floodarti")
end
return 1
end

function Ban(user, data)
s,e,cmd,str,reason = strfind(data, "%b<>%s(%S+)%s(%S+)%s(%S+)")
if str ~= nil and reason ~= nil then
if (str == Protect1 or str == Protect2 or str == Protect3) then
user:SendPM(BotName, Ban1)
elseif (str == user.sName) then
user:SendPM(BotName, Ban2)
else
local Userkick = GetItemByName(str)
SendToOps(BotName, ""..mess5.." "..str.." "..Ban4.." "..user.sName.." "..because.."  "..reason)
Userkick:Ban()
SendPmToNick(str, BotName, ""..Ban5.." "..user.sName.." "..because.."  "..reason)
end
else
user:SendPM(BotName, Ban3)
end
return 1
end

function ChangePass(user, data)
if (user.iProfile == -1) then
user:SendPM(BotName, changepass1)
elseif (user.iProfile == 6 or user.iProfile == 5) then
s,e,cmd,pwd = strfind(data, "%b<>%s(%S+)%s(%S+)")
local usr = user.sName
local lvl = user.iProfile
SendToOps(BotName, ""..mess5.." "..usr.." "..changepass2.."  " ..pwd)
AddRegUser(usr, pwd, lvl)
user:SendPM(BotName, ""..changepass3.."  " ..pwd)
return 1
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, ""..changepass3.."  " ..pwd)
return 1
end


end
Title:
Post by: DorianG on 22 February, 2004, 19:35:04
function ReportMsg(user, data)
s,e,cmd,msg = strfind(data, "%b<>%s(%S+)%s(.+)")
if msg ~= nil then
SendPmToOps(BotName, msg.. "  BY:  " ..user.sName)
SendPmToOps(BotName, "il suo IP ?:  " ..user.sIP)
else
SendToNick(user.sName, BotName, reporterrormsg)
end
return 1
end

function InfoUser(user, data)
s,e,cmd,str = strfind(data, "%b<>%s(%S+)%s(%S+)")
local usr = GetItemByName(str)
local message ="          ???US?R?~?INFO???     "
msg = message .."\r\n\t\t"
.. "Informazioni sull'utente: " ..usr.sName.."\r\n\t\t"
.. "IP: " ..usr.sIP.. "\t\r\n\t\t"
.. "Informazioni sulla Stringa: "..usr.sMyInfoString.."\r\n\t\t"
if usr ~= nil then
user:SendPM(BotName, msg)
else
user:SendPM(BotName, ""..mess5.." "..usr.sName.."  "..mess1)
end
return 1
end

function RegNewbie(user, data)
if (user.iProfile == -1) then
s,e,cmd,pwd = strfind(data, "%b<>%s(%S+)%s(%S+)")
if cmd ~= nil and pwd ~= nil then
local hubname = frmHub:GetHubName()
local usr = user.sName
SendPmToOps(BotName, ""..mess5.."  "..usr.."  "..mess2)
AddRegUser(usr, pwd, 6)
SendPmToNick(usr, BotName, ""..hubname.."  "..mess3)
else
user:SendPM(BotName, regme1)
end
else
user:SendPM(BotName, mess4)
return 1
end
end

function HubInfo(user, data)
user:SendPM(BotName, ""..hubinfo1.."  "..frmHub:GetHubName())
user:SendPM(BotName, ""..hubinfo2.."  "..frmHub:GetHubDescr())
user:SendPM(BotName, ""..hubinfo3.."  "..frmHub:GetUsersCount().." utenti")
user:SendPM(BotName, ""..hubinfo4.."  "..frmHub:GetMinShare().." Mb")
user:SendPM(BotName, ""..hubinfo5.."  "..frmHub:GetCurrentShareAmount().." Mb")
user:SendPM(BotName, ""..hubinfo6.."  "..frmHub:GetMaxHubs())
user:SendPM(BotName, ""..hubinfo7.."  "..frmHub:GetMinSlots())
user:SendPM(BotName, ""..hubinfo8.."  "..frmHub:GetMaxSlots())
user:SendPM(BotName, ""..hubinfo9.."  "..frmHub:GetSlotRatio())
user:SendPM(BotName, ""..hubinfo10.."  "..frmHub:GetRedirectAddress())
user:SendPM(BotName, ""..hubinfo11.."  "..frmHub:GetRedirectFull())
user:SendPM(BotName, ""..hubinfo12.."  "..frmHub:GetRegServer())
end

function AddRegOp(user, data)
s,e,cmd,str,pwd,lvl = strfind(data, "%b<>%s(%S+)%s(%S+)%s(%S+)%s(%S+)")
if cmd ~= nil and str ~= nil and pwd ~= nil and lvl ~= nil then
local usr = GetItemByName(str)
if (lvl == print(RegOp[1]) or lvl == print(RegOp[2])) then
if (usr.iProfile == -1) then
AddRegUser(str,pwd,lvl)
user:SendPM(BotName, ""..mess5.." "..usr.sName.." "..addreg1.." " ..user.sName)
else
user:SendPM(BotName, ""..mess5.." "..usr.sName.." "..addreg2)
end
else
user:SendPM(BotName, addreg4)
end
else
user:SendPM(BotName, addreg3)
end
return 1
end

function Disconnect(user, data)
s,e,cmd,str,reason = strfind(data, "%b<>%s(%S+)%s(%S+)%s(.+)")
if cmd ~= nil and str ~= nil and reason ~= nil then
local kickUser = GetItemByName(str)
SendPmToNick(str, BotName, ""..disconnect1.." " ..reason)
kickUser:Disconnect()
SendPmToOps(BotName, ""..mess5.." "..str.." "..disconnect2.." "..user.sName.." "..because.."  " ..reason)
else
user:SendPM(BotName, disconnect3)
end
end

function TimeBan(user, data)
s,e,cmd,str = strfind(data, "%b<>%s(%S+)%s(%S+)")
if cmd ~= nil and str ~= nil then
local Userkick = GetItemByName(str)
SendPmToNick(str, BotName, ""..timeban2.." "..TBan.." "..minutes.." da: " ..user.sName)
Userkick:TimeBan(TBan)
SendToOps(BotName, ""..timeban1.." "..str.." da: " ..user.sName)
else
user:SendPM(BotName, timeban3)
end
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+)")
if cmd == help then
readfrom("files/HelpUser.txt")
ReadLine(user)
elseif cmd == network then
readfrom("files/Network.txt")
ReadLine(user)
elseif cmd == report then
ReportMsg(user, data)
elseif cmd == regme then
RegNewbie(user, data)
elseif cmd == chgpass then
ChangePass(user, data)
end
if user.iProfile == 4 then
if cmd == addreg then
AddRegOp(user, data)
elseif cmd == ban then
Ban(user, data)
elseif cmd == hubinfo then
HubInfo(user, data)
elseif cmd == infouser then
InfoUser(user, data)
elseif cmd == disconnect then
Disconnect(user, data)
elseif cmd == tban then
TimeBan(user, data)
end
elseif user.iProfile == 3 then
if cmd == ban then
Ban(user, data)
elseif cmd == hubinfo then
HubInfo(user, data)
elseif cmd == infouser then
InfoUser(user, data)
elseif cmd == disconnect then
Disconnect(user, data)
elseif cmd == tban then
TimeBan(user, data)
end
elseif user.iProfile == 2 then
if cmd == ban then
Ban(user, data)
elseif cmd == hubinfo then
HubInfo(user, data)
elseif cmd == infouser then
InfoUser(user, data)
elseif cmd == disconnect then
Disconnect(user, data)
elseif cmd == tban then
TimeBan(user, data)
end
elseif user.iProfile == 1 then
if cmd == ban then
Ban(user, data)
elseif cmd == hubinfo then
HubInfo(user, data)
elseif cmd == infouser then
InfoUser(user, data)
elseif cmd == disconnect then
Disconnect(user, data)
elseif cmd == tban then
TimeBan(user, data)
end
elseif user.iProfile == 0 then
if cmd == flood then
Flood(user, data)
elseif cmd == ban then
Ban(user, data)
elseif cmd == hubinfo then
HubInfo(user, data)
elseif cmd == infouser then
InfoUser(user, data)
elseif cmd == disconnect then
Disconnect(user, data)
elseif cmd == tban then
TimeBan(user, data)
end
end
end
end
Title:
Post by: DorianG on 22 February, 2004, 19:37:58
Sorry, but the Bot was too long to traslate.
But, the words in italian they should not be essential for understand the problem...
Title:
Post by: pHaTTy on 22 February, 2004, 19:43:56
ok well the problem is that

if user.iProfile == 5 then it means this user has to be profile i1 to use these commands to do higher you will have to do if user.iProfile <= 5 then etc
Title:
Post by: nErBoS on 22 February, 2004, 19:45:10
Hi,

Phatty write fastest :P

Best regards, nErBoS

/edited
Title:
Post by: DorianG on 22 February, 2004, 21:22:35
Thank Phatty, I will always be in debt with you ;)