🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: news.software.readers
3 messages
3 total messages Started by Jackson Wallace Thu, 30 Jun 2005 20:49
[Dialog] Combine two scripts for the same event
#168395
Author: Jackson Wallace
Date: Thu, 30 Jun 2005 20:49
8 lines
1439 bytes
I've been trying, without much success, to combine the following two
scripts:

http://www.40tude.com/dialog/wiki/index.php/ScriptDateTimeInsert
http://www.40tude.com/dialog/wiki/index.php/RemoveHeaders

Depending on where I put one script the other doesn't work.  Is it possible
to combine these two?
Re: [Dialog] Combine two scripts for the same event
#168433
Author: Korbinian Abenthum
Date: Fri, 01 Jul 2005 14:16
125 lines
5254 bytes
Jackson Wallace wrote:

> http://www.40tude.com/dialog/wiki/index.php/ScriptDateTimeInsert
> http://www.40tude.com/dialog/wiki/index.php/RemoveHeaders 
> 
> Is it possible to combine these two?

Yes, you have to merge them. It is relatively easy in your case, but since
it's still easier for me to do it than to explain it, I attached it below.

untested & HTH

program OnBeforeSendingMessage;

//
// Date: 2004/11/16
//

    const
//  ----------------------------------------------------
//  Configuration settings
//  ----------------------------------------------------

    // set the header(s) you want to remove here, e.g. 'User-Agent: ,X-Scoring: '
    
    Remove_Headers = 'X-Scoring: ,X-Hamster-Info: ';

    // remove header(s) from emails and/or postings
    // set 'true' or 'false'
    
    RemoveFromEmails = true;
    RemoveFromNews   = true;

   
//  ----------------------------------------------------
//  End of configuration settings
//  ---------------------------------------------------- 


   // --------------------------------------------------------------- //
   // ----  No user maintainable parts below this line -------------- //
   // --------------------------------------------------------------- //


procedure RemoveHeaders ( Message : TStringlist; 
                          IsEmail : boolean 
);

var i                : integer;
    k                : integer;
    s                : string;
    CommaPos         : integer;
    DelHeader        : TStringlist;
    RemoveH          : String;
    
begin
   RemoveH := Remove_Headers;
   i := 0;
   if ((IsEmail=true)  and (RemoveFromEmails=true)) or
      ((IsEmail=false) and (RemoveFromNews=true)) then begin
      If ( RemoveH <> '' ) then begin
      try 
         DelHeader := TStringlist.Create;
         if ansipos ( ',', RemoveH) = 0 then begin
            DelHeader.Add ( LowerCase ( TrimLeft( RemoveH )));
         end // if
         else begin
            CommaPos := 0;   
            for k := 1 to length ( RemoveH ) do begin
               If RemoveH[k] = ',' then begin
                  DelHeader.Add ( LowerCase ( TrimLeft (copy ( RemoveH, CommaPos + 1, k - ( CommaPos + 1 )))));
                  CommaPos := k;
               end; // if
               if k = length ( RemoveH ) then
                  DelHeader.Add ( LowerCase ( TrimLeft (copy ( RemoveH, CommaPos + 1, k - CommaPos ))));                   
            end; // for  
         end; // else  
         s:=Message.text;
         while (Message.Strings[i]<>'') do begin
            k := 0;
            while k <= ( DelHeader.Count - 1 ) do begin 
               if pos( DelHeader[k], LowerCase ( Message.Strings[i] )) = 1 then begin
                  delete ( s, pos(DelHeader[k], LowerCase (s) ), length ( Message.Strings[i] ) + 2 );
                  i := i - 1;
                  k := DelHeader.Count - 1;
                  message.text := s;
               end; // if 
               k := k + 1;
            end; // while   
            i := i + 1;
         end; //while
         message.text:=s;
      finally
      DelHeader.Free;
      end; // try - finally 
      end; // if  
   end; // if
end; // RemoveHeaders


function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
var s:string;
    i,j:integer;
begin
  RemoveHeaders(Message,IsEmail);
  result:=true;
  
  //check the last 4 lines for %datetime% and replace it with the current date time
  for i:=message.count-4 to message.count-1 do
  begin
   if (i<0) then continue;
   s:=message.strings[i];
   j:=pos('%datetime%',s);
   if j>0 then
   	begin
	delete(s,j,length('%datetime%'));
	insert(datetimetostr(now),s,j);
   	message.strings[i]:=s;
   	break;
   	end;
   end;
end;

begin
end.
Re: [Dialog] Combine two scripts for the same event
#168434
Author: Jackson Wallace
Date: Fri, 01 Jul 2005 14:23
13 lines
1729 bytes
On Fri, 1 Jul 2005 16:16:54 +0200, Korbinian Abenthum wrote:

> Jackson Wallace wrote:
> 
>> http://www.40tude.com/dialog/wiki/index.php/ScriptDateTimeInsert
>> http://www.40tude.com/dialog/wiki/index.php/RemoveHeaders 
>> 
>> Is it possible to combine these two?
> 
> Yes, you have to merge them. It is relatively easy in your case, but since
> it's still easier for me to do it than to explain it, I attached it below.

Thank you very much for your help, it is really appreciated!
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads