PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: [G-T-E]Gate? on 05 January, 2004, 19:04:34

Title: TexterBot
Post by: [G-T-E]Gate? on 05 January, 2004, 19:04:34
Looking for a Texter bot ,
 Explaination;
PtokaX DC Hub 0.3.2.6 TestDrive 4\scripts\Textfiles

In scripts folder is texterbot.lua  that locates text files in files folder.

User types - divx  in main chat and gets in Pm to User the requested info in that file.

Anyone ?
Title:
Post by: NightLitch on 05 January, 2004, 19:11:49
* UPDATED *

try it now

--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 = "?-=Admin=-?"
Files = {
["?codec"] = "Files/codec.txt",
["?news"] = "Files/news.txt",
["?faq"] = "Files/faq.txt",
-- ["?rules"] = "Files/rules.txt", --If you're using DirtyBot, don't uncomment this line
}
function Main()
frmHub:RegBot(BotName)
end
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)  
s,e,msg = strfind( data, "%b<>%s+(%S+)" )

for key, value in Files do
if( strfind( strlower(msg), key) ) then
s,e,msg,where = strfind(data, "<"..user.sName..">%s+(%S+)%s+(.+)")
-- where must be main or pm
txtToShow, x = gsub(value, "%b[]", user.sName)
-- SendToAll( data ) -- Now the command will not sent to all
Show(user, TheFile, pm)
return 1
end
end
end
end


function Show(user, TheFile, where)
readfrom(txtToShow, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
if strlower(where) == "main" then
user:SendData(BotName, message)
elseif strlower(where) == "pm" then
user:SendPM(BotName, message)
end
readfrom()
end

Hope it does what you want...
Title:
Post by: [G-T-E]Gate? on 05 January, 2004, 19:25:40
Tks ,
 Working ok But Appreciate PM to User instead of result in main chat ..
gate :D
Title:
Post by: plop on 05 January, 2004, 20:20:59
here you are, this should do all and more.
-- texter bot by plop
-- shows text files from a folder named text.
-- doesn't mather what prefix is used.
-- if the file excist it shows.

Bot = "something"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1)
   if( strsub(data, 1, 1) == "<" ) then
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      cmd = strsub(cmd, 2,strlen(cmd))
      if readfrom("text/"..cmd..".txt") then
         showtext(user, cmd)
         return 1
      end
   elseif(strsub(data, 1, 4) == "$To:") then
      s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
      cmd = strsub(cmd, 2,strlen(cmd))
      if readfrom("text/"..cmd..".txt") then
         showtext(user, cmd)
         return 1
      end
   end
end


function showtext(user, cmd)
   lines = "\r\n\r\n"
   readfrom("text/"..cmd..".txt")
   while 1 do
      local line = read()
      if line == nil then
         readfrom()
         break
      end
      lines = lines..line.."\r\n"
   end
   user:SendPM(Bot, lines.." |")
end
plop
Title:
Post by: NightLitch on 05 January, 2004, 23:42:13
Nice one plop... Was thinking in that direction but
became lazy... :-)
Title:
Post by: plop on 06 January, 2004, 01:59:13
QuoteOriginally posted by NightLitch
Nice one plop... Was thinking in that direction but
became lazy... :-)
well took some minutes 2 make but the result is even lazyer. lol

plop
Title:
Post by: [G-T-E]Gate? on 06 January, 2004, 14:33:30
Tks Plop
Just what I needed
 :D
Title:
Post by: suyang99 on 07 January, 2004, 10:37:19
how can i read the random line
Title:
Post by: c h i l l a on 07 January, 2004, 11:30:06
a faster way is this func.


function ReadHelp(file)
local handle = openfile(FDFolder.."/"..file, "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
return contents
end
Title:
Post by: plop on 08 January, 2004, 01:18:15
QuoteOriginally posted by c h i l l a
a faster way is this func.


function ReadHelp(file)
local handle = openfile(FDFolder.."/"..file, "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
return contents
end
thx, sure is a lot easyer/shorter that way.
-- texter bot by plop
-- thx 2 chilla for the faster routine for opening the files
-- shows text files from a folder named text.
-- doesn't mather what prefix it used.
-- if the file excist it shows.

Bot = "something"
FDFolder = "text"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1)
   if( strsub(data, 1, 1) == "<" ) then
      s,e,cmd = strfind(data,"%b<>%s+(%S+)")
      cmd = strsub(cmd, 2,strlen(cmd))
      if readfrom(FDFolder.."/"..cmd..".txt") then
         showtext(user, cmd)
         return 1
      end
   elseif(strsub(data, 1, 4) == "$To:") then
      s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
      cmd = strsub(cmd, 2,strlen(cmd))
      if readfrom(FDFolder.."/"..cmd..".txt") then
         showtext(user, cmd)
         return 1
      end
   end
end

function showtext(user, file)
local handle = openfile(FDFolder.."/"..file..".txt", "r")
local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
closefile (handle)
user:SendPM(Bot, "\r\n"..contents.."\r\n|")
end
plop
Title: Help mee!!
Post by: WickeD on 20 September, 2004, 20:35:19
This script do I want to get to work! I do not work!

Can eny one help mee to get this script to work?



--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 = "Info-Box"
Files = {
["?codec"] = "Files/codec.txt",
["?news"] = "Files/news.txt",
["?faq"] = "Files/faq.txt",
-- ["?rules"] = "Files/rules.txt", --If you're using DirtyBot, don't uncomment this line
}
function Main()
frmHub:RegBot(BotName)
end
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)  
s,e,msg = strfind( data, "%b<>%s+(%S+)" )

for key, value in Files do
if( strfind( strlower(msg), key) ) then
s,e,msg,where = strfind(data, "<"..user.sName..">%s+(%S+)%s+(.+)")
-- where must be main or pm
txtToShow, x = gsub(value, "%b[]", user.sName)
-- SendToAll( data ) -- Now the command will not sent to all
Show(user, TheFile, pm)
return 1
end
end
end
end


function Show(user, TheFile, where)
readfrom(txtToShow, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
if strlower(where) == "main" then
user:SendData(BotName, message)
elseif strlower(where) == "pm" then
user:SendPM(BotName, message)
end
readfrom()
end


I get this error massage:

Syntax error: bad argument #1 to `strlower' (string expected, got nil)
stack traceback:
   1:  function `strlower' [C]
   2:  function `Show' at line 47 [file `...m\ptokaX 0.330 build 15.25\scripts\Info-Box.lua']
   3:  function `DataArrival' at line 29 [file `...m\ptokaX 0.330 build 15.25\scripts\Info-Box.lua']



----------------------------------------------------------

//WickeD
Title:
Post by: BottledHate on 20 September, 2004, 21:48:08
QuoteOriginally posted by WickeD
This script do I want to get to work! I do not work!

Can eny one help mee to get this script to work?

---snip-----


I get this error massage:

Syntax error: bad argument #1 to `strlower' (string expected, got nil)
stack traceback:
   1:  function `strlower' [C]
   2:  function `Show' at line 47 [file `...m\ptokaX 0.330 build 15.25\scripts\Info-Box.lua']
   3:  function `DataArrival' at line 29 [file `...m\ptokaX 0.330 build 15.25\scripts\Info-Box.lua']



----------------------------------------------------------

//WickeD

that is because u didn't use the full command....

for example:

?codec pm
?codec main


it looks like "pm" or "main" is required in this script. (kinda lame)

replace the show function in yours with this one and it will default to main unless pm is specified:

function Show(user, TheFile, where)
readfrom(txtToShow, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
where = where or "main"
if strlower(where) == "main" then
user:SendData(BotName, message)
elseif strlower(where) == "pm" then
user:SendPM(BotName, message)
end
readfrom()
end

hope this helps...

-BH
Title: Hmm!
Post by: WickeD on 20 September, 2004, 21:58:12
I get this error:


Syntax error: `=' expected;
  last token read: `he' at line 5 in file `C:\Program\ptokaX 0.330 build 15.25\scripts\Info-Box.lua'


In this 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 = "[Bot]Info-Box"
Files = {
["?infolista"] = "Files/infolista.txt",
["?v?der"] = "Files/v?der.txt",
["?rippadvd"] = "Files/rippadvd.txt",
["?subtitles"] = "Files/subtitles.txt",
["?codec"] = "Files/codec.txt",
["?vlc"] = "Files/vlc.txt",
["?dataume?"] = "Files/dataume?.txt",
["?dataweb"] = "Files/dataweb.txt",
["?teleadress"] = "Files/teleadress.txt",
["?tidningar"] = "Files/tidningar.txt",
["?priser"] = "Files/priser.txt",
["?isp"] = "Files/isp.txt",
["?annonser"] = "Files/annonser.txt",
["?s?kmotor"] = "Files/s?kmotor.txt",
["?crackar"] = "Files/crackar.txt",
["?nysl?ppt"] = "Files/nysl?ppt.txt",
["?fakefiler"] = "Files/fakefiler.txt",
["?mcaff?r"] = "Files/mcaff?r.txt",
["?mcclub"] = "Files/mcclub.txt",
["?bilaff?r"] = "Files/bilaff?r.txt",
["?k?rkort"] = "Files/k?rkort.txt",
["?tvprog"] = "Files/tvprog.txt",
["?svar"] = "Files/svar.txt",
["?promille"] = "Files/promille.txt",
["?hashing"] = "Files/hashing.txt",
["?mplayer"] = "Files/mplayer.txt",
["?sfv"] = "Files/sfv.txt",
["?vitmakt"] = "Files/vitmakt.txt",
["?regler"] = "Files/regler.txt",
["?l?mnahub"] = "Files/l?mnahub.txt",
["?staff"] = "Files/staff.txt",
["?uppgift"] = "Files/uppgift.txt",
["?share"] = "Files/share.txt",
["?slots"] = "Files/slots.txt",
["?hub"] = "Files/hub.txt",
["?bot"] = "Files/bot.txt",
["?dmz"] = "Files/dmz.txt",
["?clienter"] = "Files/clienter.txt",
["?router"] = "Files/router.txt",
["?firewall"] = "Files/firewall.txt",
["?dc++color"] = "Files/dc++color.txt",
["?faq"] = "Files/faq.txt",
["?forum"] = "Files/forum.txt",
["?e-post"] = "Files/e-post.txt",
["?kickad"] = "Files/kickad.txt",
["?bannad"] = "Files/bannad.txt",
}
function Main()
frmHub:RegBot(BotName)
end
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)  
s,e,msg = strfind( data, "%b<>%s+(%S+)" )

for key, value in Files do
if( strfind( strlower(msg), key) ) then
s,e,msg,where = strfind(data, "<"..user.sName..">%s+(%S+)%s+(.+)")
-- where must be main or pm
txtToShow, x = gsub(value, "%b[]", user.sName)
-- SendToAll( data ) -- Now the command will not sent to all
Show(user, TheFile, pm)
return 1
end
end
end
end


function Show(user, TheFile, where)
readfrom(txtToShow, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\r\n"
end
end
where = where or "main"
if strlower(where) == "main" then
user:SendData(BotName, message)
elseif strlower(where) == "pm" then
user:SendPM(BotName, message)
end
readfrom()
end


Why??
Title:
Post by: BottledHate on 20 September, 2004, 22:10:55
lol...


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

should be...


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


somehow u wraped the words..
:D

-BH
Title: Thx!
Post by: WickeD on 20 September, 2004, 22:18:42
It works now! But!!! It shows in Main-Chat! And I want it to bee shown i a PM to the user that write the command!

Can you help mee whit that to my m8??

//WickeD
Title:
Post by: BottledHate on 20 September, 2004, 22:20:41
change:
where = where or "main"

to:
where = where or "pm"

then u can still make it go to main... but defaults to pm

:D

-BH
Title: Yes!!!!!!
Post by: WickeD on 20 September, 2004, 22:31:16
Now it works  fine my m8!

Thx a lot my m8!!!!

=)


//WickeD
Title:
Post by: BottledHate on 20 September, 2004, 22:35:44
QuoteOriginally posted by WickeD
Now it works  fine my m8!

Thx a lot my m8!!!!

=)


//WickeD

no problem.. happy i could help.  :)

-BH