CopyIf ====== author: Thomas's G. Liesner status: 12,10,2000. V1.05, however quite gaps possible... a prerequisite: Installed hamster structure of the " CopyIf.ini " ======================= [ Settings ] If the Message IDs is to be modified with umkopierten messages, here la define an appropriate supplement$NotOriginal$$$$. A, among other things the CROSS poster identifier of agent undermines, if these after Message ID looks up, can remain otherwise empty. Otherwise must with responses on this changed message Korrnews to be used, around the References back in order to bring AddToMessageID = Permits testing the functions without genuine modifications 1 = tests, 0 = emergency TestOnly=1 Restriction, how many Postings are to be tested, 0 for all: - concerning new groups of NewGroups_TestMax=100 - concerning already at least once groups searched TestMaxPostings=0 Which groups not to be searched are - ask as RegExp printout indicate, for several exclusions by commas separate. IgnoreGroups=^local\., ^internal \. The following groups nevertheless test: DontIgnoreGroups = MailInfo=1 integrates message over still unabgeholte Mails Copying only if still no instance is available - causes set AddToMessageID, otherwise is always copied: CopyIfExist=0 Crosspostings only once test, 0 test each instance CheckXPostingsOnlyOnce=1 [ display ] Yes/no = 1/0 always display final dialog ShowResultAlways=0 Final dialog display, if ShowResultIfAction=1 were copied or changed Final dialog display, if Counter exist > to 0 (applies also to Mailbenachrichtigungen): ShowResultIfCounter=1 Only Counter > 0 in the final dialog display ShowOnlyCounterGreaterThanNull=1 ShowTaskBarEntry=1 displays search procedure in task bar Display suitable Postings with test run: ShowFoundedPostingsWhenSimulate=1 [ Groups ] Automatically filled... structure of the " CopyIf.def " ======================= 0. Structure ~~~~~~ 1. General 2. The concrete possibilities 2,1 introduction to the syntax 2,1,1 " Wildcards " 2,1,2 variables 2,1,3 stringer functions 2,1,4 IF conditions 2,1,5 flow control 2,1,6 options change 2,2 text Body over process 2,2,1 Introductions of 2,2,2 texts look up/replace to 2,2,3 Quoted Printable = > 8-bit 2,3 headers process 2,3,1 definition of additional headers, headers modify or headers delete 2,3,2 ISO headers = > 8-bit 2,4 modifications store 2,5 further 3. Syntax 1. General ~~~~~~~~~~~ the CopyIf.def must be in the same directory as CopyIf.exe. It is uniquely passed through for each new Posting. Over the CopyIf.ini certain groups are excludable, besides Crosspostings become also only once passed through. Once changes stored Posting gets a special header entry, which likewise excludes a secondary run. If in the CopyIf.def not expressly one stores, the possibly made modifications without acknowledgement are rejected. To first tests should one everything up to a group exclude and the test mode activate, until the script corresponds to the own desires. As term clarifying here still the structure of a Postings from view of CopyIf: ----------- I. Header IITH Body A) Introduction b) text ----------- example: ----------- I. Message ID: < 3375981e.18152730@news.netway.at > DATE: Sat, 10 May 1997 16:32:11 GMT newsgroup: de.newusers.questions From: habol@netway.at (Hans Boldrino) .. IITH A) attention, Newbie group! ---------------------------------------- b) Hello of people! Career/development of a Newbies .. ----------- 2. The concrete possibilities ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2,1 introduction to the syntax ----------------------- The " language " of CopyIf corresponds to a large extent from Korrnews. It is line oriented and with the concrete request co-ordinated. 2.1.1 " Wildcards " - - - - - - Wildcards are enclosed in percentage signs in each case and permit e.g. the use of a header with the allocation to another header or when setting Introduction lines. Within Wildcards one can use also stringer functions, which are still described afterwards Wildcards finds use - which allocation among other things of Headern - block statements (Introductions) in most other cases are used " stringer printouts ", which have the same possibilities, but might be somewhat more readable. For the allocation of Headern and Introduction blocks the Wildcard syntax is however still whole fitting. Further details are entnehmbar the Korrnews documentation. 2.1.2 variables - - - - - Variable ones are e.g. usable in addition to be able to use - longer and a several times used printout with fewer tapping expenditure - statuses to notice, in order to be able to use it later still times in IF statements - to be able to assemble stringers stueckchenweise, in order to then assign it completely e.g. to a header. The script language knows at present excluding stringer variables, in order to process nevertheless numbers, can these by Str() into a stringer be changed at any time and with Val() again a number be made. The definition of a new variable looks in such a way: Set %Gruppe% = Header(Newsgroups) set %Programmierer% = " Thomas's G. Liesner " set %SeinVorname% = " that is nevertheless " + the Extract("^[^ ] + ", %Programmierer%) + "!" Set %ZitierteZeilen% = Str(MatchedLines('^ > ')) the use in Wildcards looks then in such a way: X-the-programmer: %Programmierer% are called! Set Introduction note: F'up2 %Header(FollowUp To)% end to correct interesting become these functions in connection with conditions. 2,1,3 stringer functions - - - - - - - - conversions: --------------- Lower(...) changes the stringer in Klein rift around Upper(...) changes the stringer in large writing around DecodeISO(...) as ISO-8859-1/qp-kodierten header changes one into a " normal " stringer with 8Bit-Zeichen around 8BitTo7Bit(...) 8-bit character in back-up characters changes codes within the ASCII around (ae = > ae, ss = > ss...) Str(...,...,...) Converts the numeric printout transferred as first parameters into a stringer. The optional second numeric parameter determines the number of Vorkomma -, optional third the number of post-decimal positions. EscRegExp(...) If one uses header etc. as RexExp, one can avoid inadvertent side effects by means of this function, since all special characters are out-masked ("." = > " \." etc.) stringer " to divide ": ----------------- First(...) picks the first item out of the stringer. With a stringer with commas the section before the first comma (e.g. newsgroup header with Crosspostings), if the stringer with " < " begins and with " > " ends, gets it the first " <... >"-pair out (e.g. References header). Last(...) the last item of the stringer picks out, aequi valent to " first " Adress(...) refers - like also the following two functions - on Mailadressen i.S. the From or Reply to header. Address tried to extract only the actual address from " Hans Hirni " becomes thus " abc@def.gh " Name(...) Tried to extract the total name from " Hans Hirni " thus " Hans Hirni " FirstName( becomes...) Tried to extract only the first name from " Hans Hirni " thus " Hans " MakeAdress(...,...) combines the transferred name and the transferred Mail address to a From/Reply To/To compatible printout iSv " name " inclusive. Consideration of special cases in the name (points, stating lines) Extract(...,...) Looks up as 1. He returns the delivery the appropriate section to parameter indicated regular printout (corresponds to the regular printouts in the hamster) in the second parameter to find, with success, otherwise an emptying ring. From Extract("a.*e ", " hall construction") became thus " all " CutLeft(...,...) Removes the number of characters, indicated as second parameters from the stringer transferred as first parameters, CutLeft("Re: Ups ", 3) results in thus " Ups ". CutRight(......)Entfernt the number of characters, indicated as second parameters on the right from the stringer transferred as first parameters, CutRight("Re: Ups ", 4) results in thus " RH: ". Special functions: (Sonderfunktionen:) ---------------- Header(...) the value of the indicated header if Full [ raw ] supplies to headers with [ Headername1 without... ] without parameters and at present only to conditions meaningfully usable, returns the delivery the entire headers as character string. In order to exclude certain headers, the " without" addition can be used. Full [ raw ] Body without parameters and at present only in conditions meaningfully usable, returns the delivery the entire Textbody abzgl. to the signature. Full [ raw ] Sig[nature ] without parameters and at present only in conditions meaningfully usable, supplies the complete signature as stringer back to Full with Article/Posting/Mail supplies the entire text in the " raw" format as stringer back constant: ---------- CR corresponds to a line-makeup 2,1,4 IF conditions - - - - - - - In order to offer more flexible possibilities, there is the possibility of making lines dependent on conditions. The basic form reads: If [ then ] .. [ else if .. ] [ else .. ] endif the ElseIf and the Else branch are optional, for "... " can any statements be begun, for the sake of the clarity are in moving recommendable. IF conditions leave themselves also to boxes, up to 15 levels are permitted. If one liked to execute only one instruction, also the short version goes: If then the exact syntax are under 3. to find, here simply times some kon krete examples: MixGroups replace ================== set %MixGroup% = " " If %ng% begins with " uunet.de." and %NG%<>"uunet.de.test " set %MixGroup% = " uunet.de.all " If %ng% then begins with " hamsters." then set %MixGroup% = " hamster.de.ALL " If %ng% begins with " cathedrals." If %ng% begins with " cathedral market." Set %MixGroup% = " muenster.markt.ALL " else set %MixGroup% = " muenster.ALL " endif endif .. If %MixGroup% > " " DO CoPy to of Group %MixGroup% then or Back-up for CopyFups =================== set %CopyFups% = " 0 " set %CopyThreads% = " 0 " If Header(References) contains " @"+%fqdn%+ " > " If Header(References) ends with " @"+%fqdn%+ " > " set %CopyFups% = " 1 " DO Inc. Counter " * new direct responses ", " * in " + %xng% set %Typ% = " direct response, " else DO Inc. Counter " * new acquisitions in own Threads ", " * in " + %xng% set %Typ% = " own Thread, " endif set %CopyThreads% = " 1 " endif .. If %CopyFups% = " 1 " DO CoPy to of Group then " tgl.fups " If %CopyThreads% = " 1 " then DO CoPy to of Group " Referring to special header entries ===================================== If %ng% contains ", " If %Typ% = " " then Append Intro x-post office over %Str(Count(', ', Header(Newsgroups)))% groups (%ng%) endif set %temp% = Lower(Header(FollowUp To)) If %temp% > " " and NOT (%ng% begins with " ml." or " _ or %ng% %NG%="de.rec.film.kritiken contains " digest") _ then If %temp%='de.alt.flame ' or %temp%='de.alt.0d ' or %temp% contains ' more kasper ' Append Intro ***** WARNING! = > F'Up2 * %Upper(%temp%)% * set ***** set header FollowUp to: %Header(FollowUp To)%, %Header(Newsgroups)% else Append Intro F'Up2 %temp% set endif endif If Header(Control) > " " Append Intro control: %Header(Control)% endif If Header(Supersedes) > " " Append Intro Supersedes: %Header(Supersedes)% endif If ChangedIntro Append Intro ---------------------------------------------------------------------------------------------------------------- end endIf .. to DO save CHANGE 2,1,5 flow control - - - - - - - around functional modules or the like to store externally to be able, there is the following statement: - DO Include these statements are already executed while the loading of the script file, therefore also the statement functions: To set Intro DO Include " intro.txt " end whereby for the case just as well the ' correct ' function set Intro from " intro.txt " to be taken can. Contents of the file are exactly the same treated like the " original " lines of the script. The file name becomes if no absolute path indicated relative to - the work directory loaded. - With Gosub a branch is possible into the " Sub of the same name ". Example: Gosub Teil1 Gosub Teil2 Quit Sub Teil1 .. endsub Sub Teil2 .. endsub the instruction " Quit " terminates the script and is necessary when using Subs, since otherwise the error message of " unknown quantities instruction ' Sub would come... ' ". For branching there is then still Goto label of which to the branch destination Label leads. 2,1,6 options change over - - - - - - - - With the instruction - set option designation = value the INI options for the current Postingdurchlauf can be modified at any time, permanent modifications are however not possible thereby. One can use this e.g. directly, by activating or deactivating the option CopyIfExist depending upon requirement: Set CopyIfExist = " 0 " note: The names of the options can change always in new program versions, even if I seek to avoid this to a large extent 2,2 text Body process ------------------- 2,2,1 Introductions - - - - - - For referring to Fup2-Fallen and similar own itself the Introductions - these are additional lines, which are inserted at the beginning of the Postings. - When allocations there are two basic alternatives: New setting or an attaching, the statement be called according to " set " or. " Append ". Besides there are three possibilities of transferring contents: Either in the CopyIf.def themselves as Mehrzeiler: (set Append) [ raw ] Introduction line #1 | line #2 line #3 .. end to example: If Header(Newsgroups) contains ", " set Intro note: Crossposting! Groups: to %Header(Newsgroups)% end endif or in the CopyIf.def as Einzeiler: If IntroLines > 0 then Append Intro: "==================================================================" or in an external file, so that in the CopyIf.def only a reference is: Set Intro from " Postingkopf.txt " with DELETE Intro can be deleted the Intro also again, with ChangedIntro should modifications be requestable and IntroLines in the example was already used. 2.2.2 texts look up/replace - - - - - - - - - - For the non-standard modification of the actual text there is the following instruction: - DO Replace (first read all) | hereby can directly in the text be modified, the search printout is | thereby a regular printout as often to be found also in the hamster. Example: If (Header(References) > "") and (NOT %fb% contains CR+ " >") then If %fb% contains CR+ " > " Append Intro... AMK Quoting style corrects. DO Replace ALL " ^ > " with " > " set %Save% = " 1 " endif endif permits also agent users to read AMKs Postings pleasantly. A further option is e.g. completely well useful for appendices of advertising: DELETES between read [, ] the first parameter indicate the search printout for the introductory line, the second parameter the search printout for the closing line, if this search printout is empty, only for the first search printout are looked up and all under it present deleted. The third printout determined, whether the introductory and closing line are to be also deleted, the last printout makes it possible to insert a back-up for the deleted text. The advertising block of the hamster mailing list looks e.g. in such a way: [ normal Posting ] ----------------------------------------------------------------------- Explore the popular High ending Room Go to of Where The Smart People Shop uBid.com http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx / - ----------------------------------------------------------------------- The suitable delete printout is thus: Set %Werbezeile% = "^-$" DELETE read %Werbezeile%, %Werbezeile%, false, " [ nerve advertisement deleted ] between " or. Set %Werbezeile% = "^-$" DELETE read %Werbezeile%, %Werbezeile%, true with the instruction DELETES Empty LINES RK between end can surplus blank lines at the end be also still eleminieren. 2,2,3 Quoted Printable = > 8-bits - - - - - - - - - - - - For Free agent, OE and Gravity users the following function should be - still interesting: DO Convert QPBody converts QP Postings after 8-bit inclusive. Header adjustment. 2,3 headers process ---------------- 2,3,1 definition of additional headers, headers modify or headers delete - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - In order to modify or produce a header again, the following instruction is - meant: Set header header name: Contents with set x-hello: Rear one is inserted the header x-hello. Contents of the allocation may contain Wildcards: Set x-Crosspost: %Str(Count(', ', Header(Newsgroups)))% the deletion been made from Headern by DELETE header x-MimeOLE the assortment are also variable: DO Sort header , , ... permits the assortment of the headers after the own taste. DO Sort header newsgroup, FollowUp to, From, Reply to would ensure that the headers mentioned come as first - whereby existente headers to be simply ignored - and the remaining headers under it in their original sequence to be remain. 2,3,2 ISO headers = > 8-bits - - - - - - - - - - concomitantly Gravity or Free agent user header well to read know, are the statement DO Convert QPHeader inserted - it changes only ISO-8859-1/qp-Kodiertes, this is however already the majority of the appropriate entries. 2,4 modifications store ------------------- So that one still which from the modifications has, they must be still stored. In addition at present three instruction serve: DO CoPy to of Group creates a copy into the group mentioned, which must naturally exist. DO export as stores the Posting into a text file, this must in the name one " * " have, which is then replaced when storing by the first still free number. DO save CHANGES replaces the past Posting, by deleting the old instances and the article RH-imported. DO Touch permits it that but over CopyIf in a pseudo's group it summarized groups, which one does not read directly in the Client, although not when " dead " groups in the daily statistics emerge. Example: If one defined an appropriate function... Gosub MixGroup " hamster.de. ", " hamster.de.all " Reading date of group of originals update: DO Touch " ^hamster\.de \." Alternative way of writing: DO Touch " ^"+EscRegExp("hamster.de.") 2.5 further ------- The following instruction fit not into the past upper points and are thus here gesammlt specified: DO (EXEC | Run) [, ] hereby external programs can be called, whereby additionally still parameters may be transferred: DO run " Notepad.exe ", " CopyIf.def " would load e.g. the " CopyIf.def " into the wordprocessor. The script continues thereby not, but continues after issuing the call directly, possibly this in future versions by parameters will be controllable. DO Include permits a storing externally of sections of the CopyIf.def into other files, which the installation of Fremdskripten erleichten might. DO Include " Skripte\iHinweis.def " would look up and into the current " CopyIf.def " would merge the file " Skripte\iHinweis.def " outgoing from the work directory. For debugging if necessary still two functions are usable: Stop goes being able to see into the error code, over e.g. variable etc. DO Show displays the current Posting the inclusive past modifications. DO Inc. more counter [, ] around free outputs to permit, one can produce with DO Inc. Counter " Antwortpostings " or DO Inc. Counter " Antwortpostings ", Header(Newsgroups) lines for the final dialog, each DO Inc. call counts up thereby automatically at the end to become then the lines in the left dialog section output. In the case of use of the second parameter one can let the whole divide still after a Sub code. DO DEFINE Counter .. case the output sequence is too chaotic, can one with this instruction the COUNT he sequence in time determine, two commas successively ensures thereby for a blank line. 3. Syntax ~~~~~~ the CopyIf.def is line by line organized, thus must between block structures, which extend over several lines, and " normal " statements to be differentiated. There are the following block structures: Sub | .. endsub If [ then ] | .. else if | .. else | .. endif (set | To Append) Intro[duction ] .. end (set | Append) raw Intro[duction ] .. end to set [ raw ] header header name: .. end to set [ raw ] %Variablenname% .. .. end the following special cases gives it still: DO Include this statement executed outside of the normal operational sequence, thus lead accesses to variables automatically to errors. Label labels may not be placed within If-Bloecken/Anweisungen, since in the first case the number of Endifs might tune any longer and in the second case that label is not found. " normal ones " statements can go if necessary also over several lines, if they are locked in each case with one " _ ", which particularly with longer conditions is completely well usable, become internal them a large line assembled and like a normal line treated. The individual items are so defined: Statement: = ([ set header ] (= | ( | Set header from | Set = | Set from | (set | Append) [ raw ] H[eader ] (= | | DELETE header | DO Sort header .. | (set | Append) [ raw ] (Intro[duction ] | Line[s ] | Sig[nature ]) = | (set | Append) [ raw ] (Intro[duction ] | Line[s ] | Sig[nature ]) from | DELETE (Intro[duction ] | Line[s ] | Sig[nature ]) | DO Replace (first | all | read) with | DELETES between (first | read) [, ] | To DELETE Empty LINES RK end | Set Opt[ion ] = | DO (EXEC | Run) | If then | Gosub | Return | Goto