🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #155267

Re: 40tude Dialog Beta 36 - script problem

#155267
From: Marcus Mönnig
Date: Tue, 07 Sep 2004 10:12
109 lines
4522 bytes
*Jo'Asia*, 7 Sep. 04, 11:53:

>> The script seems to work just fine. Check your filenames and that the
>> scripting engine is actually turned on in the main window.

Look at my headers.

I'm using the script below. Maybe you want to test it without any
modifications.

program OnBeforeSendingMessage;

function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
var i:integer;
    s, xcounter, file1, file2: string;
    sl:TStringlist;
begin
    result:=true;
    if (message.count<3000) then begin
        s:=message.text;
        i:=pos('signature-1',s);
        if i>0 then begin
            delete(s,i,length('signature-1'));        
            sl:=Tstringlist.create;
            try
                sl.loadfromfile('C:\file1.txt');
                insert(sl.text,s,i);
            finally
                sl.free;        
            end;
        end
        else begin
            i:=pos('signature-2',s);
            if i>0 then begin
                delete(s,i,length('signature-2'));        
                sl:=Tstringlist.create;
                try
                    sl.loadfromfile('C:\file2.txt');
                    insert(sl.text,s,i);
                finally
                    sl.free;        
                end;
            end
            else begin
                i:=pos('signature-3',s);
                if i>0 then begin
                    delete(s,i,length('signature-3'));        
                    sl:=Tstringlist.create;
                    try
                        sl.loadfromfile('C:\file3.txt');
                        insert(sl.text,s,i);
                    finally
                        sl.free;        
                    end;
                end;
            end;            
        end;
        message.text:=s;        
    end;

  file1:='C:\patch';
  file2:='C:\global-counter.txt';

  xcounter:='X-Count: ';

  //do not count emails
  if IsEmail then exit;
  //what group?      
  for i:=0 to Message.count-1 do
    if pos('Newsgroups: ',Message.strings[i]) > 0 then
      break;
  if i=Message.count-1 then exit;
  file1:=file1 + Copy(Message.strings[i],length('Newsgroups:')+1,length(Message.strings[i])) + '.txt';
  sl := TStringList.Create;
  try
    if FileExists(file1) then
      sl.LoadFromFile(file1)
    else
      sl.text:='0';

    sl.strings[0] := IntToStr (StrToInt(sl.strings[0]) + 1);
    xcounter:=xcounter + sl.strings[0];

    sl.SaveToFile(file1);

    if FileExists(file2) then
      sl.LoadFromFile(file2)
    else
      sl.text:='0';

    sl.strings[0] := IntToStr (StrToInt(sl.strings[0]) + 1);
    xcounter:=xcounter + '/' + sl.strings[0];

    sl.SaveToFile(file2);

    for i:=0 to Message.count-1 do
      if Message.strings[i] = '' then
        begin
          Message.Insert(i,xcounter);
	  break;
        end;
  finally
    sl.free;        
  end;

end;

begin
end.
Technical Details
Message-ID: <chk1j8$n6c$02$1@news.t-online.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!feed.news.tiscali.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail
References: <13jszx3om13qk.xfuvmn9gv3fd$.dlg@40tude.net> <14pjpd404uy16$.dlg@dustpuppy.sloth.hell.pl> <chfp8s$3qd$07$1@news.t-online.com> <1ip9ndnlp55qh$.dlg@dustpuppy.sloth.hell.pl> <chjv5j$uki$05$1@news.t-online.com> <1a67ze0xq3doq.dlg@dustpuppy.sloth.hell.pl>

Show Full Headers
Complete Article Headers
Message-ID: <chk1j8$n6c$02$1@news.t-online.com>
Subject: Re: 40tude Dialog Beta 36 - script problem
Date: Tue, 7 Sep 2004 12:12:05 +0200
From: Marcus Mönnig <usenet-sep04@40tude.com>
References: <13jszx3om13qk.xfuvmn9gv3fd$.dlg@40tude.net> <14pjpd404uy16$.dlg@dustpuppy.sloth.hell.pl> <chfp8s$3qd$07$1@news.t-online.com> <1ip9ndnlp55qh$.dlg@dustpuppy.sloth.hell.pl> <chjv5j$uki$05$1@news.t-online.com> <1a67ze0xq3doq.dlg@dustpuppy.sloth.hell.pl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!number1.nntp.dca.giganews.com!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!newsfeed.freenet.de!feed.news.tiscali.de!newsfeed01.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail
Newsgroups: news.software.readers
Organization: T-Online
Lines: 109
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
X-Trace: news.t-online.com 1094551977 02 23756 Y5bdXGOLog0mek0 040907 10:12:57
X-Complaints-To: usenet-abuse@t-online.de
X-ID: ZY6YNqZ68enJKQ7m-AEuD-nbtUjANzcT5QUpe1XU1WrnWeIZ42518-
User-Agent: 40tude_Dialog/2.0.13.2de (91c5d813.268.159)
X-Face: .k.-$2:"SOnv`$+._5GWLVbo=\AYg!R'T#G[$P`Chd0T$NtF2}68aF}1gRDrxTQi']7Ldza
 n{+d:rTHS*nc<xt?o:zVx>3P$=`rx}:o1!BA'OmJn(lR=Y%mG{*T#D-B02=:Dh0138$V