I wanted to change how my blog comment notifications looked. Since I only have one blog, I don't need the first part to tell me which blog the comment is from. I also wanted to do whois lookups on the ipaddresses so I can get more info about the people who are commenting on my site.
Here's what the original email looks like:
Subj: [PromoGuy dot Net] New Comment Posted to '7 x 14 + 2 = 100 Things
Aboot Me'
—————————————————————-
A new comment has been posted on your blog PromoGuy dot Net, on entry #1489
(7 x 14 + 2 = 100 Things Aboot Me).
http://www.promoguy.net/archives/001489.php
IP Address: 123.45.678.90
Name: Lisa
Email Address: SomeMail@SomeDomain.net
URL: http://www.snarkypants.com
Comments:
Hey! Where's the rest?? You promised! Slackerboy!
—
After my modifications, my Comment Notifications look like this:
Subj: [7 x 14 + 2 = 100 Things Aboot Me] by "Lisa" – PromoGuy dot Net
—————————————————————-
"Lisa" left a new comment in your blog PromoGuy dot Net, on entry #1489 (7 x
14 + 2 = 100 Things Aboot Me).
http://www.promoguy.net/archives/001489.php
IP Address: 123.45.678.90
IP Info: http://www.samspade.org/t/lookat?a=123.45.678.90
Name: Lisa
Email Address: SomeMail@SomeDomain.net
URL: http://www.snarkypants.com
Comments:
Hey! Where's the rest?? You promised! Slackerboy!
—
My changes reflect my preferences, yours may be different.
1. I don't need to see "New Comment Posted to" in my subject line. It takes
up too much space, and my web mail program won't show full subject lines, so I
need the important stuff first. Besides, by looking at the Brackets I recognize
that it is a comment notification.
2. I want to know which post got the comment, so I put that first. I don't
need to know which blog it is from, because I only have one – so I moved that
part to the end. Plus, I wanted to know Who sent the comment.
3. On heavy comment days, my inbox is nearly bursting. Now when I see a
comments is posted by a certain person, I can go to read that one first.
The only major change in the Body was making the IP Address into a clickable
link to do a WHOIS and TRACEROUTE on SamSpade.com. I added a new line for that.
I also slightly changed the wording on the first sentence.
Here is what I did. Again, once you see the changes I made, you will probably
want to customize it the way you want it to look. Please note: This code was
tested and executed on MoveableType 2.64. I don't know if it will work on
lower versions, so YMMV.
Disclaimer: Do this at your own risk. It should go fine, but you never
know. I won't be responsible for fixing it if you go and screw it up.
First, FTP or otherwise navigate to your MT installation directory and find:
/lib/MT/App/
Now, make a backup copy of Comments.pm (always make backups, yo).
Open up Comments.pm in your favorite text editor (I use
araneae; for simple jobs
like this).
Go to Line 132 or search for "$author->email" (without the quotes) and you
will be close.
Be sure you are on the line that says "Subject =>" and we are ready to get
jiggy!
Highlight and delete:
Subject => '[' . $blog->name . '] ' . $app->translate('New Comment Posted to \'[_1]\", $entry->title));
Replace it with:
Subject => '[' . $entry->title . '] ' . $app->translate('new comment by "[_1]" – [_2]', $comment->author, $blog->name)
);
Now if you want to Tweak the Body of the message, scroll down to about Line
146.
I edited the body of the text to lead with the Comment Author's name. So
change this:
my $body = $app->translate('A new comment has been posted on your blog [_1], on entry #[_2] ([_3]).', $blog->name, $entry->id, $entry->title);
To this:
my $body = $app->translate('"[_1]" left a new comment in your blog [_2], on entry #[_3] ([_4]).', $comment->author, $blog->name, $entry->id, $entry->title,);
If you want to investigate their IP address, put your cursor right under
$app->translate('IP Address:') . ' ' . $comment->ip . "\n" .
and hit enter, making a blank line.
Now copy and paste this:
$app->translate('IP Info: http://www.samspade.org/t/lookat?a=[_1]', $comment->ip) . "\n" .
Save the file, making sure it has the .pm extension. Save it back to the same
directory, overwriting the current Comments.pm. (because you already have a
backup, right?).
Now go leave yourself a comment. See how much more meaningful those Comment
Notifications are?