Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ Lua ➜ Chat to Notepad.

Chat to Notepad.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Shigs   (27 posts)  Bio
Date Wed 30 Jan 2008 08:02 PM (UTC)
Message
Right, I'm catching * <chat> * via a trigger and then sending %0 to notepad, but if a \n is held in the line it will only send the text before \n to notepad and the rest is shown in my screen, ANSI colours and all.

Any ideas of a workaround for this?
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #1 on Wed 30 Jan 2008 08:10 PM (UTC)

Amended on Wed 30 Jan 2008 08:11 PM (UTC) by Nick Gammon

Message
How have you done that? Like this?


SendToNotepad ("Chats", "%0")


The line breaks inside the %0 will throw things out. Try:


SendToNotepad ("Chats", [[%0]])


In Lua [[ ... ]] is a multi-line string.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shigs   (27 posts)  Bio
Date Reply #2 on Wed 30 Jan 2008 08:15 PM (UTC)
Message
I actually just had "append to notepad" as my location and was just passing %0 back.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #3 on Wed 30 Jan 2008 09:58 PM (UTC)
Message
Try "send to script" and the line of script I had above.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shigs   (27 posts)  Bio
Date Reply #4 on Fri 01 Feb 2008 10:09 AM (UTC)
Message
ok that works, but all the lines are running on with each other.

and
<send>AppendToNotepad ("Chats", [[%0]]."\r\n")</send>

dosen't work, how do I add a newline at the end of the string?
Top

Posted by Shigs   (27 posts)  Bio
Date Reply #5 on Fri 01 Feb 2008 10:24 AM (UTC)
Message
Here's my Plugin file .


<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Friday, February 01, 2008, 10:55 AM -->
<!-- MuClient version 4.14 -->

<!-- Plugin "chat_to_notepad" generated by Plugin Wizard -->

<muclient>
<plugin
   name="chat_to_notepad"
   author="Blaise"
   id="1ff1158d248784be2a84430e"
   language="Lua"
   purpose="Sends All Chat Messages to Notepad"
   date_written="2008-02-01 10:54:54"
   requires="4.00"
   version="1.0"
   >

</plugin>


<!--  Triggers  -->

<triggers>
  <trigger
   enabled="y"
   ignore_case="y"
   match="&lt;chat&gt; *"
   omit_from_output="y"
   sequence="100"
  >
  <send>AppendToNotepad ("Chats", [[%0]],"\r\n")</send>
  </trigger>
  <trigger
   enabled="y"
   ignore_case="y"
   match="* &lt;chat&gt; *"
   omit_from_output="y"
   send_to="12"
   sequence="100"
  >
  <send>AppendToNotepad ("Chats", [[%0]],"\r\n")</send>
  </trigger>
</triggers>

</muclient>

Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #6 on Fri 01 Feb 2008 04:12 PM (UTC)
Message
That should be:

AppendToNotepad ("Chats", [[%0]].."\n")

Lua uses two periods to concatenate strings, not a comma.

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Shigs   (27 posts)  Bio
Date Reply #7 on Sat 02 Feb 2008 10:18 AM (UTC)
Message
Ok, Is there any reason why %0 wouldn't contain the whole string?

My problem is,

Quote:

[[Blaise <CHAT> I'm sure there's a good excuse.]]
[[Tanak <CHAT> Blaise, fix that script?]]
[[Alexi <CHAT> Yeah, like sleeping.]]
[[Elas <CHAT> and dont let him lie to you]]
[[Alexi <CHAT> I have to be BACK here, on duty at noon. I need to go home and sleep. And he knows that.]]
[[Tanak <CHAT> Alexi in the army too?]]
[[Alexi <CHAT> No, I'm in the Lazy Asses Who Get Payed well field. I'm a security guard.]]
[[Tanak <CHAT> Hahaha. We're pretty lazy too.]]
[[Tanak <CHAT> Ok not really, but I like to act like I am.]]
[[Elas <CHAT> it lazy sometimes i have done it....]]
[[Tanak <CHAT> The lazy part is watching your CO watch porn on your computer.]]
[[Elas <CHAT> lol]]
[[Blaise <CHAT> No I didn't fix the script.. I went out last night straight after work and got very very drunk]]
[[Tanak <CHAT> Niiiice, what made it break? (DLed your other mod, very nifty)]]
[[Taladorn <CHAT> and now you have hangover?]]
[[> Taladorn <CHAT> best way of curing hangover is drink more]]
[[Blaise <CHAT> No, I don't have a hangover.]]
[[> Tanak <CHAT> I always used vinigar and tomato juice.]]
[[Elas <CHAT> are you a armed guard?]]
[[Taladorn <CHAT> wow, you are lucky, i always get hangover no matter what]]
[[Blaise <CHAT> Fortunatly, I drank all the right drinks, got my head down at]]
[[> Tanak <CHAT> hahaha]]
[[Tanak <CHAT> Like that alakzeler commercia.]]
[[Elas <CHAT> it lazy sometimes i have done it....]]
[[Tanak <CHAT> The lazy part is watching your CO watch porn on your computer.]]
[[Elas <CHAT> lol]]
[[Blaise <CHAT> No I didn't fix the script.. I went out last night straight after work and got very very drunk]]
[[Tanak <CHAT> Niiiice, what made it break? (DLed your other mod, very nifty)]]
[[Taladorn <CHAT> and now you have hangover?]]
[[Taladorn <CHAT> best way of curing hangover is drink more]]
[[Blaise <CHAT> No, I don't have a hangover.]]
[[Tanak <CHAT> I always used vinigar and tomato juice.]]
[[Elas <CHAT> are you a armed guard?]]
[[Taladorn <CHAT> wow, you are lucky, i always get hangover no matter what]]
[[Blaise <CHAT> Fortunatly, I drank all the right drinks, got my head down at about 3am and I'm awake now at 11:15, fresh and fine to go and be horrible to the people who'll be in work with hangovers]]
[[Tanak <CHAT> hahaha]]
[[Tanak <CHAT> Like that alakzeler commercia.]]



Quote:
[[Blaise <CHAT> Fortunatly, I drank all the right drinks, got my head down at about 3am and I'm awake now at 11:15, fresh and fine to go and be horrible to the people who'll be in work with hangovers]]


That cut off at
Quote:
Blaise <CHAT> Fortunatly, I drank all the right drinks, got my head down at about 3am


and the rest of the string still came through on my output, So.. I'm under the impression that the trigger dosen't register it as all being part of the same string or perhaps it isn't for all intents and purposes and therefor only omits and appends to notepad, the part that seems to be apart of that 'line'


The problem is, I need to catch all of it.

Any ideas Gents?
Top

Posted by Shaun Biggs   USA  (644 posts)  Bio
Date Reply #8 on Sat 02 Feb 2008 05:11 PM (UTC)

Amended on Sat 02 Feb 2008 05:23 PM (UTC) by Shaun Biggs

Message
It might be better to use a regex trigger, but they have to be case sensative. You have to match the exact text that is shown.

<triggers>
  <trigger
   enabled="y"
   regexp="y"
   match="^\[\[(\w+) <CHAT> (.*)\]\]$"
   omit_from_output="y"
   sequence="100"
   send_to="12"
  >
  <send>AppendToNotepad ("Chats", "%0")</send>
  </trigger>
</triggers>


Edit: I will be able to convert this with forum codes at SOME point...

It is much easier to fight for one's ideals than to live up to them.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #9 on Sat 02 Feb 2008 08:51 PM (UTC)
Message
Quote:

So.. I'm under the impression that the trigger dosen't register it as all being part of the same string or perhaps it isn't for all intents and purposes and therefor only omits and appends to notepad, the part that seems to be apart of that 'line'


Unless you use a multi-line trigger, and they can be fiddly to get right, a trigger only matches a single line.

One simple solution might be to configure the MUD to have a long "line width". Some MUDs let you specify something like 0 as the line width, which means "let the client wrap" rather than the server wrapping. Then the trigger will catch it all.

See if that is possible before we go down the multi-line path.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shigs   (27 posts)  Bio
Date Reply #10 on Sat 02 Feb 2008 09:42 PM (UTC)
Message
I think I've discovered the true problem here and it's one that I'm struggling to think of a way around.

When someone uses a channel it sends out


NAME <CHANNEL> TEXT
or

<CHANNEL> NAME EMOTE

now I've got triggers to match both of them as you can see above.. but there's no way for me to tell the client when a line ends...

What I want to know is, Am I missing something? or can I use ANSI codes? each line is coloured in purple and thus has the RESET code at the end, can Mushclient match up ANSI codes in triggers? what sort of alias would I be looking at if it does to match up

NAME <CHANNEL> TEXT %RESET^

<CHANNEL> NAME EMOTE %RESET%


and if it can't match them in triggers is there some way it could be implemented?

Thanks
Liam
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #11 on Sat 02 Feb 2008 10:58 PM (UTC)
Message
Are the square brackets you posted earlier part of the chat? Or did you add that?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shigs   (27 posts)  Bio
Date Reply #12 on Sun 03 Feb 2008 10:05 AM (UTC)
Message
No I added them.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #13 on Sun 03 Feb 2008 08:42 PM (UTC)

Amended on Sun 03 Feb 2008 08:50 PM (UTC) by Nick Gammon

Message
I think it can be done fairly easily, if the chat lines are a distinctive colour. You are going to need two triggers (or more if you count the emotes). The first one detects the start of a chat sequence, eg.

NAME <CHANNEL> TEXT


The second one, which is normally disabled, matches anything (ie. matches "*") so it can pick up subsequent lines. I would also make it a lower sequence number (eg. 50).

Now what will happen is:


  • Main trigger matches, saves the matching text in a variable. It also enables the secondary (match everything) trigger, and sets the "match all" trigger to NOT keep evaluating. Clearing "keep evaluating" stops the new line from being processed by other trigger handlers.

  • When the secondary trigger matches (that is, on the next line), it checks two things:


    1. Is this new line in purple? If not, we have reached the end of the multi-line chat. We can send the saved chat line to the notepad, disable ourselves, and set "keep evaluating" for ourselves. You can detect the style runs in the line ( and hence the colours) by using GetStyleInfo for the last line in the output buffer.

    2. Is this new line the start of a new chat? (That is, two chats in a row). Again we send the saved line(s) to the notepad window, disable ourselves and set "keep evaluating" so the real chat trigger will handle it.

    3. If neither of the above, it is a continuation chat line. Leave ourselves enabled and concatenate this line with the previously saved chat line.




I imagine the secondary trigger (which I have named "match_all") will look something like this:


<triggers>
  <trigger
   match="*"
   name="match_all"
   send_to="12"
   sequence="50"
  >
  <send>
saved_chat_line = saved_chat_line or ""

-- get text colour of first style in last line in buffer
colour = GetStyleInfo (GetLinesInBufferCount (), 1, 14)

if colour ~= ColourNameToRGB ("magenta") or
   string.match ("%0", "^.+ &lt;.+&gt; .+") then
  EnableTrigger ("match_all", 0)
  SetTriggerOption ("match_all", "keep_evaluating", "1")
  SendToNotepad ("chats", saved_chat_line)
else
  saved_chat_line = saved_chat_line .. " %0"
end -- if
</send>
  </trigger>
</triggers>


I assume that the main matching trigger (that matches the first chat line) will put the matching text into saved_chat_line, ready for the rest to be appended to it.

Notice how the trigger is not currently enabled - it is the job of the first trigger to do that. Also when it finds a line not in magenta, or in magenta but starting a new chat, it disables itself, sets keep_evaluating, and sends the matching chat to the notepad window.



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Shigs   (27 posts)  Bio
Date Reply #14 on Mon 04 Feb 2008 11:30 AM (UTC)
Message
And what would the first trigger look like?
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


61,360 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.