Multi-line Tellcapture

Posted by Giz on Tue 14 Aug 2007 12:14 AM — 11 posts, 42,707 views.

#0
Ok searched the forum tried all the info i could find but still i'm running short i get the trigger to capture the first line but none of the rest this is the trigger and the script

the line to match from: Someone tells you, "something"
this can also be said in diffren languages and it would be like this: Someone tells you in undercommon, "something"

</trigger>
<trigger
enabled="y"
lines_to_match="10"
match="^(.+) (say|says|tell|tells|ask|asks) (.*), &quot;(.+)&quot;\Z"
multi_line="y"
omit_from_output="n"
regexp="y"
script="dotell"
sequence="2"
other_text_colour="black"
other_back_colour="black"
>
</trigger>

sub DoTell (name, output, argv)

world.AppendToNotepad "Tells", FormatDateTime (Now, vbShortTime) & ": " & ""& argv(1) &" "& argv(2) &" "& argv(3) &": "& argv(4) &"" + vbcrlf

End sub


thanks for any replies
/Giz
Australia Forum Administrator #1
The default for a dot in a regular expression is to match everything *except* a newline. Since your text has newlines in it, you need to add the "dot matches all" option, like this:


Match on: ^(.+) (say|says|tell|tells|ask|asks) (.*), "(?s)(.+)"\Z


That seemed to work OK for me, matching multiple lines.
Amended on Tue 14 Aug 2007 05:37 AM by Nick Gammon
#2
Yes Thanks nick that worked for capture but now i runned into a another problem, when it captures it captures the tell and then it takes the next line no matter what it is seems like the trigger doesn't end after the last "


/giz
USA #3
I'm not sure what type of mud or mush you are using, but for most servers, tells are sent as one line which can be linewrapped by the client. Are you positive you need a multiline trigger for this?
#4
Sadly yes because the mud i play "Realms of the Dragon" don't autowrap this it just auto sets the next line on a col break like this:
someone tells you in common, "HoSen e fan helt
imba"
maybe the easiest way is to force the immortals to change the wrapings

/Giz
Australia Forum Administrator #5
Can you please post another copy of your exact trigger?

See http://mushclient.com/copying

Also, post the lines of output from the MUD that result in an overrun - does the problem line have a " in it? (Include the extra line that appears in the output).
Amended on Tue 14 Aug 2007 08:43 PM by Nick Gammon
#6
ok this is a sample from the notepad:
12:50: You ask someone, someone, someone, someone and someone in undercommon: "uh?"
Holding : Gnomishly Dragon Enchanted Celestial Armagor's Scourge (Storm
Bonded) (left hand) and Ultimately Gnomishly Insulated Spiked Adamantite Shield (right


The Trigger: </trigger>
<trigger
enabled="y"
lines_to_match="4"
match="^(.+) (say|says|tell|tells|ask|asks) (.*), &quot;(?s)(.+)&quot;$\Z"
multi_line="y"
omit_from_output="n"
regexp="y"
script="dotell"
sequence="2"
other_text_colour="black"
other_back_colour="black"
>
</trigger>
</triggers>

the output from the mud:
someone says in undercommon: "but you did superlow damage.. 1.5k.. without my overshield"

and the script:
sub DoTell (name, output, argv)

Dim Tell

Tell = split(argv(4))

world.AppendToNotepad "Tells", FormatDateTime (Now, vbShortTime) & ": " & ""& argv(1) &" "& argv(2) &" "& argv(3) &": "& argv(4) &"" + vbcrlf


End sub

finially i should maybe say that i got all of this in a plugin don't know if that matters.

/Giz
Australia Forum Administrator #7
Quote:

ok this is a sample from the notepad:
12:50: You ask someone, someone, someone, someone and someone in undercommon: "uh?"
Holding : Gnomishly Dragon Enchanted Celestial Armagor's Scourge (Storm
Bonded) (left hand) and Ultimately Gnomishly Insulated Spiked Adamantite Shield (right

...

someone says in undercommon: "but you did superlow damage.. 1.5k.. without my overshield"


I'm not seeing here the extra line you spoke about, however I can reproduce it like this:


Someone tells you, "
Ok searched the forum tried all the info i could find but
still i'm running short i get the trigger to capture the
first line but none of the rest this
is the trigger and the script"
Someone else tells you, "oh no, another line"


If I test that, it matches on both tells, for the simple reason that it finds:


someone tells you ... "something"


The problem is, in the batch of lines it is looking at, the "something" includes a second tell. I am working on a workaround for this, will post again soon.
Australia Forum Administrator #8
Well I got it to work fairly well. I redid it in Lua, sorry for that, but VBscript isn't as good at string handling. For this to work you need to make Lua your main script language. Alternatively, make this single trigger into a small plugin that uses Lua, that will work.


<triggers>
  <trigger
   enabled="y"
   lines_to_match="10"
   match="^(.+) (say|says|tell|tells|ask|asks) (.*), &quot;(?s)(.+?)&quot;\Z"
   multi_line="y"
   regexp="y"
   send_to="12"
   sequence="2"
  >
  <send>

-- remove backslashes from in front of the double-quotes
line = string.gsub ([[%0]], '\\\\"', '"')

result = ""

-- get last match
for w in string.gmatch (line, '.-, ".-"') do
  result = w
end -- for

-- find who told us what again
who, what = string.match (result, '(.-), "(.+)"')

-- append to notepad
AppendToNotepad ("Tells", 
                os.date ("%H:%M") .. ": " .. who .. ": " .. what .. "\\r\\n")

</send>
  </trigger>
</triggers>


What this does is (in send-to-script, so it doesn't need a script file):

  • Remove backslashes from in front of the quotes - MUSHclient adds them in when it sees send-to-script, but we don't need them for multi-line literals.
  • Scans the matching text for "someone tells you something", dropping all but the last one.
  • Rescans the last matching one to find the "who" and "what".
  • Logs that one to the notepad.


That should result in each line only being logged once.
#9
Thanks nick i tried and put that one in to a plugin and it work to an extent i still get the same problem though with it capturing lines that not includes a tell.

I guess i just give that a rest and go with the one line tell capture untill i've managed to get the immorts to change the mud handler


/giz
USA #10
You could try having the termination being a line which ends with quotation mark. You might be unlucky enough to get a message where someone happens to have a set of quotes within the message in just the wrong spot, but it will be better than nothing.