simple # command
 

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

simple # command

Started by mmx, 11 December, 2003, 18:13:48

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

mmx

hi

i just would like to get/have/ simple script code that would let someone who was in my hub or me even to type say "#help" and then then it to load text stored in a text file say "help.txt" can anyone help me out here?

thankyou

mmx

please can i get a little help? it would be really really appreciated. from the likes of phatty etc

thankyou!

IceCoder

#2
here is a script


sBotName = "HELP-O-BOT"
sRulesFileName = "help.txt"

function Main()
   frmHub:RegBot(sBotName)
end

function DataArrival(user,data)
   if (strsub(data, 1, 1) == "<" ) then
      -- remove end pipe
      data=strsub(data,1,strlen(data)-1)
      --extract command
      _,_,cmd=strfind(data, "%b<>%s+(%S+)")
      --check if cmd exist
      if not cmd then cmd = "0" end
      -- make the cmd caseinsensitive
      cmd = strlower(cmd)
      -- get the command prefix
      cmdprefix = strsub(cmd, 1,1)
      -- check if the cmd prefix is !,+,# or ?
      if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
         -- Remove the prefix and check the command
         cmd = strsub(cmd, 2,strlen(cmd))
         if cmd = "help" then
            fFileHandle, sError = readfrom(sRulesFileName)
            local sLine = read()
            local sFileContent = ""
            if sLine then
               sFileContent = sLine
               while 1 do
                  sLine = read()
                  if not sLine then
                     break
                  else
                     sFileContent = sFileContent..sLine.."\r\n"
                  end
               end
               readfrom()   -- close filehandle
               user:SendPM(sBotName,sFileContent)
               return 1
            elseif fFileHandle
               user:SendPM(sBotName,"Nothing found in "..sRulesFileName)
               return 1
            else
               user:SendPM(sBotName,"Error "..sError)
            end
            readfrom()
         end
      end
   end
end

mmx

Syntax Error: `then' expected;
  last token read: `=' at line 24 in string "sBotName = "HELP-O-BOT"
..."

plop

change this
 if cmd = "help" then
for this
 if cmd == "help" then


plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

mmx

Syntax Error: `then' expected;
  last token read: `user' at line 42 in string "sBotName = "hbot"
..."

mmx

sBotName = "hbot"
sRulesFileName = "help.txt"

function Main()
frmHub:RegBot(sBotName)
end

function DataArrival(user,data)
if (strsub(data, 1, 1) == "<" ) then
-- remove end pipe
data=strsub(data,1,strlen(data)-1)
--extract command
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
--check if cmd exist
if not cmd then cmd = "0" end
-- make the cmd caseinsensitive
cmd = strlower(cmd)
-- get the command prefix
cmdprefix = strsub(cmd, 1,1)
-- check if the cmd prefix is !,+,# or ?
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
-- Remove the prefix and check the command
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "help" then
fFileHandle, sError = readfrom(sRulesFileName)
local sLine = read()
local sFileContent = ""
if sLine then
sFileContent = sLine
while 1 do
sLine = read()
if not sLine then
break
else
sFileContent = sFileContent..sLine.."\r\n"
end
end
readfrom() -- close filehandle
user:SendPM(sBotName,sFileContent)
return 1
elseif fFileHandle
user:SendPM(sBotName,"Nothing found in "..sRulesFileName)
return 1
else
user:SendPM(sBotName,"Error "..sError)
end
readfrom()
end
end
end
end

------------------------------------------------------
Syntax Error: `then' expected;
  last token read: `user' at line 42 in string "sBotName = "hbot"
..."

mmx

didn't u test this?

all i want is to type #help

and get help.txt to open

in a PM window to who ever types it.


-------------------------------------------------------
 i didn't think it would be OTT considering some of the scripts u see on the forum.

as always thankyou v.much appreciated

IceCoder


mmx

lol i got it to be fixed. sigh your soo useless. joke  :rolleyes:

mmx

sBotName = "hbot"
sRulesFileName = "help.txt"

function Main()
frmHub:RegBot(sBotName)
end

function DataArrival(user,data)
if (strsub(data, 1, 1) == "<" ) then
-- remove end pipe
data=strsub(data,1,strlen(data)-1)
--extract command
_,_,cmd=strfind(data, "%b<>%s+(%S+)")
--check if cmd exist
if not cmd then cmd = "0" end
-- make the cmd caseinsensitive
cmd = strlower(cmd)
-- get the command prefix
cmdprefix = strsub(cmd, 1,1)
-- check if the cmd prefix is !,+,# or ?
if cmdprefix == "!" or cmdprefix == "+" or cmdprefix == "#" or cmdprefix == "?" then
-- Remove the prefix and check the command
cmd = strsub(cmd, 2,strlen(cmd))
if cmd == "help" then
fFileHandle, sError = readfrom(sRulesFileName)
local sLine = read()
local sFileContent = ""
if sLine then
sFileContent = sLine
while 1 do
sLine = read()
if not sLine then
break
else
sFileContent = sFileContent..sLine.."\r\n"
end
end
readfrom() -- close filehandle
user:SendPM(sBotName,sFileContent)
return 1
elseif fFileHandle then
user:SendPM(sBotName,"Nothing found in "..sRulesFileName)
return 1
else
user:SendPM(sBotName,"Error "..sError)
end
readfrom()
end
end
end
end


----------------------------
and it works!!! - all i want now is to get it to open up in a Pm window :P

IceCoder

haha it is in a window "SendPM"

mmx

it does i'm so stupid

mmx

and ideas on how to get it to do another command like #network without having to write the same code time and time again?

cheers.

mmx

Bot = "Helper"

textArray = {}
QWarray = {}
antall = 0


function Main()

frmHub:RegBot(Bot)
loadText()
getLine()
end

function OnTimer()
getLine()
end

-- Triggers

TriggerPrivate = {
- ["+newbie"]="newbie.txt",
- ["+rules"]="rules.txt",
}

function DataArrival(curUser, sData)

if( strsub(sData, 1, 1) == "<" ) then
-- get the msg only using regular expression
s,e,msg = strfind(sData, "%b<> ([ -z]*)")
if (msg == "+rules") then
local text1 = ""
readfrom("rules.txt.txt")
while 1 do
local line = read()
if (line == nil) then
break
else
text1 = text1..line.."\r\n"
end
end
readfrom()
local text2 = ""
readfrom("newbie.txt")
while 1 do
local line = read()
if (line == nil) then
break
else
text2 = text2..line.."\r\n"
end
end
readfrom()

end
end
if( strsub(sData, 1, 1) == "<" ) or ( strsub(sData, 1, 4) == "$To:") then
s,e,msg = strfind(sData, "%b<> ([ -z]*)")
for key, value in TriggerPrivate do
if( strfind( strlower(msg), key) ) then
answer, x = gsub(value, "%b[]", curUser.sName)
local text = ""
readfrom(answer)
while 1 do
local line = read()
if (line == nil) then
break
else
text = text..line.."\r\n"
end
end
SendPmToNick(curUser.sName, Bot, text)

end
readfrom()
end

Syntax Error: `end' expected (to close `if' at line 68);
  last token read: `' at line 89 in string "-- Defines the name of the bot
..."

Bot = "Helper"


textArray = {}
QWarray = {}
antall = 0


function Main()

frmHub:RegBot(Bot)
loadText()
getLine()
end

function OnTimer()
getLine()
end

-- Triggers

TriggerPrivate = {
- ["+newbie"]="newbie.txt",
- ["+rules"]="rules.txt",
}

function DataArrival(curUser, sData)

if( strsub(sData, 1, 1) == "<" ) then
-- get the msg only using regular expression
s,e,msg = strfind(sData, "%b<> ([ -z]*)")
if (msg == "+rules") then
local text1 = ""
readfrom("rules.txt.txt")
while 1 do
local line = read()
if (line == nil) then
break
else
text1 = text1..line.."\r\n"
end
end
readfrom()
local text2 = ""
readfrom("newbie.txt")
while 1 do
local line = read()
if (line == nil) then
break
else
text2 = text2..line.."\r\n"
end
end
readfrom()

end
end
if( strsub(sData, 1, 1) == "<" ) or ( strsub(sData, 1, 4) == "$To:") then
s,e,msg = strfind(sData, "%b<> ([ -z]*)")
for key, value in TriggerPrivate do
if( strfind( strlower(msg), key) ) then
answer, x = gsub(value, "%b[]", curUser.sName)
local text = ""
readfrom(answer)
while 1 do
local line = read()
if (line == nil) then
break
else
text = text..line.."\r\n"
end
end
SendPmToNick(curUser.sName, Bot, text)

end
readfrom()
end

Syntax Error: `end' expected (to close `if' at line 68);
  last token read: `' at line 89 in string "-- Defines the name of the bot
..."

mmx

can u help me fix that?

thanx to sha_dow

plop

rewriten the whole thing.
make a folder named text, place in that all text files you want this bot 2 be able 2 show.
if the file is called rules.txt you can trigger it with !rules/+rules/#rules/Arules.
doesn't mather what prefix a user uses as long as it's 1 character and the file excists it works.
-- texter bot by plop
-- shows text files from a folder named text.
-- doesn't mather what prefix it 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
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

pHaTTy

on the other hand you cud have went to this thread

i wrote a long time ago............


http://board.univ-angers.fr/thread.php?threadid=46&boardid=12&styleid=1&sid=6fac38ac3b3103906d8ee71e4ec1b27c

l8rr,,

-phatty
Resistance is futile!

plop

QuoteOriginally posted by (uk-kingdom)pH?tt?
on the other hand you cud have went to this thread

i wrote a long time ago............


http://board.univ-angers.fr/thread.php?threadid=46&boardid=12&styleid=1&sid=6fac38ac3b3103906d8ee71e4ec1b27c

l8rr,,

-phatty
lol would have been a way easyer thing indeed.
next time pls tell me before i write something.  lol

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

pHaTTy

Resistance is futile!

mmx

cheers PLOP (what a name).

mmx

thanx to phatty. only thing about ur bots though there OTT they always have to go the extra mile and i preferr the simpl'er version by plop . . . like the black listing thing.

IceCoder

i can post a script later

plop

#23
QuoteOriginally posted by mmx
cheers PLOP (what a name).
yw.
my name isn't so weird if you are from the netherlands / belgium

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk