CondenseQuoteChars
From 40tude Dialog Wiki
Condense quote characters
This is a OnBeforeSendingMessage event script. Its purpose is to condense (format) misformatted quote characters.
Example
A quoting block like the following
| >: | > text | >: | more text | >: other text
will become
|>:|> text |>:| more text |>: other text
in your message.
Tested successfully on 2.0.10.1
program OnBeforeSendingMessage;
const
// set the expected quote chars here
QuoteChars='>|:';
procedure CondenseQuotes(Message:TStringlist;IsEmail:boolean);
var i,j,k,l:integer;
Quote,Content:widestring;
isQuote,Done:boolean;
begin
// determine beginning of body
while Message.Strings[i]<>'' do i:=i+1;
// check body line by line
while i<=Message.Count do
begin
i:=i+1;
Done:=false;
Content:=Message.Strings[i];
Quote:='';
// do only for quoted lines
for j:=1 to length(QuoteChars) do
begin
if pos(copy(QuoteChars,j,1),copy(Message.Strings[i],1,2))<>0 then
begin
// char by char: we check the first 20 chars per line only (performance)
for k:=1 to 20 do
begin
if Done then break;
if pos(' ',copy(Message.Strings[i],k,1))<>0 then
Content:=copy(Message.Strings[i],k+1,length(Message.Strings[i])-k+1)
else
begin
isQuote:=false;
// check for all configured QuoteChars
for l:=1 to length(QuoteChars) do
begin
if isQuote then break;
if pos(copy(QuoteChars,l,1),copy(Message.Strings[i],k,1))<>0 then
begin
isQuote:=true;
Quote:=Quote+copy(QuoteChars,l,1);
end;
end;
// if it's not a QuoteChar, then we are done
if not isQuote then
begin
Content:=copy(Message.Strings[i],k,length(Message.Strings[i])-k+1);
Done:=true;
break;
end;
end;
end;
end;
end;
// replace the old line
if Quote<>'' then
if Content='' then
Message.Strings[i]:=Quote
else
Message.Strings[i]:=Quote+' '+Content;
end;
end;
function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
begin
CondenseQuotes(Message,IsEmail);
result:=true;
end;
begin
end.
Script by anchedo (Andreas Loch)