Yes, I am new to lua.. and this is all a working progress..
but I cannot seem to find anything wrong with this code!!
Quotefunction ToArrival(user, data)
s,e,to,fr,pf,cmd,args = string.find(data, "^$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S)(%S+)%s+(.*)")
if to == botnick and pf == "!" then
if cmd == "news" and args ~= nil then SendPmToNick(fr,botnick,"** Announcing news ..") end
if cmd == "addnews" then SendPmToNick(fr,botnick,"** Adding news .."..args) end
end
end
PMing the bot..
'!news' Results: None.
'!addnews' Results: None.
'!news applepie' Results: '
** Announcing news ..'
WHAT is wrong here?? I even included if args ~= nil .. but that didn't work either.
Please help me out. :)
if args ~= nil
This means that, that command will only function when there is an arg.
Hope it helps.
QuoteOriginally posted by Dessamator
if args ~= nil
This means that, that command will only function when there is a trig.
Hope it helps.
Oh, I see.. :P
if arfs ~= nil was removed..
It still gets the same result thou. >:(
[17/11-05 08:30:34] !news
[17/11-05 08:30:38] !addnews ss
[17/11-05 08:30:38] <@mayhem> ** Adding news ..ss
[17/11-05 08:30:41] !news ss
[17/11-05 08:30:41] <@mayhem> ** Announcing news ..
s,e,to,fr,pf,cmd,args = string.find(data, "^$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S)(%S+)%s+(.*)")
Well that was only 1 error in the scripting, the second one is the string.find, this part particularly :
%s+(.*)"
Quote+ 1 or more repetitions (returns nil if not found)
* 0 or more repetitions (returns "" on 0 repetitions)
In other words the string.find will only work when there is a space after the trig.It has nothing to do with what u write after it, even if u write "!news ", notice the space, it will work .
Hope it Helps, btw these are just hints since ur trying to learn.
Thank you! :D
s,e,to,fr,pf,cmd,args = string.find(data, "^$To:%s+(%S+)%s+From:%s+(%S+)%s+$%b<>%s+(%S)(%S+)(.+)")
.. ran perfectly!