PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Pit on 08 November, 2004, 02:58:41

Title: Some like warn funtion
Post by: Pit on 08 November, 2004, 02:58:41
Greetings

What i want in this request is that if someone can make me a standalone script for my hub.
with this options:

-Only certain nicks have permission to the comand;
-Comand may be !pick
-If it find an error in the sintase phrase, send PM with a line of explanation like: !pick
-After a certain 'pick' times, the bot send his nickname to a certain op nick with the varios 'picks' writen in PM
-Of course that has to be made a picks.txt or a picks.dat to acomplish

If it's possible be able to make a table with the 5 top 'pickers' with the following items:

-Username
-Pick times
-Date of picks
-Picked by
-Levels

This estructure has a funny gold that i rather not confess it, but if it can be made i'll be gratefull..

Thanks
Title:
Post by: nErBoS on 08 November, 2004, 11:48:42
Hi,

I could make the script, but fisrt i need to understand it. I am not understanding what you mean with "pick" what is the objective of this command ??? Can you give more examples please.

Best regards, nErBoS
Title: Sorry nerbos
Post by: Pit on 08 November, 2004, 17:47:47
Greetings

You can understand 'pick' as warn!
But instead, after a number predifened 'warnings', the user get kicked, simple the bot send pm to some defined in script nicks a msg!
Then after some msg's receaved the nick in charge of that task simple realize what to do with it!

Hope i get more clear this time..

Thanks

And i'm still using your Brain-Master dude...
100%
no stops and see this:

Tempo de Liga??o, 9 Dias, 22 Horas 17 Minutos e 23 Segundos
O tempo m?ximo de Estado Online no Friends ? de 15 dias, 19 Horas e 32 Minutos...no dia 26/8/2004

Not jokin',,,it's true man!!

And i've made some modifications on it

More cmds and txts

Hope you don?t mind..

Keep up the good work
Title:
Post by: nErBoS on 09 November, 2004, 02:14:37
Hi,

I think i have understood it right. You want to save all warns made to the user, or only the last one ???

Best regards, nErBoS
Title: yes your dam right
Post by: Pit on 09 November, 2004, 19:09:24
Greetings nerbos

Thanks for the quick replies..
And yes
I want the script to save all warns made to the user, with all the points i designed

thanks man

[[[[[[]]]]]]]]]]]]
Title:
Post by: nErBoS on 10 November, 2004, 03:03:21
Hi,

Here you go...

--## DIFFERENT WARN BOT
--## Requested by Pit
--## Made by nErBoS
--## Commands:
--## !pick - Warns a user and saves it with a type of warn level
--## !toppick - The "iTop" most warned in the HUB

sBot = "DW-Bot"

arrWarn = {}
fWarn = "warn.dat"
arrAux = {}

--## Configuration ##--

iWarns = 4 -- Time of warns to warn OPs

iTop = 5 -- Number of users you want to show on the TOP

arrOPs = { -- Table with the nick of OPs to be warned after iWarns
"nErBoS",
"Pit",
}

arrLevel = { -- Table with the levels of Warn
[0] = "DANGER",
[1] = "MEDIUM",
[2] = "LIGHT",
}

uLaterPtokax = 0 -- Choose 0 if you are using Ptokax Version 0.3.3.0 or higher
-- Choose 1 if you are using Ptokax Version lower then 0.3.3.0

--## END ##--

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

function OnExit()
SaveToFile(fWarn , arrWarn , "arrWarn")
end


function DataArrival(user, data)
if (user.bOperator and (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot)) then
data = strsub(data,1,strlen(data)-1)
local s,e,cmd = strfind(data, "%b<>%s+(%S+)")
if (cmd == "!pick") then
local s,e,sNick,iLevel,sReason = strfind(data, "%b<>%s+%S+%s+(%S+)%s+(%S+)%s+(.+)")
if (sNick == nil or sReason == nil) then
user:SendPM(sBot, "Syntax Error, !pick , you must write a nick, a level of pick and a reason.")
elseif (iLevel == nil or tonumber(iLevel) == nil or arrLevel[tonumber(iLevel)] == nil) then
local sTmp,iIndex,sPick = "The Level of Pick is invalid, it must be one of this numbers:\r\n\r\n"
for iIndex, sPick in arrLevel do
sTmp = sTmp.."LEVEL: "..iIndex.." ["..sPick.."]\r\n"
end
user:SendPM(sBot, sTmp)
elseif (GetItemByName(sNick) == nil) then
user:SendPM(sBot, "The user "..sNick.." is not online.")
else
sNick = GetItemByName(sNick)
if (arrWarn[sNick.sName] == nil) then
arrWarn[sNick.sName] = {}
arrWarn[sNick.sName]["WARNS"] = {}
arrWarn[sNick.sName]["TIMES"] = 0
end
tinsert(arrWarn[sNick.sName]["WARNS"], {["REASON"] = sReason, ["TIME"] = GetTime(), ["BY"] = user.sName, ["LEVEL"] = arrLevel[tonumber(iLevel)]} )
arrWarn[sNick.sName]["TIMES"] =  arrWarn[sNick.sName]["TIMES"] + 1
user:SendPM(sBot, "The user "..sNick.sName.." was been pick, because: "..sReason.." wiht the level "..arrLevel[tonumber(iLevel)])
sNick:SendPM(sBot, "You are been pick by "..user.sName.." because: "..sReason.." with the level "..arrLevel[tonumber(iLevel)])
if (arrWarn[sNick.sName]["TIMES"] >= iWarns) then
SendWarn(sNick.sName)
end
if (uLaterPtokax == 1) then
OnExit()
end
end
return 1
elseif (cmd == "!toppick") then
local sTmp,iSize,iCount,iMax,sMax,sNick,arrTable,iTimes = "The "..iTop.." Users most warned in the HUB: \r\n\r\n",GetSize(),0,0,""
while iCount < iSize do
for sNick, arrTable in arrWarn do
if (arrAux[sNick] == nil and arrTable["TIMES"] >= iMax) then
sMax = sNick
iMax = arrTable["TIMES"]
end
end
sTmp = sTmp.."USER: "..sMax.." WARNED: "..iMax.." times\r\n"
iCount = iCount + 1
end
arrAux = {}
user:SendPM(sBot, sTmp)
return 1
end
end
end

function SendWarn(sNick)
local sTmp,arrTable = "The user "..sNick.." has recived "..arrWarn[sNick]["TIMES"].." warns :\r\n\r\n"
for i=1, getn(arrWarn[sNick]["WARNS"]) do
arrTable = arrWarn[sNick]["WARNS"][i]
sTmp = sTmp.."\t--## WARN ##--\r\n\r\n"
sTmp = sTmp.."REASON: "..arrTable["REASON"].."\r\n"
sTmp = sTmp.."TIME: "..arrTable["TIME"].."\r\n"
sTmp = sTmp.."LEVEL: "..arrTable["LEVEL"].."\r\n"
sTmp = sTmp.."BY: "..arrTable["BY"].."\r\n"
end
for i=1, getn(arrOPs) do
if (GetItemByName(arrOPs[i]) ~= nil) then
GetItemByName(arrOPs[i]):SendPM(sBot, sTmp)
end
end
end

function GetSize()
local iCount,sNick,arrTable = 0
for sNick, arrTable in arrWarn do
iCount = iCount + 1
if (iCount >= iTop) then
return iTop
end
end
return iCount
end

function GetTime()
return "Date: ".." "..date("%d").."/"..date("%m").."/20"..date("%y").." Hour: "..date("%H")..":"..date("%M")..":"..date("%S")
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

About the Brain-Master....

No problem you are free to make the modification you want. About the UPTIME, the record of the BOT for now belongs to [PT]CableGuy for more then 40 days (without shutting down the ptokax) with the Brain-Master.

Best regards, nErBoS
Title: you're the man
Post by: Pit on 10 November, 2004, 18:53:01
Greetings nerbos

thanks for the script
i'll check it right now..then i'll say something to you

Keep on doing thw good work man

See ya

Pit
Title: Just like i wanted...
Post by: Pit on 11 November, 2004, 23:32:19
Greetings nerbos

The script works 200%
I think we have a connection man
I have the thoughts, you the gift doing them...
Thanks a lot man
Own you one more...
lol

I have two more ideas..
Check it out the request scripts...
;)
when you have free time of course..

See ya nerbos
;)


monnie[[[[[[]]]]]]]]]]]