home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / ircdor15.zip / irc.mex < prev    next >
Text File  |  1996-08-28  |  4KB  |  122 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File: irc.mex
  4. //
  5. // Desc: Provides an Internet Chat service from Maximus/2 BBS
  6. //       Requires IRCDOOR/2 package
  7. //
  8. // Copyright 1996 by Andrew Eigus 2:5100/33@fidonet
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #include <max.mh>
  13. #include <prm.mh>
  14. #include <max_menu.mh>
  15.  
  16. #define DEMO_TIME 5L  // define limited demo time
  17.  
  18. long calc_time()
  19. {
  20.   long: t;
  21.  
  22.   t := timeleft();
  23. //  if (stridx(usr.xkeys, 1, 'I') = 0)
  24. //    if (t > DEMO_TIME) t := DEMO_TIME; // restrict time
  25.   return t;
  26. }
  27.  
  28. int doirc(string: servername, int: tcpport)
  29. {
  30.   long: time;
  31.   string: command;
  32.   int: exitcode;
  33.  
  34.   log(":IRC to " + servername);
  35.  
  36.   command := "irc.cmd " + 
  37.     uitostr(id.port) + " " + uitostr(id.task_num) +
  38.     " -r\"" + usr.name + "\" -t" + ltostr(calc_time() * 60);
  39.   if (servername <> "") 
  40.     command := command + " -s" + servername + " " + "-$" + uitostr(tcpport);
  41.   exitcode := shell(IOUTSIDE_DOS, command);
  42.   if (exitcode <> 0 AND exitcode <> 255)
  43.   {
  44.     if (exitcode = 1)
  45.       print(COL_LRED, '\n', command, "\nCommand line syntax error. Please report to SysOp.");
  46.     print("\n\n");
  47.     menu_cmd(MNU_PRESS_ENTER, "");
  48.     print('\n');
  49.   }
  50.   return 0;
  51. }
  52.  
  53. void main()
  54. {
  55.   char: ch;
  56.   string: servername;
  57.   int: len;
  58.  
  59.   ch := 1;
  60.   display_file(prm_string(PRM_MISCPATH) + "doorsys2", ch);
  61.   do {
  62.     // now check if user is registered to use Telnet. If he has used all of his
  63.     // demo time, piss him off.
  64. //    if (stridx(usr.xkeys, 1, 'I') = 0)
  65. //    {
  66. //      if (timeon() > DEMO_TIME)
  67. //      {
  68. //        print(COL_LRED "\nSorry ", usr.name, ", but your demo access time for this session\n" +
  69. //            "is over. You can only use first ", DEMO_TIME, " minutes for IRC ONCE logged\n" +
  70. //            "on to the board.\n\n" +
  71. //            "In order to have more time for IRC, please contact your SysOp.\n\n");
  72. //        menu_cmd(MNU_PRESS_ENTER, "");
  73. //        print('\n');
  74. //       return;
  75. //      }
  76. //    }
  77.  
  78.     print("\n" COL_LCYAN "INTERNET RELAY CHAT");
  79. //    if (stridx(usr.xkeys, 1, 'I') = 0) 
  80. //      print(COL_LRED "\n\nYou have demo IRC access limited to ", 
  81. //            calc_time(), " minutes. If you" +
  82. //            " wish more time,\ncontact your SysOp\n\n");
  83. //    else
  84.       print(COL_CYAN " (" COL_LCYAN, calc_time(), COL_CYAN " min.)\n\n");
  85.  
  86.     print(COL_GRAY "Choose one of the IRC servers below to use for IRC,\n",
  87.       "or press `", COL_WHITE "Q" COL_GRAY "' to quit to the main menu:\n\n");
  88.  
  89.     print("   " COL_LCYAN "1" COL_CYAN ")     " COL_WHITE "irc.funet.fi      [port 6666]\n");
  90.     print("   " COL_LCYAN "2" COL_CYAN ")     " COL_WHITE "irc.pspt.fi       [port 6667]\n");
  91.     print("   " COL_LCYAN "3" COL_CYAN ")     " COL_WHITE "irc.nol.net       [port 6667]\n");
  92.     print("   " COL_LCYAN "4" COL_CYAN ")     " COL_WHITE "irc.epix.net      [port 6667]\n");
  93.     print("   " COL_LCYAN "5" COL_CYAN ")     " COL_WHITE "irc.bt.net        [port 6667]\n");
  94.     print("   " COL_LCYAN "6" COL_CYAN ")     " COL_WHITE "irc.cs.hut.fi     [port 6667]\n");
  95.     print("   " COL_YELLOW "*" COL_CYAN ")     " COL_WHITE "custom...\n");
  96.     ch := input_list("Q123456*?", CINPUT_FULLPROMPT OR CINPUT_ACCEPTABLE,
  97.       "", COL_LRED "\nInvalid selection.\n", COL_GRAY "\nSelect:" COL_WHITE);
  98.     print('\n');
  99.     if (ch = '1') 
  100.       doirc("irc.funet.fi", 6666);
  101.     else
  102.     if (ch = '2')
  103.       doirc("irc.pspt.fi", 6667);
  104.     else
  105.     if (ch = '3')
  106.       doirc("irc.nol.net", 6667);
  107.     else
  108.     if (ch = '4')
  109.       doirc("irc.epix.net", 6667);
  110.     else
  111.     if (ch = '5')
  112.       doirc("irc.bt.net", 6667);
  113.     else
  114.     if (ch = '6')
  115.       doirc("irc.cs.hut.fi", 6667);
  116.     else
  117.     if (ch = '*')
  118.       doirc("", 0);
  119.   }
  120.   while (ch <> 'Q');
  121. }
  122.