#!hs2 # Script FAQ-poster by Martin Diedrich # written in 09/2000. # Ready. Final Version, maintained only if buggy or if I´d like to. # Define Paths VarSet( $path, HamPath + "faqs\" ) # Text-Dateien VarSet( $sendpath, HamPath + "groups\news.out\" ) # News.Out-Verzeichnis # At first call, create INI-File if( !fileexists( "faqpost.ini" ) ) VarSet( $groups, ListAlloc ) ListLoad( $groups, "groups.hst" ) VarSet( $selnum, ListBox( $groups, "Please choose the group you wish to post to." ) ) VarSet( $grpname, ListGet($groups, $selnum)) ListFree( $groups ) VarSet( $midpart1, InputBox( "Please enter the left part of the message-ID. This part will be completed internally to prevent posting with the same MID more than one time." ) ) IniWrite( "faqpost.ini", $grpname, "midpart1", $midpart1 ) VarSet( $midpart2, InputBox( "Please enter your FQDN." ) ) IniWrite( "faqpost.ini", $grpname, "midpart2", $midpart2 ) VarSet( $from, InputBox( "Please enter the FROM-Address in the form 'name name '." ) ) IniWrite( "faqpost.ini", $grpname, "from", $from ) VarSet( $organization, InputBox( "Please enter the entry for the ORGANIZATION: -Header. You could perhaps enter your website-address here.", "", "Posted by FAQposter.hsc" ) ) IniWrite( "faqpost.ini", $grpname, "organization", $organization ) VarSet( $temptime, InputBox( "Please enter the number of days the FAQ will be posted again after the last post." ) ) VarSet( $olympiade, int( $temptime ) * 24 * 60 * 60 ) IniWrite( "faqpost.ini", $grpname, "olympiade", $olympiade ) VarSet( $file, InputBox( "Please enter the filename in which the FAQ ist stored (file must be saved WITHOUT any headers!)." ) ) IniWrite( "faqpost.ini", $grpname, "file", $file ) VarSet( $subject, InputBox( "Please enter the subject of the article." ) ) IniWrite( "faqpost.ini", $grpname, "subject", $subject ) Print( "The FAQ-poster configuration is basically completed now." ) endif # FAQ-Post?! # Gruppenliste laden VarSet( $groups, ListAlloc ) ListLoad( $groups, "groups.hst" ) # Zeit und Datum auslesen var( $year, $month, $day, $hrs, $min, $sec, $wd ) VarSet( $localtime, time ) decodetime( timegmt, $year, $month, $day, $hrs, $min, $sec, $wd ) # Wochentage in Bez. umwandeln icase( $wd, "1", VarSet( $weekday, "Sun" ), "2", VarSet( $weekday, "Mon" ), "3", VarSet( $weekday, "Tue" ), "4", VarSet( $weekday, "Wed" ), "5", VarSet( $weekday, "Thu" ), "6", VarSet( $weekday, "Fri"), "7", VarSet( $weekday, "Sat" ) ) # Monate in Bez. umwandeln icase( $month, "1", VarSet( $mon, "Jan" ), "2", VarSet( $mon, "Feb" ), "3", VarSet( $mon, "Mar" ), "4", VarSet( $mon, "Apr" ), "5", VarSet( $mon, "May" ), "6", VarSet( $mon, "Jun"), "7", VarSet( $mon, "Jul" ), "8", VarSet( $mon, "Aug" ), "9", VarSet( $mon, "Sep" ), "10", VarSet( $mon, "Oct" ), "11", VarSet( $mon, "Nov" ), "12", VarSet( $mon, "Dec" ) ) # Konvention: ZWEI Ziffern if( len( $day ) = 1 ) VarSet( $day, str( $day, 2, 0 ) ) endif if( len( $hrs ) = 1 ) VarSet( $hrs, str( $hrs, 2, 0 ) ) endif if( len( $min ) = 1 ) VarSet( $min, str( $min, 2, 0 ) ) endif if( len( $sec ) = 1 ) VarSet( $sec, str( $sec, 2, 0 ) ) endif # Gruppenliste durchgehen Var( $i ) $i = 0 while( $i < ListCount( $groups ) ) VarSet( $grpname, ListGet( $groups, $i ) ) VarSet( $olympiade, IniRead( "faqpost.ini", $grpname, "olympiade", "0" ) ) VarSet( $lastpost, IniRead( "faqpost.ini", $grpname, "lastpost", "0" ) ) if( $olympiade <> "0" ) if( time > int( $olympiade ) + int( $lastpost ) ) faqpost else VarSet( $nextpost, int( $olympiade ) + int( $lastpost ) ) Var( $y, $mt, $d, $h, $m, $s, $wd ) decodetime( $nextpost, $y, $mt, $d, $h, $m, $s, $wd ) icase( $wd, "1", VarSet( $weekday, "Sun" ), "2", VarSet( $weekday, "Mon" ), "3", VarSet( $weekday, "Tue" ), "4", VarSet( $weekday, "Wed" ), "5", VarSet( $weekday, "Thu" ), "6", VarSet( $weekday, "Fri"), "7", VarSet( $weekday, "Sat" ) ) print( "Keine FAQ für " + $grpname + " heute! - next: " + $weekday + ", " + $d + "." + $mt + "." ) endif endif inc( $i ) endwhile ListFree( $groups ) quit # SUBROUTINE faqpost sub faqpost # Zeitrechnung auf aktuelles Datum, 00:00 Uhr VarSet( $todaypost, encodetime( $year, $month, $day, "00", "00", "00" ) ) # Lastpost in INI eintragen IniWrite( "faqpost.ini", $grpname, "lastpost", $todaypost ) # Header in neue Liste generieren und INI auslesen VarSet( $posting, ListAlloc ) VarSet( $midpart1, IniRead( "faqpost.ini", $grpname, "midpart1", "undefined-MIDpart1" ) ) VarSet( $midpart2, IniRead( "faqpost.ini", $grpname, "midpart2", "invalid.loc" ) ) VarSet( $from, IniRead( "faqpost.ini", $grpname, "from", "addyisinvalid@invalid.loc" ) ) VarSet( $subject, IniRead( "faqpost.ini", $grpname, "subject", "FAQ" ) ) VarSet( $organization, IniRead( "faqpost.ini", $grpname, "organization", "Posted by FAQposter.hsc" ) ) VarSet( $file, IniRead( "faqpost.ini", $grpname, "file", "invalidfilename" ) ) VarSet( $subject, InputBox( "Please enter a new subject or hit return to accept.", "FAQposter unconfigured posting", $subject ) ) ListLoad( $posting, $path + $file ) # Misc ListInsert( $posting, 0, "" ) ListInsert( $posting, 0, "Content-Transfer-Encoding: 8bit" ) ListInsert( $posting, 0, "Content-Type: text/plain; charset=iso-8859-1" ) ListInsert( $posting, 0, "MIME-Version: 1.0" ) ListInsert( $posting, 0, "Newsgroups: " + $grpname ) ListInsert( $posting, 0, "Subject: " + $subject ) ListInsert( $posting, 0, "X-Posting-Agent: Hamster/" + HamVersion ) # MID generieren und Listen VarSet( $MID, "Message-ID: <" + $midpart1 + "." + time + "@" + $midpart2 + ">" ) ListInsert( $posting, 0, $MID ) # Datum einfügen VarSet( $headerdate, "Date: " + $weekday + ", " + $day + " " + $mon + " " + $year + " " + $hrs + ":" + $min + ":" + $sec + " GMT" ) ListInsert( $posting, 0, $headerdate ) # From, Organization und X-Mailer einfügen ListInsert( $posting, 0, "From: " + $from ) ListInsert( $posting, 0, "Organization: " + $organization ) ListInsert( $posting, 0, "X-Mailer: FAQposter.hsc from http://www.mdiedrich.de" ) VarSet( $postfilename, "faq" + time + ".msg" ) ListSave( $posting, $sendpath + $postfilename ) ListFree( $posting ) Warning( "Die FAQ der Gruppe " + $grpname + " wurde gepostet." ) endsub