WriteLog and duplicate lines

Posted by Rollanz on Tue 15 Jul 2014 11:40 PM — 4 posts, 16,565 views.

#0
I'm making a script to copy news posts in Achaea to a log file, and for some reason each line in my output log file is duplicated. Alias is like this:

<aliases>
  <alias
   match="^copyArchive (\d+)$"
   enabled="y"
   group="archive"
   regexp="y"
   send_to="12"
   keep_evaluating="y"
   sequence="100"
  >
  <send>numPosts=%1

archiveIndex=archiveIndex or 0
archiveIndex=archiveIndex+1

OpenLog("PublicArchives.txt",true)
EnableGroup("archiver",true)

world.Send("read ", archiveIndex)
</send>
  </alias>
</aliases>



And the trigger:


<triggers>
  <trigger
   group="archiver"
   keep_evaluating="y"
   match="^(.*)$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>input_string="%1"

if string.find(input_string,"Type MORE if you wish to continue reading%.")~=nil then
world.Send("more")
elseif string.find(input_string,"PUBLIC SECTION (%d+)/(%d+)")==1 then
numPosts=numPosts-1
if numPosts==0 then
FlushLog()
CloseLog()
EnableGroup("archiver", false)
else
archiveIndex=archiveIndex+1
world.Send("read ", archiveIndex)
end
(%d+)/(%d+)"))
elseif string.match(input_string, "News &gt; ")==1 then
--print("ignore")
else
WriteLog(input_string)
Note("wrote log: ", input_string)
end
  </trigger>
</triggers>


And hints as to what is causing the duplication would be appreciated.
Australia Forum Administrator #1
Once you have done an OpenLog all incoming lines are logged anyway, so doing a WriteLog would log them a second time.
#2
So the correct solution is as simple as gagging the trigger? Thanks!
Australia Forum Administrator #3
Ah yes, if that was what that code was doing. :)

If I may suggest, indenting the inside of "if" blocks makes the structure easier to follow.