home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / ad109f66.zip / chat.cmd < prev    next >
OS/2 REXX Batch file  |  1997-02-17  |  15KB  |  335 lines

  1. /* Jewfish's Multi-Line Chat Config */
  2. /* /Invite added by Hagar */
  3. /* /Join and private added by Bill-e */
  4.  
  5. Arg Line
  6.  
  7. call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  8. call SysLoadFuncs
  9.  
  10.  
  11. DefaultChannel = 'General Chat'                               /* Max 15 Chars */
  12. UserChannelCount = Right(AdeptConvert(Line,'{CU'),2,'0')
  13.  
  14.             queuename='ND'line
  15.                q =rxqueue('delete', queuename)
  16.                  q1 =rxqueue('create',queuename)
  17.                  q2 =rxqueue('set',queuename)
  18.                  q3 =rxqueue('get')
  19.                  queue '1036a.none'
  20.  
  21.  
  22.  
  23. UserName = AdeptGetVar(Line,2)
  24. UserNode = Right(Line,2,'0')
  25. UserCount = AdeptConvert(Line,'{CU')
  26. KeyList = D2C(9)
  27. InputText = ''
  28. LastPVT = ''
  29. Start = Time('M')
  30. newchannel.line=''
  31. Call AdeptInitRexx Line
  32. rc = AdeptSysChatConnectUser(Line)                                               /* Connect to Server */
  33. If rc \= 1 Then Do
  34.    Call AdeptPrint Line, "\r\n\r\nChat Server isn't available!\r\n"
  35.    Call AdeptHitReturn Line
  36.    Exit
  37. End
  38.  
  39. Call Join
  40. joined:
  41. Call AdeptPrint Line, '\r\n{CS{B2{FC  AdeptXBBS {FGMulti-Line Chatting System v0.02    {B1{F9▄\r\n'
  42. Call AdeptPrint Line, '{B2  {FFYou have entered the {FC' || DefaultChannel || ' {FFChannel' || Copies(' ',15 - Length(DefaultChannel)) || '  {B1{F9█\r\n'
  43. Call AdeptPrint Line, '{B2  {FGThere are {FB' || UserChannelCount || ' {FGusers in the Chat Subsystem      {B1{F9█\r\n'
  44. Call AdeptPrint Line, ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\r\n'
  45. Call AdeptPrint Line, '{FGType /? -or- /H for Quick Help\r\n\r\n'
  46.  
  47. Call AdeptMenuType Line, 52,""
  48. Call AdeptPrint Line, '\r\n'
  49.  
  50. Do Forever
  51.    RetC = Strip(AdeptSysChatInput(Line, "USERTEXT", KeyList, InputText),'t')
  52.    InputText = ''
  53.    If (RetC == IRC_CHATWAITING) Then Do
  54.           Call ProcessChatMsg(Line)
  55.           Iterate
  56.    End
  57.    Select
  58.          When RetC == 1 Then Do
  59.                 If UserText = 'USERTEXT' Then Iterate
  60.                 If Left(UserText,1,1) = '/' Then Call Commands
  61.                 Else Do
  62.                    If UserCount \= 999 Then Call AdeptSysChatPubMsg Line, '{FE[{FG' || UserNode || '{F8-{FB' || UserName || '{FE] {FC' || UserText
  63.                    /* Else Call AdeptPrint Line, '\r{FG¡ {FFWarning - You are the only person in this channel.\r\n            For a list of people online, type /W' */
  64.                    Call AdeptPrint Line, '\r\n'
  65.                 End
  66.                 Iterate
  67.          End
  68.          When RetC == 9 Then Do
  69.                 If LastPvt \= '' Then InputText = '/S,' || LastPvt || ' '
  70.                 Else InputText = '/S,'
  71.                 Iterate
  72.          End
  73.          When RetC == IRC_NOTIMELEFT Then Do
  74.                 Call AdeptPrint Line, "\r\nYou're outta time sucker!"
  75.                 Call Leave('Out of Time')
  76.                 Exit
  77.          End
  78.          When RetC == LOSTCARRIER Then Do
  79.                 Call Leave('Lost Carrier')
  80.                 Exit
  81.          End
  82.          When RetC == IRC_CHATDOWN Then Call AdeptSysChatReconnectUser Line
  83.          When RetC == IRC_CHATWAITING Then Do
  84.                 Call AdeptPrint Line, '\r\nThe Chatserver is busy at the moment...\r\n'
  85.                 Iterate
  86.          End
  87.          Otherwise Nop
  88.    End
  89. End
  90.  
  91.  
  92. Commands:
  93.  
  94.    If Pos(',',UserText) = 0 Then Parse Var UserText Command NodeTo MsgText
  95.    Else Parse Var UserText Command ',' NodeTo ' ' MsgText
  96.    Command = Translate(Command)
  97.    Select
  98.          When Command = '/W' Then Do
  99.                 Call AdeptMenuType Line, 55,""
  100.                 Call AdeptPrint Line, '\r\n'
  101.                 Return
  102.          End
  103.          When Command = '/Q' Then Do
  104.                 Call Leave('Leaving')
  105.                 Exit
  106.          End
  107.          When Command = '/S' Then Do
  108.                 If NodeTo = '' | MsgText = '' Then Call AdeptPrint Line, '\rYou screwed that command well and good!\r\n'
  109.                 Else Do
  110.                      Chkit = AdeptGetVar(NodeTo,44)
  111.                      myrt = AdeptCheckBit(NodeTo,24,Chit)
  112.                      if myrt = 1 then do
  113.                      Call AdeptPrint Line, '\r{F9■{F5■{FD■{FG■ Private Message Not sent, that user has their Chat Flag Disabled... {FG■{FD■{F5■{F9■\r\n'
  114.                      Return
  115.                      end
  116.                   retc = AdeptSysChatPrivMsg(Line, NodeTo, '{FE[{FG' || UserNode || '{F8-{FB' || UserName || '{FD, Pvt Msg{FE] {FC' || MsgText)
  117. /*                     Call AdeptComWrite NodeTo, '{FE[{FG' || UserNode || '{F8-{FB' || UserName || '{FD, Pvt Msg{FE] {FC' || MsgText     */
  118.                    NodeUserName = AdeptGetVar(NodeTo, 2)
  119.                    If NodeUserName \= '' Then Call AdeptPrint Line, '\r{F9■{F2■{FA■{FC■{FG■ Private Message sent to {FB' || NodeUserName || ' {FGon Node {FB' || NodeTo || ' {FG■{FC■{FA■{F2■{F9■\r\n'
  120.                    Else Call AdeptPrint Line, '\r{F9■{F5■{FD■{FG■ Private Message Not sent, there is no-one on Node {FD' || NodeTo || ' {FG■{FD■{F5■{F9■\r\n'
  121.                    LastPvt = NodeTo
  122.                 End
  123.                 Return
  124.          End
  125.          When Command = '/H' | Command = '/?' | Command = '/HELP' Then Do
  126.                 /* Convert to Meta Later */
  127.                 Call AdeptPrint Line,'\r────HELP──────────────────────────────────────────┬───EXAMPLES─────────────┐'
  128.                 Call AdeptPrint Line,'\r\n│ /S,[Node #] [Message] Send a Private Message.    │ /S,1 Hello             '
  129.                 Call AdeptPrint Line,'\r\n│ /ME [Message] Allows you to perform an Action.   │ /ME Laughs!            '
  130.                 Call AdeptPrint Line,'\r\n│ /G,[Node #] Get information about another user.  │ /I                     '
  131.                 Call AdeptPrint Line,'\r\n│ /W Show users Currently logged into the BBS.     ├────────────────────────┤'
  132.                 Call AdeptPrint Line,'\r\n│ /T Time Statistics        /A Show All Channels   │ /J Join/Make a Channel '
  133.                 Call AdeptPrint Line,'\r\n│ /L List users in Channel  /CLS Clears the Screen to make private, 1st    '
  134.                 Call AdeptPrint Line,'\r\n│ /I Invite user into your Channel                 char in name must be "+"'
  135.                 Call AdeptPrint Line,'\r\n└────────────────────────────────────/Q to Quit────────────────────────────\r\n\r\n'
  136.          End
  137.          When Command = '/T' Then Do
  138.                 Call AdeptPrint Line, '\r{FGTime Statistics:'
  139.                 Call AdeptPrint Line, '\r\nCurrent time is ' || Time('C') || '.'
  140.                 Call AdeptPrint Line, '\r\nYou have been in chat for ' ||  Time('M') - Start || ' Minute(s).'
  141.                 Call AdeptPrint Line, '\r\nYou have {T0 minute(s) Remaining on the BBS.\r\n\r\n'
  142.          End
  143.          When Command = '/ME' Then Do
  144.         If NodeTo = '' Then Call AdeptPrint Line, '\rCan you *TRY* to get the format of the command right\r\n'
  145.         Else Do
  146.            Call AdeptSysChatNoPrePubMsg Line, '{FA■ {FF' || UserName || '{ZZ' || SubStr(UserText,4)
  147.            Call AdeptPrint Line, '\r{F9■{F2■{FA■{FC■{FG■ Public Action Sent {FG■{FC■{FA■{F2■{F9■\r\n'
  148.         End
  149.      End
  150.          When Command = '/G' Then Do
  151.                 If NodeTo = '' Then Call AdeptPrint Line, '\rInvalid Command. /I,1 to get info from node 1\r\n'
  152.                 Else Do
  153.                    Call AdeptPrint Line, '\r{FGInformation About:'
  154. /*                 Call AdeptPrint Line, '\r\nUser  : ' || AdeptGetVar(NodeTo,1) || ', on Node ' || NodeTo || ' of ' || AdeptGetVar(Line,137) || '.' */
  155.                    Call AdeptPrint Line, '\r\nAlias : ' || AdeptGetVar(NodeTo,2)
  156.                    Call AdeptPrint Line, '\r\nTime  : ' || AdeptConvert(NodeTo,'{T0') || ' Minute(s) Remaining on the BBS.\r\n\r\n'
  157.                 End
  158.          End
  159.          When Command = '/CLS' Then Call AdeptPrint Line, '{CS'
  160.          When Command = '/A' Then Do
  161.                 Call AdeptMenuType Line, 52,""
  162.                 Call AdeptPrint Line, '\r\n'
  163.                 Return
  164.          End
  165.          When Command = '/L' Then Do
  166.                 Call AdeptMenuType Line, 53,""
  167.                 Call AdeptPrint Line, '\r\n'
  168.                 Return
  169.          End
  170.          When Command = '/I' Then Do
  171. if newchannel= '' then roomname=defaultchannel
  172. else roomname=newchannel
  173. Call AdeptCLS Line
  174. Call AdeptMenuType Line, 52,""
  175. /*Call AdeptMenuType Line,42,""*/
  176. Call AdeptPrint Line,"\r\n"
  177. Call AdeptPrint Line,"\r\nSend Invitation to which Node Number, 1-15... \r\nEnter to abort ..."
  178. Node=AdeptInput(Line,1,1)
  179. if Node = '' then signal done
  180. if Node > '5' then signal NoSuchNode
  181. /* if Node < '1' then signal UnAvail */
  182. CheckChat = AdeptGetVar(Node,44)
  183. IsOn = AdeptCheckBit(Node,24,CheckChat)
  184. if IsOn = 0 then signal UnAvail
  185. /*if left(roomname,1)='+' then do
  186. paswrd =  AdeptInput(line,,10,,,'\r\nEnter the Password for your Conference (5 char Max):',,,)
  187. end */
  188. Call AdeptPrint Line,"\r\nInvitation will be sent when you "
  189. Call AdeptHitReturn Line
  190. carrier = AdeptGetVar(Node,276)
  191. cr = X2C('0D')
  192. lf = X2C('0A')
  193. Call Adeptprint Node, cr lf username " is inviting you to the chat lounge room named "roomname cr
  194. if left(roomname,1)='+' then Call Adeptprint Node, cr lf ' The password is: 'paswrd
  195.  
  196. /* Call AdeptComWrite Node,cr lf "Press <Enter> to continue..."*/
  197. rc = AdeptComPeekByte(Node,1000)
  198. signal done
  199. UnAvail:
  200. Call AdeptCls Line
  201. Call AdeptPrint Line,"\r\nThat Node/User is Currently unavailable for Chat...\r\n"
  202. Call AdeptHitReturn Line
  203. signal done
  204. NoSuchNode:
  205. Call AdeptCls Line
  206. Call AdeptPrint Line,"\r\nNo such Node Number, Node must be between 1 and 5 Inclusive\r\n"
  207. Call AdeptHitReturn Line
  208. signal done
  209.  
  210. done:
  211. Call AdeptCls Line
  212. return
  213.          End
  214.          When Command = '/J' Then Do
  215.             call adeptprint line, '\r\nEnter the name of your Conference, to make a room PRIVATE'
  216.             newchannel =  AdeptInput(line,,10,,,'\r\nput a '"+"' as the first letter in the room name, ex. +room (10 chars max):',,,)
  217.             if newchannel='' then leave
  218.             if left(newchannel,1)='+' then do
  219.             idcheck='no'
  220.             isfirst='yes'
  221.             pwcheck='no'
  222.             paswrd =  AdeptInput(line,,10,,,'\r\nEnter the Password for your Conference (5 char Max):',,,)
  223.  
  224.             call adeptprint line, '\r\n'
  225.             call adeptprint line, '\r\nWhen you /I (invite) a person to your room you the system will give the user'
  226.             call adeptprint line, '\r\nthe password 'paswrd'.  This will be transmitted ONLY to the user you are'
  227.             call adeptprint line, '\r\ninviting in.  That user will then enter it along with the room name.'
  228.             call adeptprint line, '\r\n'
  229.             ok = adeptinput(line,,2,,,'\r\n Press enter to continue',,,)
  230.  
  231.  
  232.             parse upper var paswrd paswrd
  233.             parse upper var newchannel newchannel
  234.             pw=paswrd
  235.             nc=newchannel
  236.             do i=0 to 16
  237.             queuename='ND'i
  238.                q =rxqueue('set', queuename)
  239.                q= rxqueue('set', queuename)
  240.                parse pull pw1'.'nc1
  241.                if pw1='' then pw1='1036a'
  242.                if nc1='' then nc1 = 'none'
  243.                if queued() =0 then if i=line then do
  244.                  q1 =rxqueue('create',queuename)
  245.                  q2 =rxqueue('set',queuename)
  246.                  q3 =rxqueue('get')
  247.                  queue pw1'.'nc1
  248.                end
  249.                if nc<>nc1 then idcheck='ok'
  250.                if nc=nc1 then isfirst='no'
  251.                if nc=nc1 then idcheck='no'
  252.                if pw=pw1 then pwcheck='ok'
  253.                if isfirst='no' then leave
  254.             end
  255.             if isfirst='yes' then do
  256.             queuename='ND'line
  257.                q0 =rxqueue('delete',queuename)
  258.                q1 =rxqueue('create',queuename)
  259.                q2 =rxqueue('set',queuename)
  260.                q3 =rxqueue('get')
  261.             queuein = pw'.'nc
  262.             queue queuein
  263.             end
  264.             end
  265.             if left(newchannel,1)<>'+' then idcheck='ok'
  266.             if isfirst='yes' then idcheck='ok'
  267.             if isfirst='yes' then pwcheck='ok'
  268.             if idcheck='ok' then do
  269.                rc = AdeptSysChatJoinConf(Line,newchannel)
  270.                If rc = 2 Then rc = AdeptSysChatPubMsg(Line, '{FG» {FF' || UserName || ' has Joined the Channel')
  271.                UserChannelCount = Right(AdeptConvert(Line,'{CU'),2,'0')
  272.             end
  273.             if isfirst='no' then if pwcheck='no' then do
  274.             newchannel=defaultchannel
  275.             call adeptprint line, "\r\nSorry, you do not have access to that chat room"
  276.                ok = adeptinput(line,,2,,,'\r\n Press enter to continue',,,)
  277.             end
  278. Call AdeptPrint Line, '\r\n{CS{B2{FC  AdeptXBBS {FGMulti-Line Chatting System v0.02    {B1{F9▄\r\n'
  279. Call AdeptPrint Line, '{B2  {FFYou have entered the {FC' || newChannel || ' {FFChannel' || Copies(' ',15 - Length(newChannel)) || '  {B1{F9█\r\n'
  280. Call AdeptPrint Line, '{B2  {FGThere are {FB' || UserChannelCount || ' {FGusers in the Chat Subsystem      {B1{F9█\r\n'
  281. Call AdeptPrint Line, ' ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\r\n'
  282. Call AdeptPrint Line, '{FGType /? -or- /H for Quick Help\r\n\r\n'
  283. return
  284.          end
  285.  
  286.          Otherwise Call AdeptPrint Line, "\r{FG¡ {FFUnrecognised Command, Type /H for help.\r\n"
  287.    End
  288. Return
  289.  
  290.  
  291.  
  292.  
  293.  
  294. ProcessChatMsg:
  295.  
  296.    ARG line
  297.  
  298.    do while(AdeptSysChatMsgWaiting(line) == 1)
  299.            RetC = AdeptSysChatGetMsg(line)
  300.  
  301.            if(RetC == 3) then do
  302.                   /*
  303.                   Call AdeptPrint Line, '\r\nPktType = ' || PktType || '\r\n'
  304.                   Call AdeptPrint Line, '\r\nRetC = ' || RetC || '\r\n'
  305.                   */
  306.                   if(PktType == 100) then do
  307.                           AdeptPrint(line, "\r" || ChatMsgData || "\r\n")
  308.                   end
  309.                   if(PktType == 101) Then do
  310.                           AdeptPrint(line, "\r" || ChatMsgData || "\r\n")
  311.                   end
  312.                   if(PktType == 102) then do
  313.                           LastPVT = SubStr(ChatMsgData,9,2)
  314.                           AdeptPrint(line, "\r" || ChatMsgData || "\r\n")
  315.                   end
  316.            end
  317.    end
  318. return
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325. Join:
  326.    rc = AdeptSysChatJoinConf(Line, "Main")
  327.    If rc = 2 Then rc = AdeptSysChatPubMsg(Line, '{FG» {FF' || UserName || ' has Joined the Channel')
  328. Return
  329.  
  330. Leave:
  331.    Parse Arg Reason
  332.    rc = AdeptSysChatPubMsg(Line, '{FG« {FF' || UserName || ' has Left the Channel ({FG' || Reason || '{FF)')
  333.    rc = AdeptSysChatLeaveConf(Line)
  334. Return
  335.