Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[DIALOG] Scripting No Workee

2 views
Skip to first unread message

Walker

unread,
Mar 29, 2008, 1:55:11 PM3/29/08
to
I have had no luck in getting Dialog to use one of the author's perl
scripts to RemoveUserAgent. I copy and pasted the script into Dialog,
executed the script, got an OK with the following (I have Scripting
enabled):

Program RemoveUserAgent;
Begin
End.
if ((IsEmail=true) and (RemoveFromEmails=true)) or ((IsEmail=false) and
(RemoveFromNews=true)) then begin s:=Message.text; while
(Message.Strings[[i]]<>'') and (pos(RemoveHeader,Message.Strings[i])=0)
do begin i:=i+1; if pos(RemoveHeader,Message.Strings[[i]])<>0 then begin
delete(s,pos(RemoveHeader,s),length(Message.Strings[[i]])+2); end; end;
message.text:=s; end; end; function OnBeforeSendingMessage(var Message:
TStringlist; Servername: string; IsEmail: boolean):boolean; begin
RemoveAnyHeaderprogram OnBeforeSendingMessage; const // set the header
you want to remove here, e.g. 'User-Agent' RemoveHeader='User-Agent'; //
remove header from emails and/or postings // set 'true' or 'false'
RemoveFromEmails=true; RemoveFromNews=true; procedure
RemoveAnyHeader(Message:TStringlist;IsEmail:boolean); var i:integer;
s:string; begin if ((IsEmail=true) and (RemoveFromEmails=true)) or
((IsEmail=false) and (RemoveFromNews=true)) then begin s:=Message.text;
while (Message.Strings[[i]]<>'') and
(pos(RemoveHeader,Message.Strings[i])=0) do begin i:=i+1; if
pos(RemoveHeader,Message.Strings[[i]])<>0 then begin
delete(s,pos(RemoveHeader,s),length(Message.Strings[[i]])+2); end; end;
message.text:=s; end; end; function OnBeforeSendingMessage(var Message:
TStringlist; Servername: string; IsEmail: boolean):boolean; begin
RemoveAnyHeader(Message,IsEmail); result:=true; end; begin end.

Message has been deleted

Sourcerer

unread,
Mar 29, 2008, 10:51:48 PM3/29/08
to
On Sat, 29 Mar 2008 21:27:03 GMT, Sqwertz wrote:

> If this is the script I'm thinking of (I'm not going to try and read this
> pile of crap as posted), then I'm using it without any problems. Did you
> format it like that? I can't think of any way to cut and paste that script
> without some sort of manual (and convoluted) intervention.

It's possible that the script was saved to a file on a Unix system and
opened on Windows say in Notepad where \n characters were removed because
they were in the way (on Windows new line is displayed only if the whole
sequence \r\n is there, otherwise it's just like a normal character). The
only way I see for the tabs or spaces to go missing, however, is if the
code was then placed in a HTML file and then copied from the browser.

Beats me why all that would happen, but to me this explanation seems just
as plausible as that someone deliberately removed the newlines and
spaces/tabs manually.

--
"Let's see what's out there. Engage."
Jean Luc Picard, Star Trek: TNG, Encounter at Farpoint
http://pinpoint.wordpress.com/

Walker

unread,
Mar 30, 2008, 1:45:37 PM3/30/08
to
On Sat, 29 Mar 2008 21:27:03 GMT, Sqwertz wrote:

> If this is the script I'm thinking of (I'm not going to try and read this
> pile of crap as posted), then I'm using it without any problems. Did you
> format it like that?

wow, sorry about that, ! I copy and pasted from here:

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

I have done (I think) what you have said so let's see.

> I can't think of any way to cut and paste that script
> without some sort of manual (and convoluted) intervention.
>

> It should be put into the OnBeforeSendingMessage event script - compiled,
> saved, and reloaded (to be on the safe side).
>
> Trying using this code instead of whatever you have up there, unwrapping the
> 4 obvious lines so they all appear on a single line. You may also remove
> other headers using this script
>
> program OnBeforeSendingMessage;
>
> const
>
> // set the header(s) you want to remove, e.g. 'User-Agent: ,X-Scoring: '
>
> Remove_Headers = 'User-Agent: ';
>
> // remove header(s) from emails and/or postings


> // set 'true' or 'false'
>
> RemoveFromEmails = true;
> RemoveFromNews = true;
>

> 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;
>
> begin

> RemoveHeaders(Message,IsEmail);
> result:=true;
> end;
>
> // ----------------------------------------------------------------------
>
> begin
> end.

Walker

unread,
Mar 30, 2008, 1:46:58 PM3/30/08
to
Voila! Thanks, guys, for your time an patience.!

Walker

unread,
Mar 30, 2008, 1:47:32 PM3/30/08
to
On Sun, 30 Mar 2008 04:51:48 +0200, Sourcerer wrote:

> It's possible that the script was saved to a file on a Unix system and
> opened on Windows say in Notepad where \n characters were removed because
> they were in the way (on Windows new line is displayed only if the whole
> sequence \r\n is there, otherwise it's just like a normal character). The
> only way I see for the tabs or spaces to go missing, however, is if the
> code was then placed in a HTML file and then copied from the browser.
>
> Beats me why all that would happen, but to me this explanation seems just
> as plausible as that someone deliberately removed the newlines and
> spaces/tabs manually.

Naw, just saved by a dummy on Windoz, thx!

0 new messages