PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: [SWE]henrik on 01 January, 2004, 08:28:48

Title: why dont it PM?
Post by: [SWE]henrik on 01 January, 2004, 08:28:48
hi all
can someone be nice and look at this script, its supposed to send data in PM when users type the tight command but astead it comes in main:(

I may otherwise need help whit how i do to get the .txt files go in PM, if theres a surtain way to add them in text folder

Thi is the script:

--ShowInfo v1.0 by latinmusic == poweroperator 18/04/2003
--Based on TrickerBot 2 by ?Ptaczek?
--Based on a few lines of DirtyBot made by Dirty Finger
--This script read several files from a table and display them to a single user when he type the appropiate command...
--The directory --> Files <-- must exist inside of PtokaX Script Directory...
--The files --> rules.txt, net.txt, logo.txt and news.txt <-- must exist inside Files Directory...
--Enjoy
BotName = "Acoustic & World Music Hub"
Files = {
      ["+help"] = "data/usercommands.txt",
      ["+rules"] = "txt/rules.txt", --If you're using DirtyBot, don't uncomment this line
      ["!account"] = "txt/account.txt",
      ["!register"] = "txt/register.txt",
      ["!offline"] = "txt/offline.txt",
--      ["+network"] = "Files/network.txt",
--      ["+posts"] = "Files/posts.txt",
--      ["+faq"] = "Files/faq.txt",
      ["!test1"] = "Files/test1.txt",
      ["!test2"] = "Files/text2.txt",
      ["?news"] = "Files/news.txt",
      ["?rarfile"] = "Files/rarfile.txt",
      ["?regler"] = "Files/regler.txt",
      ["?winrar"] = "Files/winrar.txt",
      ["?rippdvd"] = "Files/rippdvd.txt",
      ["?opfun"] = "Files/opfun.txt",
      ["?dvd2vcd"] = "Files/dvd2vcd.txt",
   }
function Main()
end
function DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      s,e,msg = strfind(data, "%b<> ([ -z]*)")
      for key, value in Files do
         if( strfind( strlower(msg), key) ) then
            txtToShow, x = gsub(value, "%b[]", user.sName)
            SendToAll( data )
            Show(user, TheFile)
            return 1
         end
      end
   end
end
function Show(user, TheFile)
   readfrom(txtToShow, "r")
   local message = ""
   while 1 do
      local line = read()
      if line == nil then break
      else
         message = message..line.."\r\n"
      end
   end
   user:SendPM(BotName, message)
   readfrom()
end

Ill be very thankfull if anybody could take a look at this
Title:
Post by: pHaTTy on 01 January, 2004, 09:01:24
SendToAll( data )


hmmmm ;)
Title: hrm....
Post by: [SWE]henrik on 01 January, 2004, 15:11:21
QuoteOriginally posted by (uk-kingdom)pH?tt?
SendToAll( data )


hmmmm ;)

thanks for the hint my friend, you leave me in the blue cause i realy dont know how to change in a script o then i just go right to it and mess it up, ehehehe.
Ill be very happy to see you quote this script complete to me, ive seen you done some other times;) otherwise i just try to delete that line and see if its working, anyway i promice you to give you a big hug if this work.
Ill almost et divorced in this issue,lol
have a nice day
Title:
Post by: Intel on 01 January, 2004, 15:19:50
I guess it should be like this :
--ShowInfo v1.0 by latinmusic == poweroperator 18/04/2003
--Based on TrickerBot 2 by ?Ptaczek?
--Based on a few lines of DirtyBot made by Dirty Finger
--This script read several files from a table and display them to a single user when he type the appropiate command...
--The directory --> Files <-- must exist inside of PtokaX Script Directory...
--The files --> rules.txt, net.txt, logo.txt and news.txt <-- must exist inside Files Directory...
--Enjoy
BotName = "Acoustic & World Music Hub"
Files = {
["+help"] = "data/usercommands.txt",
["+rules"] = "txt/rules.txt", --If you're using DirtyBot, don't uncomment this line
["!account"] = "txt/account.txt",
["!register"] = "txt/register.txt",
["!offline"] = "txt/offline.txt",
-- ["+network"] = "Files/network.txt",
-- ["+posts"] = "Files/posts.txt",
-- ["+faq"] = "Files/faq.txt",
["!test1"] = "Files/test1.txt",
["!test2"] = "Files/text2.txt",
["?news"] = "Files/news.txt",
["?rarfile"] = "Files/rarfile.txt",
["?regler"] = "Files/regler.txt",
["?winrar"] = "Files/winrar.txt",
["?rippdvd"] = "Files/rippdvd.txt",
["?opfun"] = "Files/opfun.txt",
["?dvd2vcd"] = "Files/dvd2vcd.txt",
}
function Main()
end
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
s,e,msg = strfind(data, "%b<> ([ -z]*)")
for key, value in Files do
if( strfind( strlower(msg), key) ) then
txtToShow, x = gsub(value, "%b[]", user.sName)
SendToAll( data )
Show(user, TheFile)
return 1
end
end
end
end
function Show(user, TheFile)
readfrom(txtToShow, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
user:SendToAll( data )
readfrom()
end

Title:
Post by: [SWE]henrik on 01 January, 2004, 17:23:12
QuoteOriginally posted by Intel
I guess it should be like this :
--ShowInfo v1.0 by latinmusic == poweroperator 18/04/2003
--Based on TrickerBot 2 by ?Ptaczek?
--Based on a few lines of DirtyBot made by Dirty Finger
--This script read several files from a table and display them to a single user when he type the appropiate command...
--The directory --> Files <-- must exist inside of PtokaX Script Directory...
--The files --> rules.txt, net.txt, logo.txt and news.txt <-- must exist inside Files Directory...
--Enjoy
BotName = "Acoustic & World Music Hub"
Files = {
["+help"] = "data/usercommands.txt",
["+rules"] = "txt/rules.txt", --If you're using DirtyBot, don't uncomment this line
["!account"] = "txt/account.txt",
["!register"] = "txt/register.txt",
["!offline"] = "txt/offline.txt",
-- ["+network"] = "Files/network.txt",
-- ["+posts"] = "Files/posts.txt",
-- ["+faq"] = "Files/faq.txt",
["!test1"] = "Files/test1.txt",
["!test2"] = "Files/text2.txt",
["?news"] = "Files/news.txt",
["?rarfile"] = "Files/rarfile.txt",
["?regler"] = "Files/regler.txt",
["?winrar"] = "Files/winrar.txt",
["?rippdvd"] = "Files/rippdvd.txt",
["?opfun"] = "Files/opfun.txt",
["?dvd2vcd"] = "Files/dvd2vcd.txt",
}
function Main()
end
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
s,e,msg = strfind(data, "%b<> ([ -z]*)")
for key, value in Files do
if( strfind( strlower(msg), key) ) then
txtToShow, x = gsub(value, "%b[]", user.sName)
SendToAll( data )
Show(user, TheFile)
return 1
end
end
end
end
function Show(user, TheFile)
readfrom(txtToShow, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
user:SendToAll( data )
readfrom()
end


im realy thankfull for this but theres a syntax:
Syntax Error: attempt to call field `SendToAll' (a nil value)
Maybe something abouth what phatty try to tell me, hehe
Title:
Post by: [NL]trucker on 01 January, 2004, 17:53:24
[SWE]henrik

first of all these wont be shown because they are in the wrong folder:

["+help"] = "data/usercommands.txt",
["+rules"] = "txt/rules.txt", --If you're using DirtyBot, don't uncomment this line
["!account"] = "txt/account.txt",
["!register"] = "txt/register.txt",
["!offline"] = "txt/offline.txt",

--The directory --> Files <-- must exist inside of PtokaX Script Directory...
--The files --> rules.txt, net.txt, logo.txt and news.txt <-- must exist inside Files Directory...

you have put them in a dir data and txt so it will not work unless your main script takes over that part and then it is not neccesary to add them in this script anyway.

asfar as your question i think phatty meant that you had to replace

SendToAll( data )

with

SendToNick(curUser.sName) or
SendPmTo(curUser.sName)

first shows message in main to user and second sends pm to user.

try it and if i,m wrong i,m sure some of the fine scripters here can help you further.
Title:
Post by: pHaTTy on 01 January, 2004, 18:01:08
SendToAll( data )


remove it ;)
Title:
Post by: [NL]trucker on 01 January, 2004, 18:21:39
LoooOOOoooool


gues i still need some more time learning this stuff.
Title: developing...
Post by: [SWE]henrik on 01 January, 2004, 19:45:23
QuoteOriginally posted by (uk-kingdom)pH?tt?
SendToAll( data )


remove it ;)

thanks phatty, now it comes in main any way at least im back where i started;)
this is shown in main:
Private message from Acoustic & World Music Hub: this is test from folder text.but still it doesnt come up in a PM like rules do...
what do i do wrong? i put that a .txt doc in
a, script folder along whit the scripts
b, data folder along whit other data
c, text folder along whit other text files...
this is the changes ive done in script exept removed send to all:
{
["+help"] = "data/usercommands.txt",
["+rules"] = "txt/rules.txt", --If you're using DirtyBot, don't uncomment this line
["!account"] = "txt/account.txt",
["!register"] = "txt/register.txt",
["!test"] = "txt/test.txt",
-- ["+network"] = "Files/network.txt",
-- ["!test"] = "Files/test.txt",
-- ["+faq"] = "Files/faq.txt",
["!test"] = "Files/test.txt",
["!test"] = "Files/text.txt",
["?news"] = "Files/news.txt",
["?rarfile"] = "Files/rarfile.txt",
["?regler"] = "Files/regler.txt",
["?winrar"] = "Files/winrar.txt",
["?rippdvd"] = "Files/rippdvd.txt",
["?opfun"] = "Files/opfun.txt",
["?dvd2vcd"] = "Files/dvd2vcd.txt",
}
...
im sometimes now (like this realy) think ill manege to solve this problem whit your help;)
Title:
Post by: [NL]trucker on 01 January, 2004, 21:53:25
[SWE]henrik



first of all these wont be shown because they are in the wrong folder:

["+help"] = "data/usercommands.txt",["+rules"] = "txt/rules.txt", --If you're using DirtyBot, don't uncomment this line

 -- i,ll guess the above ones  are handled by the mainscript so no need to add them here.--


["!account"] = "txt/account.txt",
["!register"] = "txt/register.txt",
["!offline"] = "txt/offline.txt",

--The directory --> Files <-- must exist inside of PtokaX Script Directory...
--The files --> rules.txt, net.txt, logo.txt and news.txt <-- must exist inside Files Directory...
 


["!test"] = "Files/test.txt",
["!test"] = "Files/text.txt",


hmmm 2x !test for diffrent messages?

this wont work either[wrong folder]

["!test"] = "txt/test.txt",

this one will not work

-- ["!test"] = "Files/test.txt",

A. you commented it out by putting -- in front of line
B. it is not in the right dir e.g.
ptotaxdir/scripts/Files

is the file dir like this: Files or like this:  files?

and as last what is the main script you use?
this because you use three diffrent prefixes in this bot and i can imagine it interferes with your mainbot.

to make sure wich txt file is showing make them say the foldername there in.

like this is txt from data folder
      this is txt from files folder
      this is txt from data folder
Title:
Post by: NightLitch on 01 January, 2004, 22:30:25
this is so simple that many seems to forget...

function Main()
frmHub:RegBot(BotName)
end


should be in script... then it works with your PM

code here if you're lazy ;-)

--ShowInfo v1.0 by latinmusic == poweroperator 18/04/2003
--Based on TrickerBot 2 by ?Ptaczek?
--Based on a few lines of DirtyBot made by Dirty Finger
--This script read several files from a table and display them to a single user when he type the appropiate command...
--The directory --> Files <-- must exist inside of PtokaX Script Directory...
--The files --> rules.txt, net.txt, logo.txt and news.txt <-- must exist inside Files Directory...
--Enjoy
BotName = "Acoustic & World Music Hub"
Files = {
["+help"] = "data/usercommands.txt",
["+rules"] = "txt/rules.txt", --If you're using DirtyBot, don't uncomment this line
["!account"] = "txt/account.txt",
["!register"] = "txt/register.txt",
["!offline"] = "txt/offline.txt",
-- ["+network"] = "Files/network.txt",
-- ["+posts"] = "Files/posts.txt",
-- ["+faq"] = "Files/faq.txt",
["!test1"] = "Files/test1.txt",
["!test2"] = "Files/text2.txt",
["?news"] = "Files/news.txt",
["?rarfile"] = "Files/rarfile.txt",
["?regler"] = "Files/regler.txt",
["?winrar"] = "Files/winrar.txt",
["?rippdvd"] = "Files/rippdvd.txt",
["?opfun"] = "Files/opfun.txt",
["?dvd2vcd"] = "Files/dvd2vcd.txt",
}
function Main()
frmHub:RegBot(BotName)
end
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
s,e,msg = strfind(data, "%b<> ([ -z]*)")
for key, value in Files do
if( strfind( strlower(msg), key) ) then
txtToShow, x = gsub(value, "%b[]", user.sName)
SendToAll( data )
Show(user, TheFile)
return 1
end
end
end
end
function Show(user, TheFile)
readfrom(txtToShow, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
user:SendPM(BotName,message)
readfrom()
end

hope it works now... Otherwise I try fix it...
Title:
Post by: NightLitch on 01 January, 2004, 23:25:30
gaaaa... ehehe forgot to put in the short code myself...

ehehe

Above code updated...
Title:
Post by: pHaTTy on 02 January, 2004, 11:12:04
haha im was tired and lazy i didnt even see it was not registering the botname hahah :))

note: reason it does not work without botname is because its a cleint problem, nmdc it will work but dc++/odc it wont, they check if user is in list, i guess its to stop spam or something
Title:
Post by: [SWE]henrik on 02 January, 2004, 12:08:26
QuoteOriginally posted by NightLitch
gaaaa... ehehe forgot to put in the short code myself...

ehehe

Above code updated...

yeeeeeeeeeeeeees, it works :))
just one problem that i assume is easy to help out, now ive got a PM from magicpm that i call the bot now but lol all that stands in there is:

*** User went online [magicpm ()] ***


hrm... ive create an folder called test1 that ive typed "work now god dammed" and put that in to the txt folder among whit other folders (rules, network and those who are there from the beginning... But still ive just got the PM above when i type !test1 in main
can you help me out here mate?
Title:
Post by: pHaTTy on 02 January, 2004, 12:26:08
i dont understadn what you mean :/