PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Syphrone-NL on 29 April, 2005, 09:28:01

Title: A message in main at 1 time
Post by: Syphrone-NL on 29 April, 2005, 09:28:01
Hello everybody

Can somebody make me a script.

I want a automatic message at 1 time ( i want it at 4 o clock afternoon) in mainchat. so if its 4 o clock there apears a message with something. And i want that i can change the message. And maybe with a botname.

Can somebody make me this script

Thx in advanced
Title:
Post by: jiten on 29 April, 2005, 13:49:13
QuoteOriginally posted by Syphrone-NL
Hello everybody

Can somebody make me a script.

I want a automatic message at 1 time ( i want it at 4 o clock afternoon) in mainchat. so if its 4 o clock there apears a message with something. And i want that i can change the message. And maybe with a botname.

Can somebody make me this script

Thx in advanced
A message red from a file (e.g. txt)?

Cheers
Title:
Post by: jiten on 30 April, 2005, 23:18:56
Here goes:
-- timed message by jiten

sConf = {
sBot = frmHub:GetHubBotName(),
sFile = "file.txt", -- the txt file
}

function Main()
SetTimer(30*60*1000) -- timed message in 30 minutes
StartTimer()
end

function OnTimer()
local H = os.date("%H")  
if (H == "16") then
SendToAll(sConf.sBot,ReadFile(sConf.sFile1)) -- Send sFile1
end
end

function ReadFile(file)
local fFile = io.open(file)
if fFile then
local message = ""
for line in io.lines(file) do
message = message..line.."\n"
end
fFile:close()
return message
end
end
Cheers
Title:
Post by: LoTeK_ on 02 May, 2005, 03:24:52
Is possibile to modify this script (or a new one), to send chat lines in main chat read from a txt file every xx minutes?
Title:
Post by: James on 02 May, 2005, 09:40:32
this ?

--Timebot for LUA 5
--
-- by blackwings
--Little changed by nErboS
--
-- Converted to LUA 5 by Mutor 2/28/2005
-- Changed by DTM?-Message only MainChat no PM
-- Deutsche Anleitung
--

bot = "Message" -- BotNamen in UserListe
name2 = "News" --BotNamen in MainChat


sec = 60


fMsgAll2 = "MsgAll2.txt"--Namen der txt datei af dem der script zugreift--datei muss in Ordner scripte sein
sMsgAll2 = ""

tClock = {
   ["tMsgAll2"] = os.clock() + 1*sec,   -- Time to show in math.minutes
}

function Main()
   frmHub:RegBot(bot)
   sMsgAll2 = Readtext(fMsgAll2)
   StartTimer()
end

function OnTimer()
   if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then
      tClock["tMsgAll2"] = os.clock() + 30*sec  --Hier die WiederholungsZeit eintragen.30=30Min
      SendPmToAll(name2, sMsgAll2)
   end
end

function Readtext(file)
local sTmp="\r\n\r\n"
    for line in io.lines(file) do
        sTmp = sTmp..line.."\r\n"
    end
    return sTmp
end
Title:
Post by: jiten on 02 May, 2005, 09:57:34
QuoteOriginally posted by LoTeK_
Is possibile to modify this script (or a new one), to send chat lines in main chat read from a txt file every xx minutes?
Something like this (http://board.univ-angers.fr/thread.php?threadid=3667&boardid=26&sid=4db8cd4be4398bda478acd9b71313459)?

Best regards.
Title:
Post by: LoTeK_ on 02 May, 2005, 14:52:21
no jiten, that one is for chat history on login, thanks anyway :)

James I think your posted script suite for me, I will try it soon, thanks
no problem if I delete:
name2 = "News" --BotNamen in MainChat?
Title:
Post by: jiten on 02 May, 2005, 15:22:01
QuoteOriginally posted by LoTeK_
no jiten, that one is for chat history on login, thanks anyway :)

James I think your posted script suite for me, I will try it soon, thanks
no problem if I delete:
name2 = "News" --BotNamen in MainChat?
So, you wanted chat history shown in main in a X minutes interval?

Cheers
Title:
Post by: LoTeK_ on 02 May, 2005, 17:01:17
QuoteOriginally posted by jiten
QuoteOriginally posted by LoTeK_
no jiten, that one is for chat history on login, thanks anyway :)

James I think your posted script suite for me, I will try it soon, thanks
no problem if I delete:
name2 = "News" --BotNamen in MainChat?
So, you wanted chat history shown in main in a X minutes interval?

Cheers

Yes but not chat history, chatlines.
Only 1 line every xx minutes choosed randomly between lines in the txt file.
I'm not sure if the script from james is for this.
I have it for LUA4, but I need one new in lua5, if you want I can send you my previus LUA4 script in PM.
Title:
Post by: Dessamator on 02 May, 2005, 17:14:42
QuoteOriginally posted by LoTeK_
QuoteOriginally posted by jiten
QuoteOriginally posted by LoTeK_
no jiten, that one is for chat history on login, thanks anyway :)

James I think your posted script suite for me, I will try it soon, thanks
no problem if I delete:
name2 = "News" --BotNamen in MainChat?
So, you wanted chat history shown in main in a X minutes interval?

Cheers

Yes but not chat history, chatlines.
Only 1 line every xx minutes choosed randomly between lines in the txt file.
I'm not sure if the script from james is for this.
I have it for LUA4, but I need one new in lua5, if you want I can send you my previus LUA4 script in PM.

cant it fit here?, just post the script and some1 will convert it, hopefully!
Title:
Post by: LoTeK_ on 02 May, 2005, 17:32:28
I can't, the person who gave me this script don't want it posted anywhere. I can send you a PM with the code.
Title:
Post by: jiten on 02 May, 2005, 17:40:04
QuoteOriginally posted by LoTeK_
QuoteOriginally posted by jiten
QuoteOriginally posted by LoTeK_
no jiten, that one is for chat history on login, thanks anyway :)

James I think your posted script suite for me, I will try it soon, thanks
no problem if I delete:
name2 = "News" --BotNamen in MainChat?
So, you wanted chat history shown in main in a X minutes interval?

Cheers

Yes but not chat history, chatlines.
Only 1 line every xx minutes choosed randomly between lines in the txt file.
I'm not sure if the script from james is for this.
I have it for LUA4, but I need one new in lua5, if you want I can send you my previus LUA4 script in PM.
Sure, you may send it.
Title:
Post by: Quattro on 03 May, 2005, 10:08:51
QuoteOriginally posted by LoTeK_
I can't, the person who gave me this script don't want it posted anywhere. I can send you a PM with the code.

Why doesn't he want it to be send anywhere...
Is he ashamed of it like someone I know for his security bot for DCHpp.
He couldn't give it to me because he was ashamed of how crappy the code was :P
Title:
Post by: Dessamator on 03 May, 2005, 11:07:10
QuoteOriginally posted by Quattro
QuoteOriginally posted by LoTeK_
I can't, the person who gave me this script don't want it posted anywhere. I can send you a PM with the code.

Why doesn't he want it to be send anywhere...
Is he ashamed of it like someone I know for his security bot for DCHpp.
He couldn't give it to me because he was ashamed of how crappy the code was :P

LOL, I saw the code it was very untidy indeed, :D
Title: Not tested...
Post by: NightLitch on 03 May, 2005, 11:17:17
Try this one, made this one in 3min here in school, have not tested it because I don't have a px here ;-p

------------------------------------------------------------------------------
--// Send Random Text Line every x minute // By NightLitch
------------------------------------------------------------------------------
cBotName = "botnamehere" -- enter botname
cFilename = "filename.here" -- enter filename
cTime = 10 -- enter time in minutes
------------------------------------------------------------------------------
lineTable = {n=0}

function Main()
GetLines(sFilename)
SetTimer(cTime*60000)
StartTimer()
end

function OnTimer()
local message = lineTable(math.random(1,table.getn(lineTable))
SendToAll(cBotName, message)
end

function GetLines(filename)
local file = io.open(filename, "r")
for line in file:lines() do
table.insert(lineTable, line)
end
file:close()

end

Hope it does what you want LoTeK_.

Enjoy!
Title:
Post by: Dessamator on 03 May, 2005, 12:30:52
------------------------------------------------------------------------------
--// Send Random Text Line every x minute // By NightLitch
------------------------------------------------------------------------------
cBotName = "botnamehere" -- enter botname
cFilename = "filename.here" -- enter filename
cTime = 10 -- enter time in minutes
------------------------------------------------------------------------------
lineTable = {n=0}

function Main()
GetLines(cFilename)
SetTimer(cTime*60000)
StartTimer()
end


function OnTimer()
local message = lineTable[math.random(1,table.getn(lineTable))]
SendToAll(cBotName, message)
end

function GetLines(filename)
local file = io.open(filename, "r")
for line in file:lines() do
table.insert(lineTable, line)
end
file:close()
end

There were some errors, fixed, hopefully !
--Post edited--> some debugging code was left !
Title:
Post by: LoTeK_ on 03 May, 2005, 13:57:15
whoa :P, I will test it soon, less code than my version. thanks.
Title:
Post by: LoTeK_ on 03 May, 2005, 16:56:47
Is possible to add two commands (like my previous version) to do add a line to the txt directly from Hub (!memaddline) and to send a line (!memories) in this moment?
Title:
Post by: Dessamator on 03 May, 2005, 18:09:24
       
------------------------------------------------------------------------
------
--// Send Random Text Line every x minute // By NightLitch
-- little mod by Dessamator, added memlines and memory
------------------------------------------------------------------------------
cBotName = "botnamehere" -- enter botname
cFilename = "memories.txt" -- enter filename
cTime = 10 -- enter time in minutes
------------------------------------------------------------------------------
lineTable = {n=0}

function Main()
frmHub:RegBot(cBotName)
GetLines(cFilename)
SetTimer(cTime*60000)
StartTimer()
end


function OnTimer()
SendStuff()
end

function GetLines(filename)
local file = io.open(filename, "r")
for line in file:lines() do
table.insert(lineTable, line)
end
file:close()
end

function ChatArrival(curUser, sdata)

local s, e, cmd, args = string.find(sdata, "^%b<> %!(%a+)%s*(.*)|$")
if curUser.bOperator then
if cmd == "memories" then
SendStuff()
return 1
elseif cmd == "memaddline"  then
addline("memories.txt", args)
curUser:SendData(cBotName,"Done ,memory added")
return 1
end
end
end

function SendStuff()
GetLines(cFilename)
local message = lineTable[math.random(1,table.getn(lineTable))]
SendToAll(cBotName, message)
         return message
end

function addline(filename,msg)
local file = io.open(filename, "a+")
file:write("\n"..msg)
file:close()
end



Done !!
Title:
Post by: Syphrone-NL on 03 May, 2005, 18:30:50
QuoteOriginally posted by James
this ?

--Timebot for LUA 5
--
-- by blackwings
--Little changed by nErboS
--
-- Converted to LUA 5 by Mutor 2/28/2005
-- Changed by DTM?-Message only MainChat no PM
-- Deutsche Anleitung
--

bot = "Message" -- BotNamen in UserListe
name2 = "News" --BotNamen in MainChat


sec = 60


fMsgAll2 = "MsgAll2.txt"--Namen der txt datei af dem der script zugreift--datei muss in Ordner scripte sein
sMsgAll2 = ""

tClock = {
   ["tMsgAll2"] = os.clock() + 1*sec,   -- Time to show in math.minutes
}

function Main()
   frmHub:RegBot(bot)
   sMsgAll2 = Readtext(fMsgAll2)
   StartTimer()
end

function OnTimer()
   if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then
      tClock["tMsgAll2"] = os.clock() + 30*sec  --Hier die WiederholungsZeit eintragen.30=30Min
      SendPmToAll(name2, sMsgAll2)
   end
end

function Readtext(file)
local sTmp="\r\n\r\n"
    for line in io.lines(file) do
        sTmp = sTmp..line.."\r\n"
    end
    return sTmp
end

Can it be in main instead of pm
Title:
Post by: jiten on 03 May, 2005, 18:39:49
Just replace SendPmToAll with SendToAll in your code.

Cheers
Title:
Post by: 6Marilyn6Manson6 on 03 May, 2005, 19:26:01
--Timebot for LUA 5 by blackwings
--Little changed by nErboS
-- Converted to LUA 5 by Mutor 2/28/2005
-- Changed by DTM?-Message only MainChat no PM
-- Deutsche Anleitung

bot = "Message" -- BotNamen in UserListe
name2 = "News" --BotNamen in MainChat

sec = 60

fMsgAll2 = "MsgAll2.txt"--Namen der txt datei af dem der script zugreift--datei muss in Ordner scripte sein
sMsgAll2 = ""

tClock = {
["tMsgAll2"] = os.clock() + 1*sec, -- Time to show in math.minutes
}

function Main()
frmHub:RegBot(bot)
sMsgAll2 = Readtext(fMsgAll2)
StartTimer()
end

function OnTimer()
if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then
tClock["tMsgAll2"] = os.clock() + 30*sec --Hier die WiederholungsZeit eintragen.30=30Min
SendToAll(name2, sMsgAll2)
end
end

function Readtext(file)
local sTmp="\r\n\r\n"
for line in io.lines(file) do
sTmp = sTmp..line.."\r\n"
end
return sTmp
end

bye bye bye :P
Title:
Post by: James on 03 May, 2005, 20:12:33
:D
Title:
Post by: Syphrone-NL on 03 May, 2005, 20:43:37
going to try it today but i need to fill in how many minutes or seconds for the time to show can it maybe be only every day at 4 o clock afternoon
Title:
Post by: LoTeK_ on 03 May, 2005, 23:02:09
QuoteOriginally posted by Dessamator
       
------------------------------------------------------------------------
------
--// Send Random Text Line every x minute // By NightLitch
-- little mod by Dessamator, added memlines and memory
------------------------------------------------------------------------------
cBotName = "botnamehere" -- enter botname
cFilename = "memories.txt" -- enter filename
cTime = 10 -- enter time in minutes
------------------------------------------------------------------------------
lineTable = {n=0}

function Main()
GetLines(cFilename)
SetTimer(cTime*60000)
StartTimer()
end


function OnTimer()
SendStuff()
end

function GetLines(filename)
local file = io.open(filename, "r")
for line in file:lines() do
table.insert(lineTable, line)
end
file:close()
end

function ChatArrival(curUser, sdata)

local s, e, cmd, args = string.find(sdata, "^%b<> %!(%a+)%s*(.*)|$")
if curUser.bOperator then
if cmd == "memories" then
SendStuff()
curUser:SendData(cBotName," Done , Memory Sent!!")
return 1
elseif cmd == "memaddline"  then
addline("memories.txt", args)
curUser:SendData(cBotName,"Done ,memory added")
return 1
end
end
end

function SendStuff()
GetLines(cFilename)
local message = lineTable[math.random(1,table.getn(lineTable))]
SendToAll(cBotName, message)
end

function addline(filename,msg)
local file = io.open(filename, "a+")
file:write("\n"..msg)
file:close()
end



Done !!

Thank you! :)
Title:
Post by: Dessamator on 03 May, 2005, 23:20:26
yw, :)
Title:
Post by: LoTeK_ on 04 May, 2005, 15:51:41
I tried Send Random Text Line every x minute, and eats less memory than Memories, but I'd like some more adjustments if it's possible.

First when it send the line, it add: memory sent.
Is possibile to not show this status message?

Second botname is not show in userlist.
Thanks again.
Title:
Post by: James on 04 May, 2005, 16:19:37
Hi

look at the script from jiten...Rotating Mesage !!!
maybe it's better for you -)))

 :D
Title:
Post by: Dessamator on 04 May, 2005, 17:03:54
QuoteOriginally posted by LoTeK_
I tried Send Random Text Line every x minute, and eats less memory than Memories, but I'd like some more adjustments if it's possible.

First when it send the line, it add: memory sent.
Is possibile to not show this status message?

Second botname is not show in userlist.
Thanks again.

done, post edited !!
Title:
Post by: LoTeK_ on 04 May, 2005, 19:33:02
QuoteOriginally posted by Dessamator
QuoteOriginally posted by LoTeK_
I tried Send Random Text Line every x minute, and eats less memory than Memories, but I'd like some more adjustments if it's possible.

First when it send the line, it add: memory sent.
Is possibile to not show this status message?

Second botname is not show in userlist.
Thanks again.

done, post edited !!

Ok now the bot is the userlist but when it send the line, it add another message: "Done , following Memory has been Sent :". I would like to remove this message at all, can you tell where I have to edit the code? thanks
Title:
Post by: jiten on 04 May, 2005, 19:55:51
QuoteOriginally posted by LoTeK_
QuoteOriginally posted by Dessamator
QuoteOriginally posted by LoTeK_
I tried Send Random Text Line every x minute, and eats less memory than Memories, but I'd like some more adjustments if it's possible.

First when it send the line, it add: memory sent.
Is possibile to not show this status message?

Second botname is not show in userlist.
Thanks again.

done, post edited !!

Ok now the bot is the userlist but when it send the line, it add another message: "Done , following Memory has been Sent :". I would like to remove this message at all, can you tell where I have to edit the code? thanks
That message is only sent to the user that requests the command.
Anyway, if u don't want it to be show replace this:
curUser:SendData(cBotName," Done , following Memory has been Sent :"..SendStuff())
 
with
--curUser:SendData(cBotName," Done , following Memory has been Sent :"..SendStuff())
Cheers
Title:
Post by: Syphrone-NL on 05 May, 2005, 14:52:56
A little request more got that script:

--Timebot for LUA 5
--
-- by blackwings
--Little changed by nErboS
--
-- Converted to LUA 5 by Mutor 2/28/2005
-- Changed by DTM?-Message only MainChat no PM
-- Deutsche Anleitung
--

bot = "Message" -- BotNamen in UserListe
name2 = "News" --BotNamen in MainChat


sec = 60


fMsgAll2 = "MsgAll2.txt"--Namen der txt datei af dem der script zugreift--datei muss in Ordner scripte sein
sMsgAll2 = ""

tClock = {
["tMsgAll2"] = os.clock() + 1*sec, -- Time to show in math.minutes
}

function Main()
frmHub:RegBot(bot)
sMsgAll2 = Readtext(fMsgAll2)
StartTimer()
end

function OnTimer()
if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then
tClock["tMsgAll2"] = os.clock() + 30*sec --Hier die WiederholungsZeit eintragen.30=30Min
SendPmToAll(name2, sMsgAll2)
end
end

function Readtext(file)
local sTmp="\r\n\r\n"
for line in io.lines(file) do
sTmp = sTmp..line.."\r\n"
end
return sTmp
end

Can you make it that you insert 7 .txt files and that it every 60 seconds the other one chooses so first minute 1.txt second minute 2.txt third minute 3.txt

Thx in advanced
Title:
Post by: jiten on 05 May, 2005, 14:59:42
Have a look at Rotating Message.
It already does that ;)

Cheers
Title:
Post by: Dessamator on 05 May, 2005, 15:35:05
QuoteOriginally posted by LoTeK_
Ok now the bot is the userlist but when it send the line, it add another message: "Done , following Memory has been Sent :". I would like to remove this message at all, can you tell where I have to edit the code? thanks

Done post edited , once more !!!
Title:
Post by: Syphrone-NL on 05 May, 2005, 16:01:30
That one selects a file that it wants. Not in a row.

I want first 1.txt then 2.txt then 3.txt then 4.txt then 5.txt then 6.txt then 7.txt
Title:
Post by: kepp on 05 May, 2005, 16:06:00
QuoteOriginally posted by Syphrone-NL
That one selects a file that it wants. Not in a row.

I want first 1.txt then 2.txt then 3.txt then 4.txt then 5.txt then 6.txt then 7.txt

It selects the file in order, it's then  up to you to name the files in order :P
Title:
Post by: Syphrone-NL on 05 May, 2005, 16:09:47
I got this one:

-- Rotating Message 1.1 by jiten - for PtokaX 0.3.3.0 build 16.09 or Higher
-- based on Rotating Message 1.0 by Mutor The Ugly
-- Rotates n text files posted to main chat at interval
-- Added: Rotates every .txt file stored in sFolder (by kepp)

mSet = {
sBot = "Disneys_diner", -- Bots Name
RunStatus = 1, -- Auto Start -> 1=ON 0=OFF
iDelay = 144, -- Delay between each text file in minutes
sFolder = "diners", -- Folder where all the .txt files are stored
-- Don't change this
iCnt = 1,
}

sFile = {}

Main = function()
ReloadText()
SetTimer(mSet.iDelay*60*1000)
if (mSet.RunStatus == 1) then
StartTimer()
end
end


ChatArrival = function(sUser, sData)
sData=string.sub(sData,1,-2)
local s,e,cmd = string.find(sData, "%b<>%s+[%!%?%+%#](%S+)" )
if sUser.bOperator then
local tCmds = {
["adon"] = function(user,data)
mSet.RunStatus = 1
user:SendData(mSet.sBot,"Messages started...")
StartTimer()
end,
["adoff"] = function(user,data)
mSet.RunStatus = 0
user:SendData(mSet.sBot,"Messages stopped...")
StopTimer()
end,
["reload"] = function(user,data)
ReloadText()
user:SendData(mSet.sBot,"Textfiles loaded...")
end,
}
if tCmds[cmd] then
return tCmds[cmd](sUser,sData),1
end
end
end

OnTimer = function()
local TableSize = table.getn(sFile)
for i=1,TableSize do
if (i == mSet.iCnt) then
local sContent = FileExists(mSet.sFolder.."/"..sFile[i])
if (sContent) then
SendToAll(mSet.sBot,"\r\n"..sContent)
end
if (TableSize == i) then mSet.iCnt = 1 else mSet.iCnt = mSet.iCnt + 1 end
break
end
end
end

function FileExists(sFile)
local oFile = io.open(sFile,"r");
if (oFile) then
local line = oFile:read("*all");
oFile:close();
return string.gsub(line,"\r","\r\n");
else
return nil;
end
end

function ReloadText()
sFile = nil;
sFile = {};
collectgarbage();

--// Load up files to table from folder \\--
os.execute("dir /b "..mSet.sFolder.."\\*.txt > files.txt");
local hFile = io.open("files.txt","r");
local line = hFile:read();
while line do
table.insert(sFile,1,line)
line = hFile:read();
end
hFile:close();
os.remove("files.txt");
end

My files:
Diner 1
Diner 2
Diner 3
Diner 4
Diner 5
Diner 6
Diner 7

but it started with 3

i want to do that in that order