PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: kash? on 05 April, 2005, 18:02:24

Title: advertise on start at PM
Post by: kash? on 05 April, 2005, 18:02:24
I wanted a script which will send any text message
or ascii from the text file at the start of connecting
hub in PM
( text to be displayed is not to be saved in script
but in different text file )
Title:
Post by: Dessamator on 05 April, 2005, 18:18:24

---------------------------------------------------------------------------------- ascii PM sender , on connect
--added newuserconnected, by Dessamator
--by stravides
-- LUA 5
--03/02/05

sBot = frmHub:GetHubBotName()   --  your main bot here

file1 ="ascii" --name of file
function Main()
   frmHub:RegBot(sBot)
end

function NewUserConnected(user,data)
showtext(user, file1)
end

OpConnected = NewUserConnected

function showtext(user, file)
local contents ="\r\n\r\n"
for line in io.lines(file..".txt") do
    contents = contents..line.."\r\n"
    end
user:SendPM(sBot,"\r\n"..contents.."\r\n|")
end


Done!!

in case u want to add anymore txts, just add two lines :
eg.:
file2 ="ascii2" --name of file
and
showtext(user, file2)

Title:
Post by: kash? on 06 April, 2005, 13:20:49
Unfortunately, it doesn't work m8
Can you please check again....
Title:
Post by: Dessamator on 06 April, 2005, 13:40:07
QuoteUnfortunately, it doesn't work m8  
Can you please check again....

hmm it does work, just follow these 3 steps:

1. create a folder named, "images", in the scripts folder

2. copy a file which u want the users to receive to that folder

3.put the file name here eg.: ascii.txt :
file1 ="ascii" --name of file

(ps the file u select must have an extension of .txt)

 run the script, and reconnect, and voila ull receive ur msg !!!
Title:
Post by: kash? on 06 April, 2005, 13:54:44
I did it earler also and I did it again but
still it doesn't work...:-(

The text file to be displayed can be saved in scripts
folder rather making different folder.....

plz help...
Title:
Post by: jiten on 06 April, 2005, 14:20:26
It's working well with me...
Title:
Post by: kash? on 06 April, 2005, 14:41:47
I am getting this error.....
20: bad argument #1 to `lines' (No such file or directory
)
Title:
Post by: Dessamator on 06 April, 2005, 14:47:46
Done !!, post edited u can put in a normal scripts folder
Title:
Post by: kash? on 06 April, 2005, 15:11:59
I am  getting this error
.lua:22: bad argument #1 to `lines' (No such file or directory)
Title:
Post by: Dessamator on 06 April, 2005, 15:30:55
QuoteOriginally posted by kash?
I am  getting this error
.lua:22: bad argument #1 to `lines' (No such file or directory)
ok, lets c how to solve this, first, post ur script here, with all the changes u made!
Title:
Post by: kash? on 06 April, 2005, 15:40:51
i haven't modified I think.....
this is...
---------------------------------------------------------------------------------- ascii PM sender , on connect
--added newuserconnected, by Dessamator
--by stravides
-- LUA 5
--03/02/05

sBot = frmHub:GetHubBotName()   --  your main bot here

file1 ="ascii" --name of file
function Main()
   frmHub:RegBot(sBot)
end

function NewUserConnected(user,data)
showtext(user, file1)
end

OpConnected = NewUserConnected

function showtext(user, file)
local contents ="\r\n\r\n"
   for line in io.lines(file..".txt") do
       contents = contents..line.."\r\n"
    end
      user:SendPM(sBot,"\r\n"..contents.."\r\n|")
end
Title:
Post by: Dessamator on 06 April, 2005, 15:49:31
ok, and where exactly did u put the file, with the info u want to send?, and whats the name of the file?
Title:
Post by: kash? on 06 April, 2005, 16:13:12
i put that lua file in scripts folder and
and text also in scripts folder with info and
I tried with ascii and ascii.txt also...
Title:
Post by: Dessamator on 06 April, 2005, 16:37:09
QuoteOriginally posted by kash?
i put that lua file in scripts folder and
and text also in scripts folder with info and
I tried with ascii and ascii.txt also...
hmm, the name should be: ascii.txt , and it should be in : \ptokax\scripts
like this :
\(ptokax folder)\scripts\ascii.txt
Title:
Post by: kash? on 06 April, 2005, 17:09:57
I have done as u told me
Still I am getting same error

try some other script for it

regards
Title:
Post by: jiten on 06 April, 2005, 18:12:27
Try this one (put the text files in ur scripts folder alongside the lua files):

--added newuserconnected, by Dessamator
--by stravides
-- LUA 5
--03/02/05

sBot = frmHub:GetHubBotName()   --  your main bot here

file1 ="asciis" --name of file1

function Main()
frmHub:RegBot(sBot)
end

function NewUserConnected(user,data)
showtext(user, file1)
end

OpConnected = NewUserConnected

function showtext(user, filename)
local contents ="\r\n\r\n"
local f = io.open(filename..".txt", "r")
if f then
for line in f:lines() do
contents = contents..line.."\r\n"
end
f:close()
user:SendPM(sBot,"\r\n"..contents.."\r\n|")
else
user:SendPM(sBot,filename..".txt doesn't exist")
end
end


Cheers
Title:
Post by: Dessamator on 06 April, 2005, 18:52:52
---------------------------------------------------------------------------------- ascii PM sender , on connect
--added newuserconnected, by Dessamator
--by stravides
-- LUA 5
--03/02/05

sBot = frmHub:GetHubBotName() -- your main bot here

file1 ="ascii.txt" --name of file
function Main()
frmHub:RegBot(sBot)
CreateFile(file1)
end

function CreateFile(filename)
if checkfile(filename)=="false" then
io.output(filename)
io.output()
WriteToFile(filename)
end

end

function NewUserConnected(user,data)
showtext(user, file1)
end

OpConnected = NewUserConnected

function showtext(user, file)
local contents ="\r\n\r\n"
for line in io.lines(file) do
contents = contents..line.."\r\n"
end
user:SendPM(sBot,"\r\n"..contents.."\r\n|")
end

function checkfile(filename)
local f = io.open(filename, "r")
if f then
f:close()
return "true"
else
return "false"
end
end
function WriteToFile(filename)
local file = io.open(filename, "w+") -- "w" write
file:write("Type ur info here(ps u can delete this line)")
file:close()
end
 
Done !!

here u go Kash, no need to create a file, just search for "ascii.txt"(without quotation marks), and edit it and put the info you want there !
Title:
Post by: kash? on 07 April, 2005, 19:47:20
thanx guys
Dessamator you script is not working
however it is not showing any errors

jiten ur script is working
but it works only once after starting hub, i.e.if I close dc++ and open it again it doesn't show any text,
that too only I received that ascii and no other
user in hub received it

I want it to work whenever I connect hub and
whoever connect it
 
Is it possible to display two text files (ascii)  

thanx both for help

regards
Title:
Post by: Dessamator on 07 April, 2005, 19:58:00
QuoteOriginally posted by Dessamator
Done!!

in case u want to add anymore txts, just add two lines :
eg.:
file2 ="ascii2" --name of file
and
showtext(user, file2)