home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / gtirc306.zip / REXXMSG.CMD < prev    next >
OS/2 REXX Batch file  |  1997-11-24  |  7KB  |  131 lines

  1. /*********************************************************************/
  2. /* REXXMSG.CMD   GammaTech IRC Sample REXX Message Exit Script       */
  3. /*********************************************************************/
  4. /*                                                                   */
  5. /* This is a sample REXX script for use with GammaTech IRC. It       */
  6. /* provides the following functions.                                 */
  7. /*                                                                   */
  8. /* 1) Automatically rejoin a channel if we are kicked off.           */
  9. /* 2) Autogreet when joining a channel or when others join.          */
  10. /* 3) Automatically begin a log file when we join a channel.         */
  11. /*                                                                   */
  12. /* Warning: Do not change this script. Copy it to another name       */
  13. /* and modify the copy for backup purposes.                          */
  14. /*                                                                   */
  15. /*********************************************************************/
  16. /*                                                                   */
  17. /* Entry arguments:                                                  */
  18. /*                                                                   */
  19. /* Arg 1 - Window Handle                                             */
  20. /* Arg 2 - Our Nickname                                              */
  21. /* Arg 3 - The message text from IRC                                 */
  22. /*                                                                   */
  23. /* The third input argument is the full message from the IRC server. */
  24. /* It may be helpful to refer to RFC 1459 to interpret the various   */
  25. /* IRC messages. A copy of RFC 1459 is located in the GTIRC          */
  26. /* directory.                                                        */
  27. /*                                                                   */
  28. /* The incoming message may be suppressed or ignored. To suppress    */
  29. /* the message, return a null ("") string. To allow the message to   */
  30. /* be processed normally, return a non-null string.                  */
  31. /*                                                                   */
  32. /*********************************************************************/
  33. /*                                                                   */
  34. /* There are external REXX functions you may use in this REXX        */
  35. /* procedure which are described in the online help under Script     */
  36. /* programming. A summary of those functions is shown below:         */
  37. /*                                                                   */
  38. /* IrcRexxDisplay(text,win)          Display text in a window.       */
  39. /* IrcRexxCommand(text,win)          Send text or /comamnd to IRC    */
  40. /* IrcRexxSend(text,win)             Send raw text to server.        */
  41. /* IrcRexxVariable(win,name[,value]) Query or set an IRC variable.   */
  42. /* IrcRexxWildCard(wildcard,string)  Check for wildcard match.       */
  43. /*                                                                   */
  44. /*********************************************************************/
  45. Parse Upper Arg WinHandle OurNick Prefix Cmd Chan Nick Rest
  46.  
  47. Pool = 'OS2ENVIRONMENT'
  48.  
  49. /*********************************************************************/
  50. /* We see if this is a kick message for us. If so we format and      */
  51. /* display a message in the window and rejoin the channel.           */
  52. /*                                                                   */
  53. /* We send the join command directly to the server because if we     */
  54. /* send it as a normal command using IrcRexxCommand() it will be     */
  55. /* ignored because the kick has not been processed and it thinks     */
  56. /* we are still on the channel.                                      */
  57. /*                                                                   */
  58. /* We return a null string to suppress the kick message so that the  */
  59. /* window for the channel will not be closed.                        */
  60. /*                                                                   */
  61. /*********************************************************************/
  62.  
  63. if (Cmd = 'KICK' & Nick = OurNick) then do
  64.    By = substr(Prefix,2)
  65.    Posex = pos('!',By)
  66.    By = substr(By,1,posex - 1)
  67.  
  68.    Posex = pos(':',Rest)
  69.    Reason = substr(Rest,2)
  70.  
  71.    Disp = "*** Kicked by" By "(" || Reason || ")"
  72.    IrcRexxDisplay(Disp,WinHandle)
  73.  
  74.    OutStr = "JOIN" Chan
  75.    IrcRexxSend(OutStr,WinHandle)
  76.    Return ""
  77. End
  78.  
  79. /*********************************************************************/
  80. /* AutoGreets are lame. But if you really want to autogreet folks    */
  81. /* you can enable this script by setting the following variable:     */
  82. /*                                                                   */
  83. /* /var $AutoGreet,:#CHANNEL (channel name in upper case)            */
  84. /*                                                                   */
  85. /*********************************************************************/
  86.  
  87. if (Cmd = 'JOIN' & Chan = IrcRexxVariable(WinHandle,"$AutoGreet")) then do
  88.    Parse Arg . OurNick Prefix Rest
  89.  
  90.    NewNick = substr(Prefix,2)
  91.    Posex = pos('!',NewNick)
  92.    NewNick = substr(NewNick,1,Posex - 1)
  93.  
  94.    If (NewNick <> OurNick) then do
  95.       OutStr = "Hey" NewNick "!!!"
  96.       IrcRexxCommand(OutStr,WinHandle)
  97.    End
  98.  
  99.    Else do
  100.       OutStr = "Hi all"
  101.       IrcRexxCommand(OutStr,WinHandle)
  102.    End
  103. End
  104.  
  105. /*********************************************************************/
  106. /* Begin a log file when we join a channel. This feature is disabled */
  107. /* by default. To enable it set the following variable:              */
  108. /*                                                                   */
  109. /* /var $AutoLog,yes                                                 */
  110. /*                                                                   */
  111. /*********************************************************************/
  112.  
  113. if (Cmd = 'JOIN' & IrcRexxVariable(WinHandle,"$AutoLog") = 'yes') then do
  114.    NewNick = substr(Prefix,2)
  115.    Posex = pos('!',NewNick)
  116.    NewNick = substr(NewNick,1,Posex - 1)
  117.  
  118.    If (NewNick = OurNick) then do
  119.       OutStr = "/LOG ON"
  120.       IrcRexxCommand(OutStr,WinHandle)
  121.    End
  122. End
  123.  
  124. /*********************************************************************/
  125. /* We don't care about this message so return a non-null string so   */
  126. /* that it will be processed normally.                               */
  127. /*********************************************************************/
  128.  
  129. Return "OK"
  130.  
  131.