home *** CD-ROM | disk | FTP | other *** search
/ The Arcade BBS / arcadebbs.zip / arcadebbs / bbstools / MODS / ALLMODS.ZIP / EGG2.ZIP / EGG2.MOD next >
Encoding:
Text File  |  1995-07-03  |  14.0 KB  |  417 lines

  1. Nick #1 @1301
  2. Thu Jun 29 20:21:28 1995
  3. ┌────────────────────────────────────────────────────────────────────────────┐
  4. │ Mod Name      : EGG2.MOD          Original Author : Scramblegg 1@15284 NET │
  5. │ Difficulty    : ██▒▒▒▒▒▒▒▒        Updated to 4.23 : The Irishman           │
  6. │ WWIV Version  : 4.24              Updated to 4.24 : Nick 1@1301            │
  7. │ Mod Date      : 07/07/92  Mod Update: 06/29/95                             │
  8. │ Files Affected: BBS.C, MISCCMD.C, MMENU.C, FCNS.H                          │
  9. │ Description   : The Fabled and somewhat elusive //ADEIT mod!  The BEST     │
  10. │                 Enhanced Automessage mod there is!                         │
  11. └────────────────────────────────────────────────────────────────────────────┘
  12. ┌────────────────────────────────────────────────────────────────────────────┐
  13. │  EGG2.MOD - A New Auto-Message (Version 1.1)                               │
  14. │    Frustrated with the small auto-message in stock WWIV, I wrote this.  It │
  15. │ lets you  write  an auto-message with  Ctrl-P color, word  wrap, unlimited │
  16. │ lines, the  Ctrl-N/X/W  features, etc.  You  can  lock  the  auto  message │
  17. │ (letting only the sysop write it) or  unlock it (letting anyone change it) │
  18. │ while in the BBS, without having to recompile.                             │
  19. │    New features in 1.1:  Now all variables are kept external, so that  you │
  20. │ can change them without recompiling the BBS.  They are: maximum  lines per │
  21. │ message, the security level to write  anonymous, the auto-message  colors, │
  22. │ the auto-message lock, whether or  not  the auto-message is anonymous, and │
  23. │ the author  of  the auto-message.  There  is  now an editor, accessed with │
  24. │ //AEDIT from the main menu, to edit those variables.                       │
  25. │    More stuff:  The ability to write anonymous auto-messages, configurable │
  26. │ colors, two auto-message files are written now, one for ansi users and one │
  27. │ for those without ansi, the choice to abort an auto-message if no  subject │
  28. │ is given, auto-replying to the author of an auto-message.                  │
  29. │                                                                            │
  30. │  The Disclaimer:  I'm only  responsible for the GOOD things this mod does. │
  31. │  Simple enough, eh? :-)  Address any comments, etc to 1@15284 (Scramblegg) │
  32. │                                                                            │
  33. │  06/29/95 :  I was looking for an extremely well done auto message         │
  34. │              modification for 4.24, couldn't find one, so not being        │
  35. │              fond of reinventing the wheel, I revamped this one.           │
  36. │              Watch out for line wrap....!!!                                │
  37. │                                                  -Nick, 1@1301             │
  38. │                                                                            │
  39. └────────────────────────────────────────────────────────────────────────────┘
  40.  
  41. ============================================================================
  42. Step 1 - Take out old auto message.
  43. ============================================================================
  44. At the beginning of MISCCMD.C, search for:
  45.  
  46. void read_automessage()
  47.  
  48. Delete the entire function.
  49.  
  50. ============================================================================
  51. Step 2: Add New Auto Message function.
  52. ============================================================================
  53. Add this to the bottom of MISCCMD.C:
  54.  
  55. void newam()
  56. {
  57.   time_t secs_now;
  58.   struct tm *mt;
  59.   char k,s[161],ro[160],fn[80],author[80],color1,color2,lock,anony;
  60.   int optoo,AMSGLINES,mailto,anonysl;
  61.   FILE *ff,*gg;
  62.  
  63.   gg=fopen("AUTOMSG.CNT","r+");
  64.   if(gg==NULL) {
  65.     nl();
  66.     prt(1,"Auto message status file not found. Creating with defaults.");
  67.     gg=fopen("AUTOMSG.CNT","w+");
  68.     fprintf(gg,"20\n255\n7\n1\n0\n0\n ");
  69.     fseek(gg,0,SEEK_SET);
  70.     nl();
  71.   }
  72.   AMSGLINES=atoi(fgets(s,80,gg));
  73.   anonysl=atoi(fgets(s,80,gg));
  74.   color1=atoi(fgets(s,80,gg));
  75.   color2=atoi(fgets(s,80,gg));
  76.   lock=atoi(fgets(s,80,gg));
  77.   anony=atoi(fgets(s,80,gg));
  78.   fgets(author,80,gg);
  79.   fclose(gg);
  80.  
  81.   for(;;) {
  82.     ro[0]=0;
  83.     nl();
  84.     npr("%c%d%s Auto-Message Menu\r\n",3,color1,syscfg.systemname);
  85.     sprintf(fn,", [%c%dL%c%d]ock/Unlock Auto-Message",3,color1,3,color2);
  86.     ansic(color2);
  87.     npr("[%c%dR%c%d]ead, [%c%dW%c%d]rite, [%c%dQ%c%d]uit, [%c%dA%c%d]uto-Reply%
  88. s : ",3,color1,3,
  89.                 color2,3,color1, 3,color2, 3,color1, 3,color2, 3,color1,3,color
  90. 2,
  91.            so() ? fn : "");
  92.     if(!so())
  93.       k=onek("RWQA");
  94.     else
  95.       k=onek("RWQAL");
  96.     switch(k) {
  97.        case 'Q': return;
  98.        case 'L':
  99.          nl();
  100.          lock = (!lock);
  101.          ansic(7);
  102.          npr("Auto-Message is now %s\r\n", lock ? "Locked" :
  103.         "Unlocked");
  104.          break;
  105.        case 'R': printfile("NEW_AUTO"); break;
  106.        case 'A':
  107.          if(anony && actsl<anonysl) {
  108.             nl();
  109.             ansic(2);
  110.             pl("This is an anonymous auto-message.  You cannot auto-reply.");
  111.             break;
  112.          }
  113.          nl();
  114.          mailto=finduser(author);
  115.      if(mailto>0)
  116.            email(mailto,0,0,0);
  117.          else
  118.           pl("Sorry, the user who wrote this auto-message cannot be found.");
  119.          break;
  120.        case 'W':
  121.          if(lock && (!so())) {
  122.             nl();
  123.         prt(7,"The auto-message has been locked by the SysOp");
  124.             break;
  125.          }
  126.          secs_now = time(NULL);
  127.          mt = localtime(&secs_now);
  128.          sprintf(fn,"%sTEMP.MSG",syscfg.gfilesdir);
  129.          ff=fopen(fn,"w");
  130.          if(ff==NULL) return;
  131.          nl();
  132.          if(actsl>=anonysl) {
  133.             outstr("Would you like this to be anonymous? ");
  134.             anony=yn();
  135.      }
  136.          fprintf(ff,"%c%dAuto-Message written by %c%d%s%c%d on %c%d%d/%d/%d%c0\
  137. n",
  138.                      3,color2, 3, color1, anony ? "ANONYMOUS" : thisuser.name,
  139.                      3,color2, 3, color1, (mt->tm_mon)+1,mt->tm_mday,
  140.                      mt->tm_year,3);
  141.          fprintf(ff,"%c%d",3,color2);
  142.          for(k=0;k<79;k++)
  143.        fputc(196, ff);
  144.          fprintf(ff,"\n");
  145.          ansic(7);
  146.          outstr("Subject: ");
  147.          ansic(0);
  148.          mpl(60);
  149.          inputl(s,60);
  150.          if(strlen(s)==0) {
  151.            prt(2,"No subject. Abort? ");
  152.            if(yn()) break;
  153.          }
  154.          fprintf(ff,"%c%dSubject:%c%d %s\n", 3,color1, 3, color2, s);
  155.          s[0]=0;
  156.          fprintf(ff,"%c%d",3,color2);
  157.          for(k=0;k<79;k++)
  158.            fputc(196, ff);
  159.          fprintf(ff,"\n");
  160.          nl();
  161.          optoo=0;
  162.          npr("Enter Auto-Message now - %s line limit. /ES saves."
  163.      " /ABT aborts. ", (AMSGLINES) ? itoa(AMSGLINES,s,10) : "No");
  164.          s[0]=0;
  165.          pl("Control-P color codes are recognized.");
  166.          outstr("[--------.---------.---------.---------.---------.---------.--
  167. -------.---------]");
  168.          for(k=0;optoo==0;) {
  169.             if(k==AMSGLINES && (AMSGLINES)) {
  170.                for(;;) {
  171.                  outstr("Save? ");
  172.                  if(yn()) optoo=1;
  173.                  outstr("Abort? ");
  174.                  if(!ny()) {
  175.                    nl();
  176.                    prt(1,"You have reached the maximum line limit -- You MUST s
  177. ave or abort!\r\n");
  178.                  }
  179.                  else optoo=2;
  180.                  if(optoo) break;
  181.               }
  182.             }
  183.         if(k==(AMSGLINES-1) && (AMSGLINES))
  184.                prt(0,"This is your 6last0 line!\r\n");
  185.         inli(s,ro,160,1);
  186.             if(stricmp(s,"/ES")==0) optoo=1;
  187.             if(stricmp(s,"/ABT")==0) optoo=2;
  188.             if(optoo) break;
  189.             fprintf(ff,"%s\n",s);
  190.             k++;
  191.          }
  192.          if(optoo==2) {
  193.             fclose(ff);
  194.             unlink(fn);
  195.             pl("Auto-Message aborted.");
  196.          }
  197.          if(optoo==1) {
  198.            outstr("Saving...");
  199.            strcpy(author,thisuser.name);
  200.            fprintf(ff,"%c%d",3,color2);
  201.            for(k=0;k<79;k++)
  202.              fputc(196, ff);
  203.        fprintf(ff,"\n");
  204.            fclose(ff);
  205.        sprintf(s,"copy %stemp.msg %snew_auto.ans > nul",syscfg.gfilesdir,
  206.                         syscfg.gfilesdir);
  207.            system(s);
  208.            for(k=0;k<9;k++) {
  209.              outstr("<");
  210.              backspace();
  211.              backspace();
  212.            }
  213.            prt(2,"Creating non-ansi auto-message...");
  214.            sprintf(s,"%snew_auto.ans",syscfg.gfilesdir);
  215.            ff=fopen(s,"r");
  216.            sprintf(s,"%snew_auto.msg",syscfg.gfilesdir);
  217.            gg=fopen(s,"w");
  218.            while(!feof(ff)) {
  219.              s[0]=fgetc(ff);
  220.              if(s[0]=='─') fputc('-',gg);
  221.              else if(s[0]==3) fgetc(ff);
  222.              else fputc(s[0],gg);
  223.        }
  224.            fclose(ff);
  225.        fclose(gg);
  226.            for(k=0;k<33;k++) {
  227.              outstr("<");
  228.              backspace();
  229.              backspace();
  230.            }
  231.            prt(2,"Rewriting status...");
  232.            gg=fopen("AUTOMSG.CNT","w");
  233.            fprintf(gg,"%d\n%d\n%d\n%d\n%d\n%d\n%s",AMSGLINES,anonysl,
  234.                 color1,color2,lock,anony,author);
  235.            fclose(gg);
  236.            for(k=0;k<19;k++) {
  237.              outstr("<");
  238.              backspace();
  239.              backspace();
  240.            }
  241.            prt(2,"Auto-Message saved.");
  242.          }
  243.      break;
  244.       }
  245.    }
  246. }
  247.  
  248.  
  249. ============================================================================
  250. Step 3: Change calls to old auto-message to new auto-message
  251. ============================================================================
  252.  
  253. In LILO.C, in void logon(), look for this:
  254.  
  255.   if (ss!=NULL)
  256.     farfree(ss);
  257.   nl();
  258.   if (live_user)
  259.     read_automessage();
  260.  
  261. Change
  262.     read_automessage();
  263. to
  264.     printfile("NEW_AUTO");
  265.  
  266. ============================================================================
  267. Step 4: Change the call to the function.
  268. ============================================================================
  269.  
  270. in MMENU.C, in void mainmenu() look for
  271.  
  272.   case 'A':
  273.  
  274. And change the:
  275.    write_automessage();
  276. to
  277.    newam();
  278.  
  279. ============================================================================
  280. Step 5: Add auto-message edito.
  281. ============================================================================
  282.  
  283. In MMENU.C, function mainmenu(void) search for this:
  284.  
  285.     /*  force_callout(2); */
  286.     }
  287.     if (strncmp(s,"DEBUG",5)==0) {
  288.       if((s[5]) && (s[5]!=' '))
  289.         debuglevel=s[5]-'0';
  290.       else if(s[6])
  291.         debuglevel=s[6]-'0';
  292.     }
  293.  
  294. And insert this:
  295.  
  296.   if (cs()) {
  297.     if (strcmp(s, "AEDIT")==0)
  298.       aedit();
  299.    }
  300.  
  301. ============================================================================
  302. Step 6: Add the Auto-Message setup editor
  303. ============================================================================
  304.  
  305. Open MISCCMD.C.  Add the following function to the end:
  306.  
  307. void aedit()
  308. {
  309.   FILE *gg;
  310.   char choice,color1,color2,lock,anony,author[81],s[81];
  311.   int anonysl,lines;
  312.  
  313.   gg=fopen("AUTOMSG.CNT","r+");
  314.   if(gg==NULL) {
  315.     prt(1,"\r\nAuto message status file not found. Creating with defaults.\r\n"
  316. );
  317.     gg=fopen("AUTOMSG.CNT","w+");
  318.     fprintf(gg,"20\n255\n7\n1\n0\n0\n ");
  319.     fseek(gg,0,SEEK_SET);
  320.   }
  321.   lines=atoi(fgets(s,80,gg));
  322.   anonysl=atoi(fgets(s,80,gg));
  323.   color1=atoi(fgets(s,80,gg));
  324.   color2=atoi(fgets(s,80,gg));
  325.   lock=atoi(fgets(s,80,gg));
  326.   anony=atoi(fgets(s,80,gg));
  327.   fgets(author,80,gg);
  328.   fclose(gg);
  329.  
  330.   for(;;) {
  331.     nl();
  332.     itoa(lines,s,10);
  333.     npr("   %c7Auto-Message Stats:\r\n",3);
  334.     npr("1> Max. Lines: %s\r\n",lines ? s : "Unlimited");
  335.     npr("2> Anony Security Level: %d\r\n",anonysl);
  336.     npr("3> Color #1: %c%dColor %c0(#%d)\r\n",3,color1,3,color1);
  337.     npr("4> Color #2: %c%dColor %c0(#%d)\r\n",3,color2,3,color2);
  338.     npr("5> Locked? %s\r\n", lock ? "Yes" : "No");
  339.     pl("Q> Quit+Save");
  340.     pl("X> Quit Without Saving");
  341.     npr("Auto-Message Written by: %s\r\n", author);
  342.     outstr("Choose: [1-5,Q,X] ? ");
  343.     choice=getkey();
  344.     npr("%c",choice);
  345.     if(isalpha(choice)) choice=toupper(choice);
  346.     if(choice=='Q' || choice=='X' || (choice>='1' && choice<='5')) {
  347.       nl();
  348.       switch(choice) {
  349.         case '1':
  350.           outstr("Enter new max lines (0 for unlimited): ");
  351.       mpl(3);
  352.           input(s,3);
  353.           lines=atoi(s);
  354.           npr("Maximum lines now: %s.", lines ? s : "Unlimited");
  355.           break;
  356.         case '2':
  357.           outstr("Enter new security level to write anonymous: ");
  358.           mpl(3);
  359.           input(s,3);
  360.           anonysl=atoi(s);
  361.           npr("New Anony SL: %d.",anonysl);
  362.           break;
  363.         case '3':
  364.           outstr("Enter new color for Color #1: ");
  365.           mpl(1);
  366.           s[0]=getkey();
  367.           npr("%c",s[0]);
  368.           nl();
  369.           if(s[0]>='0' && s[0]<='7')
  370.             color1=(s[0]-'0');
  371.       else
  372.             pl("Not a valid color (range: 0-7)");
  373.           break;
  374.         case '4':
  375.           outstr("Enter new color for Color #2: ");
  376.           mpl(1);
  377.           s[0]=getkey();
  378.           npr("%c",s[0]);
  379.           nl();
  380.           if(s[0]>='0' && s[0]<='7')
  381.             color2=(s[0]-'0');
  382.           else
  383.             pl("Not a valid color (range: 0-7)");
  384.           break;
  385.         case '5':
  386.           lock = (!lock);
  387.           npr("Auto-Message now %s.", lock ? "locked" : "unlocked");
  388.           break;
  389.         case 'X':
  390.           return;
  391.     case 'Q':
  392.           gg=fopen("AUTOMSG.CNT","w");
  393.           fprintf(gg,"%d\n%d\n%d\n%d\n%d\n%d\n%s",lines,anonysl,
  394.                   color1,color2,lock,anony,author);
  395.           fclose(gg);
  396.           return;
  397.       }
  398.     }
  399.   }
  400. }
  401. ============================================================================
  402. Step 6: Function prototypes
  403. ============================================================================
  404.  
  405. Either use MAKE FCNS, or  edit FCNS.H manually as follows:
  406.  
  407. Delete void read_automessage()
  408.        void  write_automessage1()
  409.        void  write_automessage()
  410.  
  411. Add
  412.        void newam();
  413.        to the end of the functions in MISCCMD.C
  414.  
  415.  
  416. MAKE the BBS and that should do it.
  417.