A message in main at 1 time
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

A message in main at 1 time

Started by Syphrone-NL, 29 April, 2005, 09:28:01

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

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
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

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

jiten

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

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?

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

jiten

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?

Best regards.

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?

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

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.

Dessamator

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!
Ignorance is Bliss.

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.

jiten

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.

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
quattro-place.no-ip.com:1418
PtokaX DC Hub 0.3.3.0 build 17.09 Not Running :(
wdp10.no-ip.info:1412
DCH++ v1.0-Release (Plugin API v1.0) Special Quattro? Build
For DCH scripting and plugins

Dessamator

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
Ignorance is Bliss.

NightLitch

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!
//NL

Dessamator

#15
------------------------------------------------------------------------------
--// 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 !
Ignorance is Bliss.

LoTeK_

whoa :P, I will test it soon, less code than my version. thanks.

LoTeK_

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?

Dessamator

#18
        
------------------------------------------------------------------------
------
--// 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 !!
Ignorance is Bliss.

Syphrone-NL

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
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

Just replace SendPmToAll with SendToAll in your code.

Cheers

6Marilyn6Manson6

--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

James


Syphrone-NL

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
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

LoTeK_

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! :)

SMF spam blocked by CleanTalk