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
➜ General
➜ Trigger help - channels
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1 2
| Posted by
| Jeffrey F. Pia
(49 posts) Bio
|
| Date
| Sun 22 Feb 2004 09:03 AM (UTC) |
| Message
| I have trigs which send lines from various channels to different notepad windows (nice feature btw, just wish color codes could be logged as well). I run into a problem when I try to skip text from certain mobs that use that same syntax.
I want to log any tells I get. This is the expression I use:
^.*You tell (?!the CLAN).+$|^(!?the golden dragon|The Father of CHAoS|Questor).+ tells you .+$
It logs all outgoing tells just fine, but skips incoming tells completely. Any idea why?
Here is the syntax for the text I'm trying to catch:
Xxx tells you 'Hi!' Or
22 Feb 02:52 - Xxx tells you 'Hi!'
Syntax for the text I'm trying to skip:
the golden dragon tells you 'blah blah'
Questor tells you 'blah blah'
The Father of CHAoS tells you 'blah blah'
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sun 22 Feb 2004 11:43 PM (UTC) |
| Message
| You have reversed ?! in the second part of the trigger as !?.
If you change it to how I have it below, it seems to work ...
^.*You tell (?!the CLAN).+$|^(?!the golden dragon|The Father of CHAoS|Questor).+ tells you .+$
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Jeffrey F. Pia
(49 posts) Bio
|
| Date
| Reply #2 on Mon 23 Feb 2004 06:59 AM (UTC) Amended on Mon 23 Feb 2004 11:26 PM (UTC) by Jeffrey F. Pia
|
| Message
| *thwap self*
Thanks... :)
In an effort to not make this thread so pointless, here's another prob I've been having. Sometimes when I spam commands, the MUD output comes after my prompt:
< 25103/28300 2400/5820 6321/6322 Dbl: 2 0QT 431tnl NS 1000 > Xxx tells you 'Hi!'
Is there a way to mod the regular expression so that the prompt is not logged, or would it be better to parse the text with a script? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Mon 23 Feb 2004 09:15 PM (UTC) |
| Message
| Yes, with judicious use of brackets.
Something like this:
^(?:\<.*\>)? ... and the rest of it ...
However a little testing has revealed it is hard to get it right.
I think I would make two triggers, to save some confusion (one for "you tell" and one for "tells you"), then the first part above should strip out the prompt, and then the rest can be returned in %2 or %3 or wherever it shows up. :) |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Jeffrey F. Pia
(49 posts) Bio
|
| Date
| Reply #4 on Tue 24 Feb 2004 04:10 AM (UTC) |
| Message
| I currently use the Send to: Notepad (append) option. Is it possible to have 2 trigs logging to the same notepad? Seemed like the distinguishing variable was the trig's name.
Also, I think I read somewhere that you had a plugin which was able to push raw color codes to an open log file. Maybe I can mod my trigs a little to open a specific channel's log file, then use code from your plugin to push the text and color code to the respective log? Dunno how much overhead that would add though. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Tue 24 Feb 2004 04:29 AM (UTC) |
| Message
| |
| Posted by
| Rinor
(16 posts) Bio
|
| Date
| Reply #6 on Wed 25 Feb 2004 12:02 AM (UTC) |
| Message
| | I've been trying to log chat messages with no luck. My prefix for chat is "[] " without the quotation marks. Not sure if it's even possible because chat isn't part of output from the mud. Thanks for any help/explanation. | | Top |
|
| Posted by
| Poromenos
Greece (1,037 posts) Bio
|
| Date
| Reply #7 on Wed 25 Feb 2004 12:43 AM (UTC) |
| Message
| | By the way, I have also found that the expression (([A-Za-z]+) tells you|You tell (.*?)) '(.*?)' works nicely, it only matches letters before "tells you", so the prompt or spaces will not match... That's what I always use, and I make it match on color too, just to be safe. |
Vidi, Vici, Veni.
http://porocrom.poromenos.org/ Read it! | | Top |
|
| Posted by
| Flannel
USA (1,230 posts) Bio
|
| Date
| Reply #8 on Wed 25 Feb 2004 12:57 AM (UTC) |
| Message
| Rinor, I assume youre talking about Chat via MC chat?
If so, theyre world.notes, and might log normally, but I woulnt be surprised if they dont.
If they dont, you can just use the plugin callbacks to write your chats to a log file.
However you wont be using a trigger, which is what I think youve been trying. |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #9 on Wed 25 Feb 2004 03:01 AM (UTC) |
| Message
| You can log chats by amending the chat plugin, assuming you are using it, and if not, I suggest you install it.
Having done that click on the Edit button in the plugins window, scroll down to the OnPluginChatDisplay part, and amend as follows...
' OnPluginChatDisplay
' ------------------
'
' MUSHclient is about to display message: type, text
' Return TRUE to use the default display, FALSE to not display
'
' Note - the message type number, which groups types
' of messages, as follows:
'
' 0 Connection attempt
' 1 Session start, end
' 2 Name Change
' 3 Message
' 4 Incoming Personal
' 5 Incoming Everybody
' 6 Incoming Group
' 7 Outgoing Personal
' 8 Outgoing Everybody
' 9 Outgoing Group
' 10 Peek List
' 11 Connection List
' 12 Ping
' 13 Information
' 14 File
' 15 Snoop Data
' 16 Command
Function OnPluginChatDisplay (message, sText)
OnPluginChatDisplay = vbTrue ' display it
If message >= 3 And message <= 10 Then
if IsLogOpen Then
WriteLog StripANSI (sText)
End If
End If
End Function
The first "If" in the script there just suppresses some message (like snoop data) which you may not want to log.
Then it checks if a log file is open, and if so, strips the ANSI codes (colours) from the chat message, and logs it. You could, of course put a prefix on it if you wanted.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Rinor
(16 posts) Bio
|
| Date
| Reply #10 on Wed 25 Feb 2004 03:29 AM (UTC) |
| Message
| | I want to put the chat messages into a notepad file, not a log. Sorry for the confusion. | | Top |
|
| Posted by
| Jeffrey F. Pia
(49 posts) Bio
|
| Date
| Reply #11 on Wed 25 Feb 2004 03:34 AM (UTC) Amended on Wed 25 Feb 2004 03:39 AM (UTC) by Jeffrey F. Pia
|
| Message
| Okay, I couldn't get the Send to: Script to work write... probably something in the syntax of my script was off... but what I did get to work was Send to: World with an empty Send: box, sending the entire trig line to a script and using:
World.AppendToNotepad "Trigger: " & sTrigname, sVariable(10) + vbCrLf
That lets me append log files opened by my other triggers.
Now since my end goal was to update saved log files instead of open ones, I may as well use my script to do it. I plan on using this code:
world.openlog sPath & sLogName & ".txt", TRUE
World.writelog sVariable(10)
world.closelog
Do you think opening and closing log files w/ each channel trig will cause a lot of overhead? Or would it be better to just leave the log files open and use AppendToNotepad?
Thanks for being so helpful btw. This has been very educational for me. :-)
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #12 on Wed 25 Feb 2004 04:41 AM (UTC) |
| Message
|
Quote:
I want to put the chat messages into a notepad file, not a log. Sorry for the confusion.
Instead of WriteLog, do AppendToNotepad, like this:
AppendToNotepad "Chats log", StripANSI (sText)
Quote:
Okay, I couldn't get the Send to: Script to work write... probably something in the syntax of my script was off... but what I did get to work was Send to: World with an empty Send: box, sending the entire trig line to a script and using:
World.AppendToNotepad "Trigger: " & sTrigname, sVariable(10) + vbCrLf
It might help to say what you did. I don't see how that helps, as you still have the trigger name in the notepad window.
Sending this to script should work:
AppendToNotepad "My notepad name", "%0" & vbCrLf
As for closing and opening for every line, why do that? It is needlessly slow. The whole reason operating systems separate open and close from read and write is that the open and close are usually much slower.
Why not just leave the log file open and do a WriteLog whenever you need to?
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Jeffrey F. Pia
(49 posts) Bio
|
| Date
| Reply #13 on Wed 25 Feb 2004 05:56 AM (UTC) |
| Message
| | Yeah, sorry I don't really know what I did... I just tweaked it until I got it to work. As for keeping the log file open... I log each channel in a separate .txt file. How can I specify which log to write to with WriteLog? Or would I use AppendToNotepad for that...? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #14 on Wed 25 Feb 2004 08:48 PM (UTC) |
| Message
| I think the simple thing would be to AppendToNotepad - the log writing is intended for a single log file at once. Alternatively you could use the FileSystemObject object and have multiple output files open at one.
If you use AppendToNotepad you might set up a timer (say, every 5 minutes) to save the notepad(s) to disk, so you don't lose the lot. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | 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.
65,355 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top