home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / dmi125.zip / AutoMode.Cmd < prev    next >
OS/2 REXX Batch file  |  1996-09-26  |  4KB  |  86 lines

  1. /*********************************************************************/
  2. /* DMI IRC REXX Command Script for REXX Clients.  v1.25   26 Sep 96  */
  3. /*********************************************************************/
  4. /* AutoMode Functions                                     26 Sep 96  */
  5. /*********************************************************************/
  6.  
  7. AutoMode:
  8.    Parse Upper Arg WinHandle WinName OurNick Verb Command Action Mask Channel Extra
  9.    Parse Arg xWinHandle xWinName xOurNick xVerb xCommand xAction xMask xChannel xExtra
  10.  
  11.    Pool = 'OS2ENVIRONMENT'
  12.    CMD = Value('COMSPEC',, Pool)
  13.    ErrStr = '*[Error]*'
  14.    DMIMsg = '*DMI*'
  15.    DataDir = Value('DataDir',, Pool)
  16.    AutoList = DataDir || 'AutoMode.Lst'
  17.  
  18.    SIGNAL ON SYNTAX
  19.    Select
  20.       When (Command == 'ADD') then do
  21.          Stream(AutoList, 'C', 'SEEK <0') /* Go to End of File */
  22.          LineOut(AutoList, Action xMask xChannel xExtra)
  23.          Select
  24.             When (Action == 'B') then TempAct = 'BanKick'
  25.             When (Action == 'O') then TempAct = 'Op'
  26.             When (Action == 'V') then TempAct = 'Voice'
  27.             Otherwise TempAct = '[UnknownAction]'
  28.          end
  29.          IrcRexxDisplay(DMIMsg 'AutoMode Added: ' || TempAct xMask || ' in channel ' || xChannel || '.', WinHandle)
  30.          IrcRexxDisplay(DMIMsg 'Comments: ' || xExtra || '', WinHandle)
  31.          LineOut(AutoList)
  32.       end
  33.       When (Command == 'DEL') then do
  34.          AutoTemp = 0
  35.          Stream(AutoList, 'C', 'CLOSE')
  36.          do while Lines(AutoList)
  37.             TempLine = LineIn(AutoList)
  38.             Parse upper var TempLine TempAct TempMask dummy
  39.             If (IrcRexxWildCard(Action, TempMask) == 'MATCH') then
  40.                IrcRexxDisplay(DMIMsg 'AutoMode deleted: ' || TempLine, WinHandle)
  41.             else do
  42.                AutoTemp = AutoTemp + 1
  43.                AutoLine.AutoTemp = TempLine
  44.             end
  45.          end
  46.          Stream(AutoList, 'C', 'CLOSE')
  47.          CALL Library
  48.          rc = SysFileDelete(AutoList)
  49.          LineOut(AutoList)
  50.          do temp = 1 to AutoTemp
  51.             LineOut(AutoList, AutoLine.temp)
  52.          end
  53.          LineOut(AutoList)
  54.       end
  55.       When (Command == 'LIST') then do
  56.          IrcRexxDisplay('Current AutoMode List:', WinHandle)
  57.          IrcRexxDisplay('~~~~~~~~~~~~~~~~~~~~~~', WinHandle)
  58.          IrcRexxDisplay('Action   UserMask                  Channel       Comments/Reason', WinHandle)
  59.          IrcRexxDisplay('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~', WinHandle)
  60.          do while Lines(AutoList)
  61.             TempLine = LineIn(AutoList)
  62.             Parse var TempLine TempAct TempMask TempChan TempExtra
  63.             Select
  64.                When (TempAct == 'B') then TempAct = 'BanKick '
  65.                When (TempAct == 'O') then TempAct = 'Op      '
  66.                When (TempAct == 'V') then TempAct = 'Voice   '
  67.                Otherwise TempAct = 'Unknown '
  68.             end
  69.             IrcRexxDisplay(TempAct Left(TempMask, 25) Left(TempChan, 13) TempExtra, WinHandle)
  70.          end
  71.          LineOut(AutoList)
  72.       end
  73.       Otherwise IrcRexxDisplay(ErrStr 'Usage: /AUTO <Command> <Action> <Mask> <Channel> [Comments/Reason]', WinHandle)
  74.    end
  75.    Return ''
  76.  
  77. library:
  78.    CALL RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  79.    CALL SysLoadFuncs
  80. Return
  81.  
  82. SYNTAX:
  83.    IrcRexxDisplay(ErrStr 'REXX Syntax Error' RC '(' || ErrorText(RC) || ') at line' SIGL 'of AutoMode.Cmd.', WinHandle);
  84. Return ''
  85.  
  86.