!news wont trigger without args
 

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

!news wont trigger without args

Started by thelizno, 17 November, 2005, 08:09:46

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

thelizno

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

Dessamator

#1
if args ~= nil

This means that, that command  will only  function when there is an arg.
Hope it helps.
Ignorance is Bliss.

thelizno

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

thelizno

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

Dessamator

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.
Ignorance is Bliss.

thelizno

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!

SMF spam blocked by CleanTalk