PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: 6Marilyn6Manson6 on 10 September, 2004, 19:43:57

Title: Script news and clear ^_^
Post by: 6Marilyn6Manson6 on 10 September, 2004, 19:43:57
Hello boys, I need  a script. I would a script with 4 commands: 1  !addnew  where I can insert the news in a text file, 2  !delnew  where I can delete the last news just added, 3  !ckear  where I can delete the text file , 4  !read  where I can read the text file. The first 3 only for OP and the " !read " availabile for all . Thanks at ALL


My HUB:   planetarium.no-ip.org
Title:
Post by: plop on 11 September, 2004, 16:24:05
check chilla's or my versions of freshstuff.
mod the commands and you got what you request.

plop
Title:
Post by: bastya_elvtars on 11 September, 2004, 16:53:47
Here you go, I hope it will satisfy you.

-- guestbook by bastya_elvtars (the rock n' roll doctor) ---> [EMAIL]rnrdoctor@vipmail.hu[/EMAIL]
-- for 6Marilyn6Manson6
-- ripped from lawmaker
-- no flush function, delete a dat file instead (gonna add if needed ^^)
-- multiple entries can be deleted by adding multiple nubers separated by spaces (meaning !delguestbook 1 43 555 756612346239)
-- but u can separate them with any non-number char if u like it better
-- commands can be added in PM or in main, bot responds according 2 them
-- make a folder called dats in the scripts folder!!!


---------------------- CONFIG PART

Bot="NoteBook"

-- i made only 3 of this add/show/delete shit.
-- if you need more, notify me
-- The help text can only be changed by experts,altho you might translate it - see a lua documentation
-- levels are always the following, determining who CAN use the command:
        -- 5:only superops
        -- 4 ops & above
        -- 3 vips & above
        -- 2 registered users & above
        -- 1 anyone
        -- 0 disabled
---=========== #1

-- What it is called?

gbname="guestbook" -- the name of this function (call it what you want)

-- name of the textfile that contains entries - if it does not exist, the script will create one.
gbfile="dats/guestbook.dat"

-- this shows the guestbook or wtf
levgbcmd1=1
gbcmd1="!showguestbook"
-- adds new entry to guestbook or wtf
levgbcmd2=1
gbcmd2="!addguestbook"
-- deletes an entry by ID
levgbcmd3=5
gbcmd3="!delguestbook"



--========== #2

-- What it is called?

nname="news bulletin" -- the name of this function (call it what you want)

-- name of the textfile that contains entries - if it does not exist, the script will create one.
nfile="dats/news.dat"

-- this shows the news bulletin or wtf
levncmd1=1
ncmd1="!shownews"

-- adds new entry to news bulletin or wtf
levncmd2=1
ncmd2="!addnews"

-- deletes an entry by ID
levncmd3=5
ncmd3="!delnews"



--========== #3

-- What it is called?

rname="request board" -- the name of this function (call it what you want)

-- name of the textfile that contains entries - if it does not exist, the script will create one.
rfile="dats/requests.dat"

-- this shows the requests or wtf
levrcmd1=1
rcmd1="!showrequests"

-- adds new entry to requests or wtf
levrcmd2=1
rcmd2="!addrequest"

-- deletes an entry by ID
levrcmd3=5
rcmd3="!delrequest"


-------------------- END OF CONFIG

function parseenv(user,env,bot)
if env=="PM" then
return "$To: "..user.sName.." From: "..bot.." $<"..bot.."> "
elseif env=="MAIN" then
return "<"..bot.."> "
end
end

function DataArrival(user,data)
returndata=0
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"%b<>%s+(%S+)")
if cmd then
returndata=parsecmds(user,data,strlower(cmd),"MAIN")
end
elseif strsub(data, 1, 4) == "$To:" then
data=strsub(data,1,strlen(data)-1)
-- is this meant for our bot?
local _,_,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == Bot) then
local _,_,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
cmd=strlower(cmd)
returndata=parsecmds(user,data,cmd,"PM")
end
end return returndata
end



function parsecmds(user,data,cmd,env)
local returndata=0
if cmd==gbcmd1 then
showshit(user,entries,gbname,gbfile,levgbcmd1,env) returndata=1 -- (user,container,wtf,file)
elseif cmd==gbcmd2 then
addshit(user,data,entries,gbfile,levgbcmd2,env) returndata=1 -- (user,data,container,file)
elseif cmd==gbcmd3 then
delshit(user,data,entries,gbfile,gbname,levgbcmd3,env) returndata=1 -- delshit(user,data,container,file,wtf)
-- news stuff
elseif cmd==ncmd1 then
showshit(user,entries,nname,nfile,levncmd1,env) returndata=1 -- (user,container,wtf,file)
elseif cmd==ncmd2 then
addshit(user,data,entries,nfile,levncmd2,env) returndata=1 -- (user,data,container,file)
elseif cmd==ncmd3 then
delshit(user,data,entries,nfile,nname,levncmd3,env) returndata=1 -- delshit(user,data,container,file,wtf)
-- requests stuff
elseif cmd==rcmd1 then
showshit(user,entries,rname,rfile,levrcmd1,env) returndata=1 -- (user,container,wtf,file)
elseif cmd==rcmd2 then
addshit(user,data,entries,rfile,levrcmd2,env) returndata=1 -- (user,data,container,file)
elseif cmd==rcmd3 then
delshit(user,data,entries,rfile,rname,levrcmd3,env) returndata=1 -- delshit(user,data,container,file,wtf)
end return returndata
end

function addshit(user,data,container,file,cmdlevel,env)
if cmdlevel~=0 then
if CheckUserLevel(user) >= cmdlevel then
local container=loadshit(file)
number=number+1
local _,_,entry=strfind(data,"%b<>%s+%S+%s+(.*)")
if entry then
container[number]=date("%c").."|"..user.sName.."|"..entry
saveshit(container,file)
user:SendData(parseenv(user,env,Bot).."Your entry has been successfully added.")
else
user:SendData(parseenv(user,env,Bot).."Please add an entry, too.")
end
container={}
else
user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
end
else
user:SendData(parseenv(user,env,Bot).."That command is disabled.")
end
end

function loadshit(file)
local shit={}
number=0
readfrom(file)
while 1 do
local line = read()
if line == nil then
break
else
number = number +1
shit[number]=line
end
end return shit
end

function saveshit(container,file)
writeto(file)
for i=1,number do
if container[i] then
write(container[i].."\n")
end
end
writeto()
end

function showshit(user,container,wtf,file,cmdlevel,env)
if cmdlevel~=0 then
if CheckUserLevel(user) >= cmdlevel then
local container=loadshit(file)
local msg="\r\nHere you go, the "..wtf..":\r\n\r\n"
if number>0 then
for i=1,number do
s,e,who,when,entry=strfind(container[i], "(.+)|(.+)|(.+)")
msg=msg..i..".\t"..who.." - "..when.." ---> "..entry.."\r\n"
end
else
msg=msg.."No entries in "..wtf.."."
end
user:SendPM(Bot,msg)
else
user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
end
else
user:SendData(parseenv(user,env,Bot).."That command is disabled.")
end
end

function delshit(user,data,container,file,wtf,cmdlevel,env)
if cmdlevel~=0 then
if CheckUserLevel(user) >= cmdlevel then
local container=loadshit(file)
local _,_,args=strfind(data,"%b<>%s+%S+%s+(.+)")
if args then
gsub(args,"(%d+)",function (what)
what = tonumber(what)
if what then
if %container[what] then
%user:SendData(parseenv(%user,%env,Bot).."Entry #"..what.." is deleted from the "..%wtf..".|")
%container[what]=nil
saveshit(%container,%file)
else
%user:SendData(parseenv(%user,%env,Bot).."Entry #"..what.." wasn't found in the "..%wtf..".|")
end
else
%user:SendData(parseenv(%user,%env,Bot).. "I need the ID number to delete an entry.|")
end
end)
else
user:SendData(parseenv(user,env,Bot).. "I need at least one ID number to work! ;).|")
end
else
user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
end
else
user:SendData(parseenv(user,env,Bot).."That command is disabled.")
end
container=nil
end

function CheckUserLevel(user)
if user.iProfile==0 then
return 5
elseif user.iProfile==1 then
return 4
elseif user.iProfile==3 then
return 2
elseif user.iProfile==2 then
return 3
else
return 1
end
end

function Main()
frmHub:RegBot(Bot)
end
Title:
Post by: 6Marilyn6Manson6 on 11 September, 2004, 17:34:21
THANK YOUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU SMACKKKKKKKKKKKKKKKKKKKKKKKKKKKKK  lol

^__^
Title:
Post by: bastya_elvtars on 13 September, 2004, 00:07:40
On request, i will make it based on every bot profiles. I already have a nxs version, and ill make a channelbot one.
Title:
Post by: Robban on 13 September, 2004, 01:02:10
Really Nice!

Do you think maybe you can get it work whit DCDM or clients whit .lua?

// Robban
Title:
Post by: bastya_elvtars on 13 September, 2004, 01:06:03
Yes, i can do it probably, but later a bit.
Title:
Post by: Robban on 13 September, 2004, 01:13:34
thx :) Becouse this script is really what I'm looking for... Time for bed now. Night!
Title:
Post by: bastya_elvtars on 13 September, 2004, 03:20:00
NXS version (http://rnrdoctor.sytes.net/guestbook.lua)

ChannelBot version (http://rnrdoctor.sytes.net/guestbook_CB.lua)
Title:
Post by: Robban on 13 September, 2004, 16:17:00
Can't get links working...
Title:
Post by: bastya_elvtars on 13 September, 2004, 17:57:08
QuoteOriginally posted by Robban
Can't get links working...


strange... works here. Try again please, cause it may be the f/w...
Title:
Post by: Robban on 13 September, 2004, 18:28:42
Nopp... still not working
Title:
Post by: bastya_elvtars on 13 September, 2004, 18:34:25
Sorry, my firewall was a bit stuffed up, i was drunk when i set it up... :D
Title:
Post by: Robban on 13 September, 2004, 18:41:54
How much work is it for make it work whit DCMD client ?
Title:
Post by: bastya_elvtars on 14 September, 2004, 03:04:20
QuoteOriginally posted by Robban
How much work is it for make it work whit DCMD client ?

Hard, because i know nothing about dcdm scripting, and i don't know where i can get info on it. ?(
Title:
Post by: Gnuff? on 22 September, 2004, 13:38:31
QuoteHard, because i know nothing about dcdm scripting, and i don't know where i can get info on it.

maybe this will help you:
DCDM can be found here (http://dialspace.dial.pipex.com/prod/dialspace/town/pipexdsl/s/asmr89/dcpluspluskcdm/)
Title:
Post by: Robban on 27 September, 2004, 17:05:40
Can't you add the script to do this in mainchat.

News added: -> Name.2004.SVCD.DVDRiP-GROUP <- By: User

Then someone add something...
Title:
Post by: plop on 27 September, 2004, 22:03:23
QuoteOriginally posted by bastya_elvtars
Hard, because i know nothing about dcdm scripting, and i don't know where i can get info on it. ?(
check my site, i have a bcdc/dcdm version of freshstuff 3.x.
should get you on the way.

plop
Title:
Post by: bastya_elvtars on 27 September, 2004, 22:04:49
QuoteOriginally posted by Robban
Can't you add the script to do this in mainchat.

News added: -> Name.2004.SVCD.DVDRiP-GROUP <- By: User

Then someone add something...

plop is right, rather use freshstuff for bcdc if you have such requirements.
Title:
Post by: Robban on 27 September, 2004, 23:36:21
No you are missunderstand me :) I'm using ptokaX now as a hubsoft and are using you excellent lua script... And I want you to add it to your script :)
Title:
Post by: Robban on 07 October, 2004, 00:01:53
Bump... I think someone miss this above ;)
Title: download?
Post by: Error on 02 December, 2004, 23:14:41
hi.
I very need that scritp but i cant find de files.
wher can i finde the url
Title:
Post by: bastya_elvtars on 02 December, 2004, 23:47:01
QuoteOriginally posted by Error
hi.
I very need that scritp but i cant find de files.
wher can i finde the url

http://www.plop.nl/ptokaxbots/bastya_elvtars/guestbook.lua