home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / gscr20.zip / gmsg.cmd < prev    next >
OS/2 REXX Batch file  |  1997-06-11  |  5KB  |  213 lines

  1. /* Processed for messages Received */
  2.  
  3. Parse Upper Arg Win Us Prefix Cmd Chan Nick Rest
  4. Parse Arg xWin xUs xPrefix xCmd xChan xNick xRest
  5. Parse Arg ywin yus yprefix ycmd ychan alltext 
  6. Pool = 'OS2ENVIRONMENT'
  7.  
  8. /* tempstr = win||'#'||us||'#'||prefix||'#'||cmd||'#'||chan||'#'||nick||'#'||rest
  9.  
  10. ircrexxdisplay(tempstr, win) */
  11.  
  12.  
  13.  
  14.  
  15. /* Auto Rejoin on Kick */
  16.  
  17. if (Cmd = 'KICK' & Nick = Us) then do
  18.    By = substr(Prefix,2)
  19.    Posex = pos('!',By)
  20.    By = substr(By,1,posex - 1)
  21.  
  22.    Posex = pos(':',xRest)
  23.    Reason = substr(xRest,2)
  24.  
  25.    Disp = "*** Kicked by" By "(" || Reason || ")"
  26.    IrcRexxDisplay(Disp,Win)
  27.  
  28.    OutStr = "JOIN" Chan
  29.    IrcRexxSend(OutStr)
  30.    Return ""
  31. End
  32.  
  33.  
  34.  
  35. /* Log anything that is a private conversation if the logger is on */
  36.  
  37. msglog = value('log',,Pool)
  38. if(cmd='PRIVMSG' & CHAN = Us & msglog = 'on') then do
  39.     n = Value('nummsgs',,Pool) + 1
  40.     Value('nummsgs',n,Pool)
  41.     id = substr(Prefix, 2)
  42.     Posex = pos('!', id)
  43.     id = substr(id,1,posex -1)
  44.     message = id' 'Time()'] 'xNick' 'xRest
  45.     Value('msgbuf.'n,message,Pool)
  46.  
  47.     
  48.     if(n > value('buffer',,Pool)) then do
  49.         roll=value('rollbuffer',,pool)
  50.         if roll = 'on' then do
  51.             do i = 1 to n
  52.                 nextmsg = value('msgbuf.'i+1,,Pool)
  53.                 value('msgbuf.'i,nextmsg,Pool)
  54.             end
  55.             value('nummsgs',n-1,Pool)
  56.         end
  57.         else do
  58.             ircrexxdisplay(' ', win)
  59.             ircrexxdisplay('YOUR MESSAGE BUFFER IS FULL', win)
  60.             ircrexxdisplay('TYPE /set nummsgs 0 TO RESET', win)
  61.             value('nummsgs',n-1,Pool)
  62.         end
  63.     end
  64. return "OK"
  65.  
  66. end
  67.  
  68.  
  69.  
  70. /* Actions on Joins to Channel */
  71.  
  72. if (cmd='JOIN') then do
  73.     joinactions=value('joinactions',,pool)
  74.     B=right(xprefix, length(xprefix)-1)
  75.     NetMask=Substr(xPrefix,2)
  76.     posbang=pos('!', NetMask)
  77.     NewNick=Substr(Netmask, 1, posbang - 1)
  78.     xchan = right(xchan, length(xchan)-1)
  79.  
  80.     if newnick=xus then do
  81.         onjoin = value('onjoin',,pool)
  82.         if onjoin = '' then return "OK"
  83.         ircrexxcommand("/rexx "||onjoin, win)
  84.         return "OK"
  85.     end
  86.     
  87.     join = value('join',,Pool)
  88.     if join \= 'on' then return 'OK'
  89.  
  90.  
  91.     do i = 1 to joinactions
  92.         A=value(host.i,,pool)
  93.         actioni=value(action.i,,pool)
  94.         call checkmask
  95.         if OK then do
  96.             do j = 1 to words(actioni)
  97.                 action=subword(actioni, j, 1)
  98.                 if action='+o' then ircrexxcommand('/mode '||xchan||' +o '||newnick, win)
  99.                 if action='+k' then ircrexxcommand('/kick '||newnick||' Autokick', win)
  100.                 if action='+b' then do
  101.                     ircrexxcommand('/mode '||xchan||' +b '||A, win)
  102.                     ircrexxcommand('/kick '||newnick||' Banned', win)
  103.                 end
  104.                 if action='+i' then do
  105.                     ircrexxcommand('/ignore '||A, win)
  106.                     ircrexxcommand('/notice '||newnick||' Sorry.  You are automatically being ignored.', win)
  107.                 end
  108.                 if action='+g' then call greetthem
  109.                 if action='+p' then call greetthem
  110.                 if action='+n' then call greetthem
  111.                 if length(action) > 2 then do
  112.                     greetscr = value('greetscr',,Pool)
  113.                     if greetscr = 'on' then do
  114.                         scriptname = right(action, length(action) - 1)
  115.                         ircrexxcommand('/rexx '||scriptname||' '||newnick, win)
  116.                     end
  117.                 end    
  118.             end
  119.         end 
  120.     end
  121.  
  122. return "OK"
  123. end
  124.  
  125.  
  126. /* Script called when leaving a channel */
  127. if (cmd='PART') then do
  128.     onleave=value('onleave',,pool)
  129.     if onleave='' then return "OK"
  130.     NetMask=Substr(xPrefix,2)
  131.     posbang=pos('!', NetMask)
  132.     NewNick=Substr(Netmask, 1, posbang - 1)
  133.  
  134.     if newnick=xus then do
  135.         ircrexxcommand("/rexx "||onleave, win)
  136.         return "OK"
  137.     end
  138. return "OK"
  139. end
  140.  
  141.  
  142. /* Autokick MirC color codes */
  143. if CMD = 'PRIVMSG' then do
  144.     kickmirc=value('kickmirc',,pool)
  145.     if kickmirc \= 'on' then return "OK"
  146.     
  147.     do i = 1 to length(alltext)
  148.         if substr(alltext, i, 1) = '' then do
  149.             NetMask=Substr(xPrefix,2)
  150.             posbang=pos('!', NetMask)
  151.             NewNick=Substr(Netmask, 1, posbang - 1)
  152.             ircrexxcommand('/kick '||newnick||' Kill the mirc escape codes, please.', win)
  153.             return "OK"
  154.         end
  155.     end
  156.     return "OK"
  157. end
  158.  
  159. /* Everything Else */
  160.  
  161. Return "OK"
  162.  
  163.  
  164.  
  165. /* Pattern Searching Routine used in Hostmasks */
  166. checkmask:
  167.  
  168. presearch = A
  169. search = ''
  170.  
  171. do k = 1 to length(presearch)
  172.     thischar = substr(presearch, k, 1)
  173.     if (thischar='.')|(thischar='*') then do
  174.         if thischar = '.' then search = search||'\.'
  175.         if thischar = '*' then search = search||'.*'
  176.     end
  177.     else search = search||thischar
  178. end
  179.  
  180. joined = B
  181. inlist = Grep(search, joined)
  182.  
  183.  
  184. if inlist='0 0' then OK=0
  185. if inlist\='0 0' then OK=1
  186.  
  187. return ''
  188.  
  189.  
  190.  
  191.  
  192. /* Auto Greets */
  193.  
  194. greetthem:
  195.  
  196. greet=value('greet',,pool)
  197. if greet \= 'on' then return ''
  198.  
  199. greetmsg = value('greetmsg',,pool)
  200. output = ''
  201.  
  202. do k = 1 to words(greetmsg)
  203.     piece = subword(greetmsg, k, 1)
  204.     if piece='$ch' then piece = xchan
  205.     if piece='$ni' then piece = newnick
  206.     output = output||' '||piece
  207. end
  208.  
  209. if action = '+g' then ircrexxcommand(output, win)
  210. if action = '+p' then ircrexxcommand('/msg '||newnick||' '||output, win)
  211. if action = '+n' then ircrexxcommand('/notice '||newnick||' '||output, win)
  212.  
  213. return ''