Thread View: news.software.readers
6 messages
6 total messages
Started by Walker
Sat, 29 Mar 2008 17:55
[DIALOG] Scripting No Workee
Author: Walker
Date: Sat, 29 Mar 2008 17:55
Date: Sat, 29 Mar 2008 17:55
29 lines
2931 bytes
2931 bytes
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.
Re: [DIALOG] Scripting No Workee
Author: Sqwertz
Date: Sat, 29 Mar 2008 21:27
Date: Sat, 29 Mar 2008 21:27
136 lines
6537 bytes
6537 bytes
Walker <takeawalk@yahoo.com> wrote:
> I have had no luck in getting Dialog to use one of the author's perl
> scripts to RemoveUserAgent.
This is not PERL, it's Delphi.
> 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.
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 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.
Re: [DIALOG] Scripting No Workee
Author: Sourcerer
Date: Sun, 30 Mar 2008 02:51
Date: Sun, 30 Mar 2008 02:51
22 lines
2319 bytes
2319 bytes
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/
Re: [DIALOG] Scripting No Workee
Author: Walker
Date: Sun, 30 Mar 2008 17:45
Date: Sun, 30 Mar 2008 17:45
108 lines
5050 bytes
5050 bytes
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.
Re: [DIALOG] Scripting No Workee
Author: Walker
Date: Sun, 30 Mar 2008 17:46
Date: Sun, 30 Mar 2008 17:46
1 lines
1463 bytes
1463 bytes
Voila! Thanks, guys, for your time an patience.!
Re: [DIALOG] Scripting No Workee
Author: Walker
Date: Sun, 30 Mar 2008 17:47
Date: Sun, 30 Mar 2008 17:47
14 lines
2077 bytes
2077 bytes
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!
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