 |
The Bat! Macro and Solutions Library |
 |
Back to
The Bat! FAQ /
How-Do-I
Clean Subject [
Reply template] |
Tidy up wayward subjects for replies
|
%REM=_
I don't remember who originally wrote this one but it's worth presenting here
_%-
%setpattregexp='(?i)\A\:?(\s*\[.*\])%-
?(\s*(aw|antw|antwort|betrifft|fw|fwd|forw|ha|rcpt|re|wg|wtr)%-
([\(\[]\d*[\)\]])?:\s*)*(.*?)%-
(\s?(\(PGP|S/MIME) Decrypted\)%-
|(\s?\(was:.*\))%-
)?$'%-
%RegExpBlindMatch(%OFullSubj)%-
%subject="Re: %SubPatt(5)"
And here's a v2 re-write, courtesy of Daniel Hahler
%_______%REM="clean subject - by daniel hahler"%________%-
%_oldSubj=%OSubj%-
%Subject="%-
%SetPattRegExp='(?ix)\A:?
( [([]+ .*? [)\]]+ )*\s* # save topic/listname
(?:
(?:
(?:aw|antw|antwort|betrifft|fw|fwd|forw|
forward|ha|rcpt|re\^?\d*|sv|vs|wg|wtr)(?:\[\d*\])?:
)
|\s+
)*
(.*?) # the subject
\s*
(
([(\[]+
( (wa[rs][:; ] | pgp | s/mime ).*
| fwd
)
[)\]]*\s*
)*
)\z'%-
%RegExpBlindMatch='%OSubj'%-
%IF:#%SubPatt='1'#<>##:#%SubPatt='1' #%-
Re: %SubPatt='2'"%-
%___________________________________
GMT offset [
Reply template] |
Find local computer's offset from GMT
|
Here's the Version 1 QTs - Version 2 QTs follow below:
=====[Begin TZOffset QT]=====
%Comment=`%Calc=~%-
%-
%REM=" Extract Hour and GMT offset "%-
%-
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{0,2})\:(\d{0,2})\:\d{0,2}\s.*?([-+])(\d{2})(\d{2})"%-
%REGEXPBLINDMATCH="%HEADERS"%-
%-
%REM=" Local hour - GMT hour (converted to minutes) "%-
%-
((%OTIME="hh" - (%SUBPATT="1" - (%SUBPATT="3"%SUBPATT="4")))*60 + %-
%-
%REM=" Local Minute - GMT minute "%-
%-
( %OTime="nn" - (%SUBPATT="2" - (%SUBPATT="3"%SUBPATT="5"))) + %-
%-
%REM=" Correct for straddling days in the different zones "%-
%-
%If:"%QInclude=_DateDiff_"="-6":"1":"%-
%If:'%QInclude=_DateDiff_'='6':'-1':'%-
%QInclude=_DateDiff_'" * (-24)*60)%-
%-
%REM=" Convert back to hhmm format "%-
%-
/60 * 100~`%-
%-
%REM=" Add lead + sign if necessary "%-
%-
%Comment="%-
%-%-%SetPattRegExp='^.*?([-+]\d*)$'%-
%-%-%RegExpMatch='+%Comment'"%-
%-
%REM=" Convert to standard notation for half hour timezones "%-
%If:"%-
%-%-%SetPattRegExp='(\d\d)$'%-
%-%-%RegExpMatch='%Comment'"="50":"%-
%-
%-%-%SetPattRegExp='^(.*)\d\d$'%-
%-%-%RegExpMatch='%Comment'%-
%-%-30":"%Comment"%-
%-
%Comment=''%-
=====[ End TZOffset QT]=====
=====[Begin DateDiff QT]=====
%CALC=_%-
%-
%-%-%Comment="%-
%-%-
%-%-%-%-%SetPattRegExp='(?im-s)^Date:.*(Sun|Mon|Tue|Wed|Thu|Fri|Sat)'%-
%-%-%-%-%RegExpMatch='%Headers'"%-
%-%-
%-%-%QInclude="DOW-Num" - %-
%-%-
%-%-%Comment="%ODate='ddd'"%-
%-%-
%-%-%QInclude="DOW-Num"_%-
%-
%Comment=""%-
=====[ End DateDiff QT]=====
=====[Begin DOW-Num QT]=====
%IF:"%Comment"="Sun":"1"%-
%IF:"%Comment"="Mon":"2"%-
%IF:"%Comment"="Tue":"3"%-
%IF:"%Comment"="Wed":"4"%-
%IF:"%Comment"="Thu":"5"%-
%IF:"%Comment"="Fri":"6"%-
%IF:"%Comment"="Sat":"7"%-
=====[ End DOW-Num QT]=====
**** Version 2 adaptation:
=====[Begin TZOffset QT]=====
%_Comment=`%Calc=~%-
%-
%REM=" Extract Hour and GMT offset "%-
%-
%SETPATTREGEXP="(?im-s)^Date\:.*?\s(\d{0,2})\:(\d{0,2})\:\d{0,2}\s.*?([-+])(\d{2})(\d{2})"%-
%REGEXPBLINDMATCH="%HEADERS"%-
%-
%REM=" Local hour - GMT hour (converted to minutes) "%-
%-
((%OTIME="hh" - (%SUBPATT="1" - (%SUBPATT="3"%SUBPATT="4")))*60 + %-
%-
%REM=" Local Minute - GMT minute "%-
%-
( %OTime="nn" - (%SUBPATT="2" - (%SUBPATT="3"%SUBPATT="5"))) + %-
%-
%REM=" Correct for straddling days in the different zones "%-
%-
%If:"%QInclude=_DateDiff_"="-6":"1":"%-
%If:'%QInclude=_DateDiff_'='6':'-1':'%-
%QInclude=_DateDiff_'" * (-24)*60)%-
%-
%REM=" Convert back to hhmm format "%-
%-
/60 * 100~`%-
%-
%REM=" Add lead + sign if necessary "%-
%-
%_Comment="%-
%-%-%SetPattRegExp='^.*?([-+]\d*)$'%-
%-%-%RegExpMatch='+%_Comment'"%-
%-
%REM=" Convert to standard notation for half hour timezones "%-
%If:"%-
%-%-%SetPattRegExp='(\d\d)$'%-
%-%-%RegExpMatch='%_Comment'"="50":"%-
%-
%-%-%SetPattRegExp='^(.*)\d\d$'%-
%-%-%RegExpMatch='%_Comment'%-
%-%-30":"%_Comment"%-
%-
%_Comment=''%-
=====[ End TZOffset QT]=====
=====[Begin DateDiff QT]=====
%CALC=_%-
%-
%-%-%_Comment="%-
%-%-
%-%-%-%-%SetPattRegExp='(?im-s)^Date:.*(Sun|Mon|Tue|Wed|Thu|Fri|Sat)'%-
%-%-%-%-%RegExpMatch='%Headers'"%-
%-%-
%-%-%QInclude="DOW-Num" - %-
%-%-
%-%-%_Comment="%ODate='ddd'"%-
%-%-
%-%-%QInclude="DOW-Num"_%-
%-
%_Comment=""%-
=====[ End DateDiff QT]=====
=====[Begin DOW-Num QT]=====
%IF:"%_Comment"="Sun":"1"%-
%IF:"%_Comment"="Mon":"2"%-
%IF:"%_Comment"="Tue":"3"%-
%IF:"%_Comment"="Wed":"4"%-
%IF:"%_Comment"="Thu":"5"%-
%IF:"%_Comment"="Fri":"6"%-
%IF:"%_Comment"="Sat":"7"%-
=====[ End DOW-Num QT]=====
Initials [
Reply template] |
Generate Initials more intelligently than TB's internal implementation
|
=====[Initials]=====
%SETPATTREGEXP="(?is)(\w).*?([-_=@\.\s]+(\w).*?)?([-_=@\.\s]+(\w).*?)?$"%-
%REGEXPBLINDMATCH="%QINCLUDE=""Full Name"""%-
%SUBPATT="1"%SUBPATT="3"%SUBPATT="5"%-
=====[ End QT ]======
=====[Full Name]=====
%CAPITAL='%ABofromNAME="%-
%QINCLUDE=_Full Name - No AB Entry_"'
=====[ End QT ]=====
=====[Full Name - No AB Entry]=====
%SETPATTREGEXP="^(?(?=.*?\@)(.*?)\@|(.*)$)"%-
%REGEXPBLINDMATCH="%OFROMNAME"%-
%SUBPATT="1"%SUBPATT="2"%-
=====[cEnd QT ]=====
Language Selection [
Reply template] |
Choose the language template automatically
|
First you have to create two templates, one for english and one for another
language. In my example i created a template for german (Handle=GReply) and
for english (Handle=EReply).
Now insert the following into your standard reply template:
%IF:"%REGEXPTEXT='(?ims)\A.{0,150} (the) '"="the":"%QINCLUDE='EReply'":"%-
%IF:_%REGEXPTEXT='(?ims)\A.{0,150} (is) '_=_is_:_%QINCLUDE='EReply'_:_%-
%IF:&%REGEXPTEXT='(?ims)\A.{0,150} (this) '&=&this&:&%QINCLUDE='EReply'&:&%-
%IF:+%REGEXPTEXT='(?ims)\A.{0,150} (or) '+=+or+:+%QINCLUDE='EReply'+:+%-
%IF:*%REGEXPTEXT='(?ims)\A.{0,150} (a) '*=*a*:*%QINCLUDE='EReply'*:*%-
%IF:#%REGEXPTEXT='(?ims)\A.{0,150} (i) '#=#i#:#%QINCLUDE='EReply'#:#%-
%QINCLUDE='GReply'#*+&_"
If you want to add more strings, copy one of the IF lines and be sure that
you use another delimiter which was not used before! Then add this delimiter
to the last line too!!!
This template scans only the first 150 chars + the length of the searchstring
for english words. This happens because sometimes people use signatures of a
different language at the end of the mail.
Achim
Local timezone [
Reply template] |
Show the sender's time in his zone and mine
|
On%SETPATTREGEXP="(?m-s)Date\:\s*?((.*?[\d]{4})\s*?%-
([\d]%-{0,2}\:[\d]{0,2})\s*?(.*))"%-
%REGEXPMATCH="%HEADERS" GMT%-
(%ODateShort, %OTime +0700 GMT), %OFROMNAME wrote:
(you need to adjust +0700 GMT to your own timezone)
Outlook L&F [
Reply template] |
Emulate Outlook Reply look & feel.
|
This template gives a tidy alternative to the default reply template.
- If To: or Cc: were blank on the original mail then these are suppressed
- Sent date preserves the sender's date format and timezone because I find
this more intuitive for the person to whom you are replying
- Also preserves timezone of original mail.
- Only tested with TheBat! v2.04.7
When pasting this template, please ensure there are no line breaks on lines
ending with the character %
Other line breaks are intentional.
--- 8< -------------------------------------
%Cursor
-----Original Message-----
From: %OFromName <%OFromAddr>
Sent%-
%VARdate='%SetPattRegExp="^Date:.*?$"%RegExpMatch=%HEADERS'%-
%SetPattRegExp=":.*$"%RegExpMatch="%VARdate"
%SetPattRegExp="^To:.*?$"%IF:"%RegExpMatch=%HEADERS"<>"":"To: %OToList
":""%-
%SetPattRegExp="^Cc:.*?$"%IF:"%RegExpMatch=%HEADERS"<>"":"Cc: %OCcList
":""%-
Subject: %OSubj
%Quotes
--- 8< -------------------------------------
Example:
-----Original Message-----
From: Fred Flintstone <fredf@bedrock.com>
Sent: Tue, 2 Mar 2004 02:24:33 -0800
To: "Barney Rubble" <barneyr@bedrock.com>
Subject: Yabba dabba doo!
.
.
.
Quote Extraction [
Reply template] |
Create quotes minus ads, PGP sigs, etc.
|
%QUOTES='%SETPATTREGEXP="(?is)%-
((\s*)?\n?-----BEGIN PGP SIGNED.*?\n(Hash:.*?\n)?\s*)?%-
(\s*(Dear|Hi|Hello|Hey|Greetings|Howdy) \S*?\s*\n+)?%-
(-+[\S ]+\n)?%-
(.*?)(^(%-
- -*?\s*?--\s*\n|%-
_{40,}\s*\n|%-
-{40,}\s*\n|%-
\n-----BEGIN PGP SIGNATURE.*s?\n|%-
--+\s+.*roups.*~--\>)|%-
\n\nYour use of|%-
\n+Get your FREE download|%-
\nNote that the email address of the sender has been changed|%-
\n---\nOutgoing mail is certified Virus Free.|%-
\z)"%REGEXPBLINDMATCH="%text"%SUBPATT="7"'
ReWrap [
Reply template] |
Recursively wrap quoted reply text
|
You have to create the following quick templates (handles are in
[brackets]). Because it uses the %COMMENT macro, it has a TB V2 variant
(listed below):
=====[ Begin wq ]=====
%COMMENT="%QUOTES"%-
%QINCLUDE="wrap2"
%COMMENT=""
=====[ End wq ]=====
=====[ Begin wrap2 ]=====
%IF:'%-
%SETPATTREGEXP="(?is-m)[^\n]+"%-
%REGEXPMATCH="%COMMENT"'<>'':'%-
%-
%WRAPPED=_%SETPATTREGEXP="(?is-m)^(.*?)(\n(((\w{0,5}(\>\s*)+)?\s*\n))+(.*)\s*$|\z)"%-
%-%-%-%-%-%REGEXPBLINDMATCH="%COMMENT"%-
%-%-%-%-%-%SUBPATT="1"_
%COMMENT=_%SETPATTREGEXP="(?is-m)^(.*?)(\n(((\w{0,5}(\>\s*)+)?\s*\n))+(.*)\s*$|\z)"%-
%-%-%-%-%-%REGEXPBLINDMATCH="%COMMENT"%-
%-%-%-%-%-%SUBPATT="7"_%-
%QINCLUDE="wrap2"'
=====[ End wrap2 ]=====
Replace the %QUOTES macro in your reply template with
%QINCLUDE="wq". That should do it.
Do what?
Well, this macro will take the text from the message to which you wish to
reply and paste it into the reply as quotes, one line at a time and wrapping
each line as it goes. This avoids the problem of having too long lines in
your quotes.
For example ... before:
This is the text I want to reply to and as you can see it's all in one long
line of text.
... and after:
> This is the text I want to reply to and as you can
> see it's all in one long line of text.
-=-=-=-=-=-=-= All New Wrap for v2 -=-=-=-=-=-=-
The multi-paragraph wrapping template is a general purpose template that
can be used on it's own, or in conjunction with other templates.
To wrap and insert text from the clipboard, simply copy your text to the
clipboard, type "wrap" (no quotes) followed by <ctrl><space> in the editor.
When called from a template, the calling template should put the text to be
wrapped in %_Wrap_Text before the wrap template is called. There is also an
optional wrap length parameter, %_Wrap_Limit if a certain column length is
desired. The following is an example driver template that will wrap quoted
text to 50 characters.
=====[Begin example driver]=====
%_Wrap_Text="%Quotes"%-
%Rem="This line is optional"%___%_Wrap_Limit="50"%-
%QInclude(wrap)%-
=====[ End example driver]=====
=====[Begin wrap template]=====
%REM='
Multi-Paragraph wrapping routine using features from TB v2
Written June 2003 by Januk Aggarwal
Notes:
1. This template can be used alone to wrap clipboard
contents or can be used as a wrapping engine by assigning
text to the variable, %_Wrap_Text, in the driver template.
2. Wrapping limit can be set optionally by defining the
variable %_Wrap_Limit in the driver template
'%-
%-
%IF:'%_Wrap_FirstTime'='':'%-
%___%IF:"%_Wrap_Text"="":"%_Wrap_Text(%Clipboard)"%-
%___%_Wrap_FirstTime="No"'%-
%-
%IF:'%-
%SetPattRegexp="(?is-m)[^\n]+"%-
%RegexpMatch(%_Wrap_Text)'<>'':'%-
%-
%SetPattRegexp="(?is-m)^(.*?)((\n((\w{0,5}(\>\s*)+)?\s*\n)+)(.*)\s*$|\z)"%-
%RegexpBlindMatch(%_Wrap_Text)%-
%-
%_Wrap_Paragraph_1(%Subpatt(1))%-
%_Wrap_Blank_Space(%Subpatt(3))%-
%_Wrap_Remainder_Of_Text(%Subpatt(7))%-
%-
%If:"%_Wrap_Limit"="":"%-
%____%Wrapped(%_Wrap_Paragraph_1)":"%-
%____%Wrapped(%_Wrap_Limit, %_Wrap_Paragraph_1)"
%_Wrap_Text(%_Wrap_Remainder_of_Text)%-
%-
%QInclude(wrap)'%-
=====[ End wrap template]=====
WebBoard Mail List [
Reply template] |
Format and clean up messages destined for a WebBoard mail list
|
TB_WB_RT - Date: 04-26-2004
~~~~~~~~
The Bat! 2.xx.xx reply template for use with WebBoard mail lists.
What it does:
~~~~~~~~~~~~
WebBoard allows (sysop discretion) email subscriptions to its topics
to facilitate a somewhat crude mail list functionality.
Unlike 'real' list servers there is some kinks which can make email
use cumbersome. The template below basically cleans up formats a reply
that is better suited for the WebBoard.
Line 4: strips off RE: from the subject
Lines 5-7: store complete sender info from body to TMP1
Lines 8-10: store quoted sender name from body to TMP2
Line 11: store friendly name to FM
Line 12: perform only basic quote prefixing
Lines 13-14: generate quote author/time stamp
Lines 15-17: WebBoard footer/attachments to remove
Line 19: strip matches of 15-17 from quote text
I've been using this with a WebBoard 6.1 and so far the template does
all that I needed. This may not be suitable for other versions of
WebBoard.
How I use this:
~~~~~~~~~~~~~~
I've a common folder which has all the incoming WebBoard traffic
sorted into. Further sorting, topic/list name I am doing with virtual
(children of the common folder) folders.
The common folder 'template' is %blank and the reply template is as
listed below.
New messages to the WebBoard list(s) are handled with address book
templates.
The WebBoard requirement, AFAIK, is simply that the REPLY-TO address be
matching the address that is part of the WebBoard account profile.
The first 3 lines obviously should reflect your own account and email
address.
------------------8<--------------------
%ACCOUNT=[xxx]%-
%FROM="xxx <xxx@xxx.xxx>"%-
%REPLYTO="xxx <xxx@xxx.xxx>"%-
%SUBJECT="%SUBJECT"%-
%SETPATTREGEXP="((^From:\s)(.*?)(\n))"%-
%REGEXPBLINDMATCH="%TEXT"%-
%VARTMP1=%SUBPATT="3"%-
%SETPATTREGEXP='(^From:\s"(.*?)")'%-
%REGEXPBLINDMATCH="%TEXT"%-
%VARTMP2=%SUBPATT="2"%-
%IF:%VARTMP2<>"":%VARFM="%VARTMP2":%VARFM="%VARTMP1"%-
%QUOTESTYLE="NONE"%-
On%SETPATTREGEXP="(?m-s)Date\:\s*?((.*?[\d]{4})\s*?([\d]{0,2}\:[\d]{0,2})\s*?(.*))"%-
%REGEXPMATCH=[%HEADERS] GMT, %VARFM wrote:
%VAR_FM="From:\s.*?\n"%-
%VAR_AT="--\nAttachment:\n.*\n"%-
%VAR_FT="To\sreply:\s.*\n"%-
%CURSOR%-
%QUOTES='%SETPATTREGEXP="(?is)(^(%VAR_FM))?(.*?)(^(%VAR_AT|%VAR_FT))"%-
%REGEXPBLINDMATCH="%TEXT"%SUBPATT="3"'%-
--
%FromName
------------------8<--------------------
I welcome any comments or improvements on the template. If I get any
knowledge of WebBoard 7.x and the template needs changes I'll try to
remember to update this here. In any event I'll add any improvements
to my site:
The Starving Hedonist
Yahoogroups Digest macro [
Reply template] |
Replace the "Re: Digest number xxxx" in the subject with the original subject of the individual email
|
copy and paste the macro.
when replying, highlight parts of the email from the word "From:" until the
end of the email that you want to quote. the macro will automatically
replace the standard subject ("Re: Digest Number xxxx") with the original
subject from the individual email and also tidy up the subject a little bit.
Feel free to modify this code :)
%subject="Re: %setpattregexp='Subject:(\s*(re|ha|rcpt|fwd|fw)\s?%-
(\[\d*\])?:\s*)*(.*?)\n(.*)'%-
%RegExpBlindMatch='%Quotes'%SubPatt='4'"
%setpattregexp="(\[.*\])\s(.*)"%-
%RegExpBlindMatch="%OSubj"%-
==== Information from %SubPatt="2" ====
%setpattregexp="(\s)?From:\s\W?(.*?)\W?\s(<.*?>)\n%-
(.*)Subject:(.*?)\n(.*)"%-
%RegExpBlindMatch="%Quotes"%-
Once upon a time, %SubPatt="2" wrote:
%SubPatt="6"
Copyright © 1996 - 2004 Marck D. Pearlstone
Last Updated 15th-October-2009