home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.magick      Meh.. another magic/spellcasting forum      90,437 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 90,420 of 90,437   
   street@shellcrash.com to All   
   AI Generated Usenet Client in Python (2/   
   19 Dec 25 04:17:16   
   
   [continued from previous message]   
      
   # ---------- GROUP RELOAD ----------   
   def reload_group(nntp, group):   
       try:   
           _, _, first, last, _ = nntp.group(group)   
           first = int(first)   
           last = int(last)   
      
           _, overviews = nntp.over((max(first, last - MAX_ARTICLES_LIST), last))   
      
           posts = []   
           for num, hdr in reversed(overviews):   
               subject = hdr.get("subject", "")   
               if RE_REPLY.match(subject):   
                   continue   
      
               msgid = hdr.get("message-id", "")   
               replies = sum(   
                   1 for _, h in overviews if msgid in h.get("references", "")   
               ) if SHOW_REPLY_COUNT_MAIN else 0   
      
               posts.append({   
                   "num": int(num),   
                   "subject": CLEAN_RE.sub("", subject),   
                   "from": CLEAN_RE.sub("", hdr.get("from", "?")),   
                   "date": hdr.get("date", "?"),   
                   "msgid": msgid,   
                   "replies": replies   
               })   
      
           return posts, first, last   
      
       except Exception as e:   
           set_status(f"Reload failed: {e}")   
           return None, None, None   
      
   # ---------- GROUP BROWSER ----------   
   def browse_group(nntp, group):   
       posts, first, last = reload_group(nntp, group)   
       if not posts:   
           return   
      
       index = 0   
      
       while index < len(posts):   
           p = posts[index]   
      
           print(f"   
   [{index+1}] #{p['num']}")   
           print(f"From: {p['from']}")   
           print(f"Date: {p['date']}")   
           print(f"Replies: {p['replies'] if SHOW_REPLY_COUNT_MAIN else '?'}")   
           print(f"Subject: {p['subject']}")   
      
           show_status()   
           print("   
   ENTER=read  SPACE=next  R=replies  N=new post  L=reload  J=jump  G=group    
   Q=quit")   
      
           key = get_key().lower()   
      
           if key == "q":   
               sys.exit(0)   
      
           elif key == " ":   
               index += 1   
      
           elif key in ("   
   ", "   
   "):   
               show_article(nntp, p["num"], group, True)   
      
           elif key == "n":   
               if post_article(nntp, group):   
                   posts, first, last = reload_group(nntp, group)   
                   index = 0   
      
           elif key == "l":   
               posts, first, last = reload_group(nntp, group)   
               index = 0   
               set_status("Group reloaded")   
      
           elif key == "j":   
               val = prompt("Jump to post number: ")   
               if val.isdigit():   
                   idx = int(val) - 1   
                   if 0 <= idx < len(posts):   
                       index = idx   
      
           elif key == "g":   
               browse_group(nntp, prompt("New group: "))   
               return   
      
           elif key == "r":   
               replies = scan_replies_xover(nntp, p["msgid"], first, last)   
               if not replies:   
                   set_status("No replies found")   
                   continue   
      
               for i, rnum in enumerate(replies):   
                   if i < len(replies) - 1:   
                       print("   
   ENTER=next reply | SPACE=skip remaining | P=reply")   
                   else:   
                       print("   
   End of replies | P=reply")   
      
                   k = get_key().lower()   
      
                   if k == " ":   
                       set_status("Skipped remaining replies")   
                       break   
                   elif k == "p":   
                       post_reply(nntp, group, rnum)   
                   elif k in ("   
   ", "   
   "):   
                       show_article(nntp, rnum, group, True)   
      
   # ---------- MAIN ----------   
   def main():   
       print(f"Connecting to {NNTP_SERVER}:{NNTP_PORT}...")   
       nntp = nntplib.NNTP_SSL(NNTP_SERVER, NNTP_PORT, USERNAME, PASSWORD)   
       set_status("Connected")   
       browse_group(nntp, START_GROUP)   
       nntp.quit()   
      
   if __name__ == "__main__":   
       main()   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca