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

  1. /*********************************************************************/
  2. /* DMI IRC REXX Command Script for REXX Clients.  v1.25   26 Sep 96  */
  3. /*********************************************************************/
  4. /* Inbound Functions                                      26 Sep 96  */
  5. /*********************************************************************/
  6.  
  7. Parse Upper Arg WinHandle OurNick Prefix Cmd Chan Nick Rest More
  8. Parse Arg xWinHandle xOurNick xPrefix xCmd xChan xNick xRest
  9. Parse Arg zWinHandle zOurNick zPrefix zCmd zChan zNick zRest zWall zWall1
  10. Parse Arg AllArgs
  11.  
  12. Pool = 'OS2ENVIRONMENT'
  13. CMDHandle = Value('CMDHandle',, Pool)
  14. DataDir = Value('DataDir',, Pool)
  15. IF ((Right(DataDir, 1) \= '\') & (DataDir \= '')) then
  16.    Value('DataDir', DataDir'\', Pool)
  17. DMIMsg = '*DMI*'
  18. ErrStr = '*[Error]*'
  19. Version = '1.25'
  20.  
  21. SIGNAL ON SYNTAX;
  22. /* LineOut('C:\IRC-In.Txt', AllArgs); LineOut('C:\IRC-In.Txt')*/ /* For debugging */
  23.  
  24. if (Cmd == 'PRIVMSG') then do
  25.    Call GetNickId
  26.    Select
  27.       When (Chan == OurNick) then do   /* These are messages to us, otherwise they're to the chan */
  28.          Select
  29.             When (Nick == ':CLIENTINFO') then do
  30.                IrcRexxSend('NOTICE' FromNick ':CLIENTINFO CLIENTINFO DCC ECHO FINGER PAGE PING SOUND SOURCE TIME USERINFO VERSION XDCC', WinHandle)
  31.                Return ''
  32.             end
  33.             When ((Nick = ':DCC') | (Nick = ':DCC')) then do
  34.                IF (Rest \= 'SEND') & (Rest \= 'CHAT') then do
  35.                   Call GetNickId       /* Eat CTCP DCC to get around GTIRC bug                  */
  36.                   IrcRexxDisplay(DMIMsg ''FromNick' has just attempted to crash GTirc! Auto-Ignoring.', WinHandle);
  37.                   IrcRexxCommand('/IGNORE' FromNick 'CTCP', WinHandle);
  38.                   Return ''
  39.                end
  40.                else
  41.                   Return 'OK'
  42.             end
  43.             When (Nick == ':SOURCE') then do
  44.                IrcRexxSend('NOTICE' FromNick ':SOURCE For GammaTech IRC, call SofTouch Systems (405) 947-8085.', WinHandle)
  45.                IrcRexxSend('NOTICE' FromNick ':SOURCE For DMI, look for Deek on EFnet.', WinHandle)
  46.                Return ''
  47.             end
  48.             When (Nick = ':VERSION') then do
  49.                IrcRexxSend('NOTICE' FromNick ':VERSION DMI '|| Version ||', Copyright (C) 1996 Dusk To Dawn Computing', WinHandle)
  50.                Return 'OK'
  51.             end
  52.             When ((Nick = ':PAGE') | (Nick = ':PAGE')) then do
  53.                Paging = Value('Paging',, Pool)
  54.                if (Paging == 'ON' | Paging == 'BEEPS') then do
  55.                   note.0 = 8
  56.                   note.1 = 220                  /* Play a series of musical notes */
  57.                   note.2 = 330
  58.                   note.3 = 440
  59.                   note.4 = 550
  60.                   note.5 = 660
  61.                   note.6 = 770
  62.                   note.7 = 880
  63.                   note.8 = 990
  64.                   do i=1 to note.0
  65.                      Beep(note.i, 50)
  66.                   end
  67.                end
  68.                if (Paging == 'WAVE') then call play 'File='Value('PageWave',, Pool)
  69.                if (Nick = ':PAGE') then
  70.                   IrcRexxDisplay('*** CTCP PAGE ('FromNick'):' Strip(xRest, 'T', ''), WinHandle)
  71.                else
  72.                   IrcRexxDisplay('*** CTCP PAGE ('FromNick')', WinHandle)
  73.                Return ''
  74.             end
  75.             When ((Nick == ':XDCC') | (Nick == ':XDCC')) then do
  76.                TempVar = XDCC_In(AllArgs)
  77.                Return TempVar
  78.             end
  79.             Otherwise do
  80.                If (Value('MsgLog',, Pool) == 'ON') then do /* MSG Logger */
  81.                   MessageLog = DataDir || 'Messages.Log'
  82.                   Flag = Pos('', xNick)
  83.                   if (Flag == 0) then do
  84.                      xNick = Strip(xNick,L,':')
  85.                      Message = xNick xRest
  86.                      LogText = FromNick FromID Date('N') Time('C') Message
  87.                      LineOut(MessageLog, LogText)
  88.                      LineOut(MessageLog)
  89.                   end
  90.                end
  91.                Return 'OK'
  92.             end
  93.          end
  94.       end
  95.       Otherwise Return 'OK'
  96.    end
  97. end
  98.  
  99. if (Cmd = 'JOIN') then do
  100.    Call GetNickId
  101.    If Value('AutoLog',, Pool) = 'ON' then do /* Begin a log file when we join a channel */
  102.       if IrcRexxWildcard(':'OurNick'!*@*', Prefix) = 'MATCH' then do
  103.          IrcRexxCommand('/LOG ON', WinHandle);
  104.       end
  105.    end
  106.    If Value('AutoMode',, Pool) = 'ON' then do /* Automatically change mode */
  107.       AutoList = DataDir||'AutoMode.Lst'
  108.       do while Lines(AutoList)
  109.          userline = LineIn(AutoList)
  110.          Parse Upper Var userline Action UsrMask Channel dummy
  111.          Parse Var Userline xAction xUsrMask xChannel Comment
  112.          Chan = Strip(Chan, 'L', ':')
  113.          If (IrcRexxWildCard(':'UsrMask, Prefix) = 'MATCH') & (IrcRexxWildCard(Channel, Chan) = 'MATCH') then do
  114.             Select
  115.                When Action = 'V' then IrcRexxSend('MODE' Chan '+v' FromNick, WinHandle)
  116.                When Action = 'O' then IrcRexxSend('MODE' Chan '+o' FromNick, WinHandle)
  117.                When Action = 'B' then do
  118.                   IrcRexxSend('MODE' Chan '-o+b' FromNick xUsrMask, WinHandle)
  119.                   if Comment = '' then
  120.                      BKMsg = Value('BKMsg',, Pool)
  121.                   else
  122.                      BKMsg = Comment
  123.                   IrcRexxSend('KICK' Chan FromNick ':'BKMsg, WinHandle)
  124.                end
  125.                Otherwise NOP
  126.             end
  127.          end
  128.       end
  129.       LineOut(AutoList)
  130.    end
  131.    Return 'OK'
  132. end
  133.  
  134. /*********************************************************************/
  135. /* We see if this is a kick message for us. If so we format and      */
  136. /* display a message in the window and rejoin the channel.           */
  137. /*********************************************************************/
  138.  
  139. if (Cmd = 'KICK' & Nick = OurNick) then do
  140.    Call GetNickId
  141.    xRest = SubStr(xRest, 2)
  142.    IrcRexxDisplay(DMIMsg 'Kicked by' FromNick '(' || xRest || ')',WinHandle)
  143.    IrcRexxSend('JOIN' xChan, WinHandle)
  144.    Return ''
  145. End
  146.  
  147. if (Cmd = '301') then do
  148.    Select
  149.       When (Value('GetInfo',, Pool) = 'ON') then do
  150.          IrcRexxDisplay('Away    : 'Strip(xRest, 'L', ':')'', CmdHandle)
  151.          Return ''
  152.       end
  153.       When (Value('GetIdle',, Pool) = 'ON') then Return ''
  154.       When (Value('GetIdle2',, Pool) = 'ON') then Return ''
  155.       Otherwise Return 'OK'
  156.    end
  157. end
  158.  
  159. if (Cmd = '311') then do
  160.    Select
  161.       When (Value('GetInfo',, Pool) = 'ON') then do
  162.          TempStr1 = 'User Information for: ' || zNick || ''
  163.          TempLen = Length('User Information for: ' || zNick)
  164.          Parse var zWall1 Dummy zWall1
  165.          IrcRexxDisplay('User Information for: 'zNick'', CmdHandle)
  166.          IrcRexxDisplay(Copies('~', TempLen), CmdHandle)
  167.          IrcRexxDisplay('IRC Name: 'Strip(zWall1, 'L', ':')'', CmdHandle)
  168.          IrcRexxDisplay('Address : 'zRest'@'zWall'', CmdHandle)
  169.          Return ''
  170.       end
  171.       When (Value('GetIdle',, Pool) = 'ON') then Return ''
  172.       When (Value('GetIdle2',, Pool) = 'ON') then Return ''
  173.       Otherwise Return 'OK'
  174.    end
  175. end
  176.  
  177. if (Cmd = '312') then do
  178.    Select
  179.       When (Value('GetInfo',, Pool) = 'ON') then do
  180.          IrcRexxDisplay('Server  : 'zRest' ('Strip(zWall, 'L', ':') zWall1')', CmdHandle)
  181.          Return ''
  182.       end
  183.       When (Value('GetIdle',, Pool) = 'ON') then do
  184.          Parse var xRest IdleServer dummy
  185.          IrcRexxSend('WHOIS' IdleServer Value('IdleNick',, Pool), WinHandle)
  186.          Value('GetIdle2', 'ON', Pool)
  187.          Return ''
  188.       end
  189.       When (Value('GetIdle2',, Pool) = 'ON') then Return ''
  190.       Otherwise Return 'OK'
  191.    end
  192. end
  193.  
  194. if (Cmd = '313') then do
  195.    Select
  196.       When (Value('GetInfo',, Pool) = 'ON') then do
  197.          IrcRexxDisplay('Info    : 'zNick' is an IRCop!', CmdHandle)
  198.          Return ''
  199.       end
  200.       When (Value('GetIdle',, Pool) = 'ON') then Return ''
  201.       When (Value('GetIdle2',, Pool) = 'ON') then Return ''
  202.       Otherwise Return 'OK'
  203.    end
  204. end
  205.  
  206. if (Cmd = '317') then do
  207.    Select
  208.       When (Value('GetInfo',, Pool) = 'ON') then do
  209.          IrcRexxDisplay('Idle    : 'zRest' Seconds', CmdHandle)
  210.          Return ''
  211.       end
  212.       When (Value('GetIdle',, Pool) = 'ON') then Return ''
  213.       When (Value('GetIdle2',, Pool) = 'ON') then do
  214.          IrcRexxDisplay(''Value('IdleNick',, Pool)' has been idle for 'zRest' seconds.', CmdHandle)
  215.          Return ''
  216.       end
  217.       Otherwise Return 'OK'
  218.    end
  219. end
  220.  
  221. if (Cmd = '318') then do
  222.    Select
  223.       When (Value('GetInfo',, Pool) = 'ON') then do
  224.          Value('GetInfo', 'OFF', Pool)          /* Turn off GetInfo */
  225.          Return ''
  226.       end
  227.       When (Value('GetIdle',, Pool) = 'ON') then do
  228.          Value('GetIdle', 'OFF', Pool)
  229.          Return ''
  230.       end
  231.       When (Value('GetIdle2',, Pool) = 'ON') then do
  232.          Value('GetIdle2', 'OFF', Pool)
  233.          Return ''
  234.       end
  235.       Otherwise Return 'OK'
  236.    end
  237. end
  238.  
  239. if (Cmd = '319') then do
  240.    Select
  241.       When (Value('GetInfo',, Pool) = 'ON') then do
  242.          IrcRexxDisplay('Channels: 'Strip(zRest, 'L', ':') zWall zWall1'', CmdHandle)
  243.          Return ''
  244.       end
  245.       When (Value('GetIdle',, Pool) = 'ON') then Return ''
  246.       When (Value('GetIdle2',, Pool) = 'ON') then Return ''
  247.       Otherwise Return 'OK'
  248.    end
  249. end
  250.  
  251. if (Cmd = '321' & Value('CSTATING',,Pool) = 'ON') then do
  252.    Junk = xRest                        /* Eat "Channel Created" timestamp */
  253.    Return ''
  254. end
  255.  
  256. if (Cmd = '322' & Value('CSTATING',,Pool) = 'ON') then do
  257.    Parse Var xRest NickTotal Topic
  258.    Topic = Strip(Topic, L, ':')
  259.    if (topic = '') then do
  260.       IrcRexxDisplay('*' Center('' nicktotal 'Total people',58) '*', CmdHandle)
  261.       IrcRexxDisplay('*' Center('Topic for' xNick 'is:',58) '*', CmdHandle)
  262.       IrcRexxDisplay('*' Center(' No topic has been set!',58) '*', CmdHandle)
  263.       IrcRexxDisplay(Copies('*', 60), CmdHandle)
  264.    end
  265.    else do
  266.       if (Length(topic) > 56) then do
  267.          wordcount = Words(topic)
  268.          halfcount = wordcount % 2
  269.          firsthalf = SubWord(topic, 1, halfcount)
  270.          secondhalf = Subword(topic, halfcount + 1)
  271.          firsthalf = Strip(firsthalf, B)
  272.          secondhalf = Strip(secondhalf, B)
  273.          IrcRexxDisplay('*' Center('' nicktotal 'Total people',58) '*', CmdHandle)
  274.          IrcRexxDisplay('*' Center('Topic for' xNick 'is:',58) '*', CmdHandle)
  275.          IrcRexxDisplay('*' Center(firsthalf, 56) '*', CmdHandle)
  276.          IrcRexxDisplay('*' Center(secondhalf, 56) '*', CmdHandle)
  277.          IrcRexxDisplay(Copies('*',60), CmdHandle)
  278.       end
  279.       else do
  280.          IrcRexxDisplay('*' Center('' nicktotal 'Total people',58) '*', CmdHandle)
  281.          IrcRexxDisplay('*' Center('Topic for' xNick 'is:',58) '*', CmdHandle)
  282.          IrcRexxDisplay('*' Center(topic,56) '*', CmdHandle)
  283.          IrcRexxDisplay(Copies('*',60), CmdHandle)
  284.       end
  285.    end
  286.    Value('cstating','OFF',Pool)
  287.    Return ''
  288. end
  289.  
  290. if (Cmd = '324' & Value('CSTATING',,Pool) = 'ON') then do
  291.    modes = xRest
  292.    IrcRexxDisplay('*' Center('Modes for' xNick':' modes, 58) '*', CmdHandle)
  293.    Return ''
  294. end
  295.  
  296. if (Cmd = '329' & Value('CSTATING',, Pool) = 'ON') then do      /* Suppress Created Time stamp on Undernet */
  297.    Junk = xRest
  298.    Return ''
  299. end
  300.  
  301. if (Cmd = '353') then do
  302.    Select
  303.       When (Value('CStating',, Pool) = 'ON') then do   /* Handle incoming channel info for display */
  304.          Parse Var xRest channel nicks
  305.          nickcount = Words(nicks)
  306.          opcount = '0'
  307.          marker = Pos('@', nicks)
  308.          if (marker = '0') then do
  309.             opcount = 'No'
  310.          end
  311.          else do
  312.             do until marker = '0'
  313.                marker = Pos('@', nicks, marker + 1)
  314.                opcount = opcount + 1
  315.             end
  316.          end
  317.          IrcRexxDisplay(Copies('*', 60), CmdHandle)
  318.          IrcRexxDisplay('*' Center('Stats for' channel':',58) '*', CmdHandle)
  319.          IrcRexxDisplay('*' Center('' nickcount 'visible People',58) '*', CmdHandle)
  320.          IrcRexxDisplay('*' Center('' opcount 'Channel Operators',58) '*', CmdHandle)
  321.          IrcRexxDisplay(Copies('*',60), CmdHandle)
  322.       end
  323.       When (Value('Walling',, Pool) = 'ON') then do      /* Wall - Get nicks, save 'em, NOTICE 'em. */
  324.          Names. = ''
  325.          Names.0 = 0
  326.          Count = 0
  327.          NickOne = Strip(zWall, 'L', ':')
  328.          NickPool = NickOne zWall1
  329.          do until NickPool = ''
  330.             parse var NickPool tmpWord NickPool
  331.             Count = Count + 1
  332.             Names.Count = tmpWord
  333.             Names.0 = Count
  334.          end
  335.          do Count = 1 to Count
  336.             if (Pos('@', Names.Count) = 1) then do
  337.                Names.Count = Strip(Names.Count, 'L', '@')
  338.             end
  339.          end
  340.          NickStr = Names.1
  341.          do Count = 2 to Count
  342.             NickStr = NickStr || ',' || Names.Count
  343.          end
  344.          TempVar = Value('WallMsg',,Pool)
  345.          Strip(NickStr, 'B', ',')
  346.          NotNick = 'NOTICE' NickStr ':'
  347.          IrcRexxSend(NotNick || TempVar, WinHandle)
  348.          Value('Walling', 'OFF', Pool)
  349.       end
  350.       When (Value('WallOping',,Pool) = 'ON') then do     /* WallOp - Get Ops' nicks, save 'em, NOTICE 'em. */
  351.          Names. = ''
  352.          Names.0 = 0
  353.          Count = 0
  354.          NickOne = Strip(zWall, 'L', ':')
  355.          NickPool = NickOne zWall1
  356.          do until NickPool = ''
  357.             parse var NickPool tmpWord NickPool
  358.             Count = Count + 1
  359.             Names.Count = tmpWord
  360.             Names.0 = Count
  361.          end
  362.          nickstr = ''
  363.          do Count = 1 to Count
  364.             if (Pos("@", Names.Count) = 1) then do
  365.                CleanNick = Strip(Names.Count, L, '@')
  366.                NickStr = NickStr || CleanNick || ','
  367.             end
  368.          end
  369.          TempVar = Value('WallMsg',, Pool)
  370.          Strip(NickStr, 'B', ',')
  371.          NotNick = 'NOTICE' NickStr ':'
  372.          IrcRexxSend(NotNick || TempVar, WinHandle)
  373.          Value('WallOping', 'OFF', Pool)
  374.       end
  375.       Otherwise Return 'OK'
  376.    end
  377.    Return ''
  378. end
  379.  
  380. if (Cmd == '364') then do
  381.    Select
  382.       When (Value('GetSrvr',, Pool) = 'ON') then do
  383.          TempCount = Value('Cnt',, Pool) + 1
  384.          Value('Cnt', TempCount, Pool)
  385.          Value('Srvrs.'TempCount, xNick, Pool)
  386.       end
  387.       When (Value('GetCurr',,Pool) = 'ON') then do
  388.          TempCount = Value('CurrCnt',, Pool) + 1
  389.          Value('CurrCnt', TempCount, Pool)
  390.          Value('CurrSvrs.'TempCount, xNick, Pool)
  391.       end
  392.       Otherwise Return 'OK'
  393.    end
  394.    Return ''
  395. end
  396.  
  397. if (Cmd == 365) then do                /* End of server list - stop looking for it */
  398.    Select
  399.       When (Value('GetSrvr',, Pool) = 'ON') then do
  400.          Value('GetSrvr', 'OFF', Pool)
  401.          IrcRexxCommand('/WRITESVR', CmdHandle)
  402.       end
  403.       When (Value('GetCurr',, Pool) = 'ON') then do
  404.          Value('GetCurr','OFF', Pool)
  405.          IrcRexxCommand('/WRITECURRSVR', CmdHandle)
  406.       end
  407.       Otherwise Return 'OK'
  408.    end
  409.    Return ''
  410. end
  411.  
  412. Return 'OK'                            /* No special message, pass it on to client */
  413.  
  414. GetNickId:
  415.    Pos1 = Pos('!', xPrefix)
  416.    FromNick = SubStr(xPrefix, 2, Pos1 - 2)
  417.    FromId = SubStr(xPrefix, Pos1 + 1)
  418. Return
  419.  
  420. SYNTAX:
  421.    IrcRexxDisplay(ErrStr 'REXX Syntax Error' RC '(' || ErrorText(RC) || ') at line' SIGL 'of DMI-Msg.Cmd.', WinHandle);
  422. Return ''
  423.  
  424.