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
➜ Tips and tricks
➜ Forcing newlines on prompt lines
Forcing newlines on prompt lines
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
3 4
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #30 on Fri 11 Mar 2005 06:48 PM (UTC) |
Message
| Global Preferences > General Tab > Regular Expressions can Match on an Empty String
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #31 on Fri 11 Mar 2005 06:50 PM (UTC) |
Message
| It's under File->Global Preferences, the General tab. And the actual name of that option is "Regular expressions can match on an empty string". | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #32 on Fri 11 Mar 2005 06:51 PM (UTC) |
Message
| |
Posted by
| Bobble
Canada (76 posts) Bio
|
Date
| Reply #33 on Sat 12 Mar 2005 04:35 PM (UTC) Amended on Sat 12 Mar 2005 04:37 PM (UTC) by Bobble
|
Message
| I've come across another issue with the plugin.
It seems to be adding a line break at the end of every packet, regardless if it's a prompt or not. Now, this isn't usually a problem because, in most cases, the last line of a packet is the prompt, but when you stack a lot of commands and send them, the response from the server puts several prompts in a packet, and them sometimes ends the packet in the middle of a line, like this example:
You remove 1 gol 59 6f 75 20 72 65 6d 6f 76 65 20 31 20 67 6f 6c
denseal root, br 64 65 6e 73 65 61 6c 20 72 6f 6f 74 2c 20 62 72
inging the total 69 6e 67 69 6e 67 20 74 68 65 20 74 6f 74 61 6c
in the cache to 20 69 6e 20 74 68 65 20 63 61 63 68 65 20 74 6f
110....[32mH:28 20 31 31 30 2e 0d 0a 1b 5b 33 32 6d 48 3a 32 38
86.[37m.[32m M:4 38 36 1b 5b 33 37 6d 1b 5b 33 32 6d 20 4d 3a 34
814.[37m.[32m E: 38 31 34 1b 5b 33 37 6d 1b 5b 33 32 6d 20 45 3a
14090.[37m.[32m 31 34 30 39 30 1b 5b 33 37 6d 1b 5b 33 32 6d 20
W:18530.[37m.[1; 57 3a 31 38 35 33 30 1b 5b 33 37 6d 1b 5b 31 3b
31m B:100%.[0;37 33 31 6d 20 42 3a 31 30 30 25 1b 5b 30 3b 33 37
m [db eb]....You 6d 20 5b 64 62 20 65 62 5d ff f9 0d 0a 59 6f 75
remove 1 kelp, 20 72 65 6d 6f 76 65 20 31 20 6b 65 6c 70 2c 20
bringing the tot 62 72 69 6e 67 69 6e 67 20 74 68 65 20 74 6f 74
al in the cache 61 6c 20 69 6e 20 74 68 65 20 63 61 63 68 65 20
to 104....[32mH: 74 6f 20 31 30 34 2e 0d 0a 1b 5b 33 32 6d 48 3a
2886.[37m.[32m M 32 38 38 36 1b 5b 33 37 6d 1b 5b 33 32 6d 20 4d
:4814.[37m.[32m 3a 34 38 31 34 1b 5b 33 37 6d 1b 5b 33 32 6d 20
E:14090.[37m.[32 45 3a 31 34 30 39 30 1b 5b 33 37 6d 1b 5b 33 32
m W:18530.[37m.[ 6d 20 57 3a 31 38 35 33 30 1b 5b 33 37 6d 1b 5b
1;31m B:100%.[0; 31 3b 33 31 6d 20 42 3a 31 30 30 25 1b 5b 30 3b
37m [db eb]....Y 33 37 6d 20 5b 64 62 20 65 62 5d ff f9 0d 0a 59
ou remove 1 echi 6f 75 20 72 65 6d 6f 76 65 20 31 20 65 63 68 69
nacea, bringing 6e 61 63 65 61 2c 20 62 72 69 6e 67 69 6e 67 20
the total in the 74 68 65 20 74 6f 74 61 6c 20 69 6e 20 74 68 65
cache to 29.... 20 63 61 63 68 65 20 74 6f 20 32 39 2e 0d 0a 1b
[32mH:2886.[37m. 5b 33 32 6d 48 3a 32 38 38 36 1b 5b 33 37 6d 1b
[32m M:4814.[37m 5b 33 32 6d 20 4d 3a 34 38 31 34 1b 5b 33 37 6d
.[32m E:14090.[3 1b 5b 33 32 6d 20 45 3a 31 34 30 39 30 1b 5b 33
7m.[32m W:18530. 37 6d 1b 5b 33 32 6d 20 57 3a 31 38 35 33 30 1b
[37m.[1;31m B:10 5b 33 37 6d 1b 5b 31 3b 33 31 6d 20 42 3a 31 30
0%.[0;37m [db eb 30 25 1b 5b 30 3b 33 37 6d 20 5b 64 62 20 65 62
]....You remove 5d ff f9 0d 0a 59 6f 75 20 72 65 6d 6f 76 65 20
1 lobelia seed, 31 20 6c 6f 62 65 6c 69 61 20 73 65 65 64 2c 20
bringing the tot 62 72 69 6e 67 69 6e 67 20 74 68 65 20 74 6f 74
al in the cache 61 6c 20 69 6e 20 74 68 65 20 63 61 63 68 65 20
to 96....[32mH:2 74 6f 20 39 36 2e 0d 0a 1b 5b 33 32 6d 48 3a 32
886.[37m.[32m M: 38 38 36 1b 5b 33 37 6d 1b 5b 33 32 6d 20 4d 3a
4814.[37m.[32m E 34 38 31 34 1b 5b 33 37 6d 1b 5b 33 32 6d 20 45
:14090.[37m.[32m 3a 31 34 30 39 30 1b 5b 33 37 6d 1b 5b 33 32 6d
W:18530.[37m.[1 20 57 3a 31 38 35 33 30 1b 5b 33 37 6d 1b 5b 31
;31m B:100%.[0;3 3b 33 31 6d 20 42 3a 31 30 30 25 1b 5b 30 3b 33
7m [db eb]....Yo 37 6d 20 5b 64 62 20 65 62 5d ff f9 0d 0a 59 6f
u remove 1 ginse 75 20 72 65 6d 6f 76 65 20 31 20 67 69 6e 73 65
ng root, bringin 6e 67 20 72 6f 6f 74 2c 20 62 72 69 6e 67 69 6e
g the total in t 67 20 74 68 65 20 74 6f 74 61 6c 20 69 6e 20 74
he cache to 132. 68 65 20 63 61 63 68 65 20 74 6f 20 31 33 32 2e
...[32mH:2886.[3 0d 0a 1b 5b 33 32 6d 48 3a 32 38 38 36 1b 5b 33
7m.[32m M:4814.[ 37 6d 1b 5b 33 32 6d 20 4d 3a 34 38 31 34 1b 5b
37m.[32m E:14090 33 37 6d 1b 5b 33 32 6d 20 45 3a 31 34 30 39 30
.[37m.[32m W:185 1b 5b 33 37 6d 1b 5b 33 32 6d 20 57 3a 31 38 35
30.[37m.[1;31m B 33 30 1b 5b 33 37 6d 1b 5b 31 3b 33 31 6d 20 42
:100%.[0;37m [db 3a 31 30 30 25 1b 5b 30 3b 33 37 6d 20 5b 64 62
eb]....You remo 20 65 62 5d ff f9 0d 0a 59 6f 75 20 72 65 6d 6f
ve 1 bellwort fl 76 65 20 31 20 62 65 6c 6c 77 6f 72 74 20 66 6c
ower, bringing t 6f 77 65 72 2c 20 62 72 69 6e 67 69 6e 67 20 74
he total in the 68 65 20 74 6f 74 61 6c 20 69 6e 20 74 68 65 20
cache to 133.... 63 61 63 68 65 20 74 6f 20 31 33 33 2e 0d 0a 1b
[32mH:2886.[37m. 5b 33 32 6d 48 3a 32 38 38 36 1b 5b 33 37 6d 1b
[32m M:4814.[37m 5b 33 32 6d 20 4d 3a 34 38 31 34 1b 5b 33 37 6d
.[32m E:14090.[3 1b 5b 33 32 6d 20 45 3a 31 34 30 39 30 1b 5b 33
7m.[32m W:18530. 37 6d 1b 5b 33 32 6d 20 57 3a 31 38 35 33 30 1b
[37m.[1;31m B:10 5b 33 37 6d 1b 5b 31 3b 33 31 6d 20 42 3a 31 30
0%.[0;37m [db eb 30 25 1b 5b 30 3b 33 37 6d 20 5b 64 62 20 65 62
]....You remove 5d ff f9 0d 0a 59 6f 75 20 72 65 6d 6f 76 65 20
Here you can see the packet ended in the middle of a line beginning with "You remove"
The next packet begins:
1 slippery elm, 31 20 73 6c 69 70 70 65 72 79 20 65 6c 6d 2c 20
bringing the tot 62 72 69 6e 67 69 6e 67 20 74 68 65 20 74 6f 74
al in the cache 61 6c 20 69 6e 20 74 68 65 20 63 61 63 68 65 20
to 110....[32mH: 74 6f 20 31 31 30 2e 0d 0a 1b 5b 33 32 6d 48 3a
2886.[37m.[32m M 32 38 38 36 1b 5b 33 37 6d 1b 5b 33 32 6d 20 4d
And continues on from there. So the line that was broken up by the packets was "You remove 1 slippery elm, bringing the total in the cache to 110."
This is how that line displayed in the output to the screen:
You remove
1 slippery elm, bringing the total in the cache to 110.
It should appear as:
You remove 1 slippery elm, bringing the total in the cache to 110.
I'm pretty sure that the plugin is causing this because the problem goes away when I uninstall it. Is there any way to stop it from adding that line break?
Please let me know if you need some more information. |
Open the watch. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #34 on Sun 13 Mar 2005 06:56 PM (UTC) |
Message
| Instead of appending newlines to prompts, on IRE games you could use a temporary patch (until version 3.66 comes out). The following plugin replaces the GO AHEAD codes (\ff\f9) which appear at the end of the packet with newlines (\0d\0a) and suppresses the extra newlines at the beginning of the next packet if GA was already replaced, removing the need for additional triggers to suppress extra empty lines, which result from duplicate newlines being produced. It's in Python since I didn't want to deal with Replace anymore, but it shouldn't be too hard to port to something else. The GA pattern is supposed to only match if it follows the "-" character (the last char in an Achaea prompt) so it would need to be replaced by something that's appropriate in your case:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, March 13, 2005, 4:11 PM -->
<!-- MuClient version 3.65 -->
<!-- Plugin "PromptCatcher_Achaea" generated by Plugin Wizard -->
<muclient>
<plugin
name="PromptCatcher_Achaea"
author="Keldar"
id="8f85913ad96bd5bc255e434a"
language="Python"
purpose="Capturing prompts"
date_written="2005-03-13 16:10:15"
requires="3.65"
version="1.0"
>
</plugin>
<script>
<![CDATA[
import re
pat1 = re.compile(u"\-\u044f\u0449$")
pat2 = re.compile("^\x0d\x0a")
terminated = False
#from time import clock
def OnPluginPacketReceived(packet):
global terminated, pat1,pat2
#start = clock()
m1 = pat1.match(packet[len(packet)-3:])
m2 = pat2.match(packet[:2])
if m1:
terminated = True
packet = packet[:len(packet)-2] + "\x0d\x0a"
if m2:
if terminated:
packet = packet[2:]
terminated = False
#timing = clock() - start
#world.AppendToNotepad("test", repr(packet) + "\r\n")
#world.Note (timing)
return packet
]]>
</script>
</muclient>
| Top |
|
Posted by
| Bobble
Canada (76 posts) Bio
|
Date
| Reply #35 on Tue 15 Mar 2005 04:10 PM (UTC) Amended on Tue 15 Mar 2005 04:13 PM (UTC) by Bobble
|
Message
| Hey Ked!
I got python scripting up and running, so I gave this plugin a whirl. It's not putting any new lines in at all, which makes me think I haven't altered the plugin to properly catch the last character of a prompt line in Aetolia.
Prompts in Aetolia look like this:H:3038 M:3579 E:15200 W:17420 B:100% [db eb]
They always end with the "]" character. With this in mind, I altered one line of the plugin as such:pat1 = re.compile(u"\]\u044f\u0449$")
The "\-" has been replaced by "\]" now. But it doesn't seem to match this as the end of the prompt and no new lines are being added. Have I made this alteration correctly or is there something else that must be done?
As always, any help is appreciated.
|
Open the watch. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #36 on Tue 15 Mar 2005 08:50 PM (UTC) |
Message
| This one replaces any and all GA codes it finds in a packet, still supressing extra newlines. You'll also need to replace the "-" char with your "]". The previous one only replaced the GA found at the very end of the packet, meaning that all other prompts were left untouched.
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE muclient>
<!-- Saved on Sunday, March 13, 2005, 4:11 PM -->
<!-- MuClient version 3.65 -->
<!-- Plugin "PromptCatcher_Achaea" generated by Plugin Wizard -->
<muclient>
<plugin
name="PromptCatcher_Achaea"
author="Keldar"
id="8f85913ad96bd5bc255e434a"
language="Python"
purpose="Capturing prompts"
date_written="2005-03-13 16:10:15"
requires="3.65"
version="1.0"
>
</plugin>
<script>
<![CDATA[
import re
pat1 = re.compile(u"(\-\u044f\u0449)($)?")
pat2 = re.compile("^\x0d\x0a")
terminated = False
def repl(mo):
global terminated
if mo.groups()[1] == "":
terminated = True
return "-\x0d\x0a"
def OnPluginPacketReceived(packet):
global terminated, pat1,pat2
if terminated:
packet = pat2.sub("",packet)
terminated = False
packet = pat1.sub(repl, packet)
return packet
]]>
</script>
</muclient>
| Top |
|
Posted by
| Bobble
Canada (76 posts) Bio
|
Date
| Reply #37 on Tue 15 Mar 2005 11:03 PM (UTC) Amended on Tue 15 Mar 2005 11:04 PM (UTC) by Bobble
|
Message
| Hi Ked!
Thanks for all your help, but I'm still not having any luck with this plugin. It's not adding any new line breaks. I wish I could give you more instructive feed back, but I don't know python or how to read packets all that well.
Here are the changes I made to the plugin:pat1 = re.compile(u"(\]\u044f\u0449)($)?")
and
Here's a sample of some output I got when I spammed getting several different herbs from my cache:H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 prickly ash bark, bringing the total in the cache to 101.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 goldenseal root, bringing the total in the cache to 111.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 kelp, bringing the total in the cache to 106.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 lobelia seed, bringing the total in the cache to 98.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 ginseng root, bringing the total in the cache to 134.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 bellwort flower, bringing the total in the cache to 135.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 slippery elm, bringing the total in the cache to 112.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 bloodroot leaf, bringing the total in the cache to 74.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 valerian, bringing the total in the cache to 17.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 skullcap, bringing the total in the cache to 118.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 irid moss, bringing the total in the cache to 71.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 hawthorn berry, bringing the total in the cache to 83.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 bayberry bark, bringing the total in the cache to 27.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 sileris, bringing the total in the cache to 13.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 black cohosh, bringing the total in the cache to 115.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 kola nut, bringing the total in the cache to 94.
H:3260 M:3579 E:15200 W:17420 B:100% [d eb]You remove 1 echinacea, bringing the total in the cache to 27.
As you can see, the newlines aren't being added at all. Is there any more information I could give you that might help solve this problem?
|
Open the watch. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #38 on Wed 16 Mar 2005 12:23 AM (UTC) |
Message
| Strange, it works for me on Achaea, although it still has the same problem as Lusternia's server-side prompt newlines - extra empty lines every once in a while. About the only thing that comes to my mind is that you somehow managed to get the non-Unicode version of Python, or maybe pywin32. Replace the OnPluginPacketReceived function with the following one and post the output it gives:
def OnPluginPacketReceived(packet):
global terminated, pat1,pat2
world.AppendToNotepad("test", repr(packet))
if terminated:
packet = pat2.sub("",packet)
terminated = False
packet = pat1.sub(repl, packet)
return packet
| Top |
|
Posted by
| Bobble
Canada (76 posts) Bio
|
Date
| Reply #39 on Wed 16 Mar 2005 12:36 AM (UTC) Amended on Wed 16 Mar 2005 12:42 AM (UTC) by Bobble
|
Message
| The output to the screen looked like this:You remove 1 kelp, bringing the total in the cache to 104.
H:3260 M:3479 E:10672 W:17420 B:100% [db eb]You remove 1 irid moss, bringing the total in the cache to 69.
The output to the notepad was:
u'You remove 1 kelp, bringing the total in the cache to 104.\r\n\x1b[32mH:3260\x1b[37m\x1b[32m M:3479\x1b[37m\x1b[1;33m E:10672\x1b[0;37m\x1b[32m W:17420\x1b[37m\x1b[1;31m B:100%\x1b[0;37m [db eb]\xff\xf9'u'You remove 1 irid moss, bringing the total in the cache to 69.\r\n\x1b[32mH:3260\x1b[37m\x1b[32m M:3479\x1b[37m\x1b[1;33m E:10672\x1b[0;37m\x1b[32m W:17420\x1b[37m\x1b[1;31m B:100%\x1b[0;37m [db eb]\xff\xf9'
|
Open the watch. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #40 on Wed 16 Mar 2005 12:50 AM (UTC) |
Message
| Once again - very strange. Either your Python is screwed up, or mine is :) The problem is that the GA regexp is set to match on the Unicode escape of "\u044f\u0449", which is what I get, but in your case it seems that the GA code is the normal "\xff\xf9". So to fix it, simply replace the pattern for pat1 with: "(\-\xff\xf9)($|\x0d\x0a)?". The extra option in the second group, seems to capture most of the extra lines, and won't hurt in any case. | Top |
|
Posted by
| Ked
Russia (524 posts) Bio
|
Date
| Reply #41 on Wed 16 Mar 2005 12:52 AM (UTC) |
Message
| And try to optionally include/exclude the 'u' before the pattern string, to see what works. | Top |
|
Posted by
| Bobble
Canada (76 posts) Bio
|
Date
| Reply #42 on Wed 16 Mar 2005 02:25 PM (UTC) |
Message
| Hey Ked!
Seems to work like a charm! Thanks for all your help, it's much appreciated. |
Open the watch. | Top |
|
Posted by
| DT
(1 post) Bio
|
Date
| Reply #43 on Tue 12 Apr 2005 04:53 PM (UTC) |
Message
| Hiya, umm, I'm sort of having a similar problem with MUSH, and Achaea and after having pretty much experienced all of the above! I was wondering if I could get some help with these scripts, me having to pick up what I can from examples etc. :)
Basically, I used the updated script by Nick, and got the extra spaces, the weird newlines on things that aren't prompts, so I went back to the first one that was put up.
I'm also using that "Deletes the empty spaces trigger" using "^$", which is a little inconvenient but works, expecially since I've never heard of Python before, or could figure out which bits to change into VBscript (which is what I'm using).
Well, now theres a slight problem that the prompt isn't being picked up, on -every- prompt that comes, basically whenever a few lines are sent rapidly to the world consecutively... possibly its not the fact they're being sent, but that information is coming back too fast...
Its frustrating, especially when important triggers are set for those lines and they aren't recognised... I can't quite seem to figure out how to make either:
1 The prompt be recognised regardless of whats in front or behind (perhaps if the plugin isn't detecting it for some reason).
or 2 Make a trigger, that will send the real command back through the system, since what I've been doing mostly, is putting a trigger that captures stuff that might be tagged onto a prompt and reoutputting it, minus prompt stuff. This doesn't trigger anything though.
Wow, hope that was easy to understand, I'm running 3.65 so any help would be greatly appreciated! Thanks. | Top |
|
Posted by
| Tsunami
USA (204 posts) Bio
|
Date
| Reply #44 on Tue 12 Apr 2005 07:34 PM (UTC) |
Message
| Release 3.66 sometime soon please... I'm begging you here Nick ;) ? | 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.
135,504 views.
This is page 3, subject is 4 pages long:
1
2
3 4
It is now over 60 days since the last post. This thread is closed.
Refresh page
top