home *** CD-ROM | disk | FTP | other *** search
/ Magazyn WWW 1999 July / www_07_1999.iso / prez / amiga / stricq_1371.lha / stricq / rexx / QSilver-ICQ.rexx < prev   
OS/2 REXX Batch file  |  1999-05-16  |  3KB  |  83 lines

  1. /*
  2.   QSilver-ICQ.rexx - A simple example of how to use STRICQ as a file server
  3.   $VER: QSilver-ICQ.rexx v1.0 12.05.99 Copyright (C) 1999 Douglas F. McLaughlin & Roger Clark
  4.   Based on original script written by: Douglas F. McLaughlin
  5.   Note: Permission is granted to use this script in any form or make any modifications as necessary.
  6. */
  7.  
  8. Config:
  9. UserName = 'Roger Clark'
  10. MyUIN = '13648880'
  11. Path = 'Work:NetUtilities/STRICQ/FileServer/'
  12. MaxFiles = 5
  13.  
  14. ReadFile:
  15. In = 'In'
  16. Parse Arg UIN Type File .
  17. Address STRICQ.1
  18. GetContact 'UIN='UIN 'VAR=USER'
  19. If ~Open(In,File,'R') Then Exit(10)
  20.   Line = Strip(ReadLn(In),"T","0d"x)
  21. Call Close(In)
  22. Call Delete(File)
  23. If Type ~= 1 Then Exit(0)
  24.  
  25. CheckOnline:
  26. If Upper(Word(Line,1)) = '!LIST' | Upper(Word(Line,1)) = '!GET' Then Do
  27.   If User.IP = '0.0.0.0' Then Do
  28.     SendMessage 'UIN='UIN 'MSG="Sorry, you are either not in my Contact List, have your IP address hidden, or are currently offline.  Your filerequest has been cancelled."'
  29.     Call Delete("Env:QSilver-ICQ")
  30.     Exit(0)
  31.   End
  32. End
  33.  
  34. Serve:
  35. If Upper(Word(Line,1)) = '!LIST' Then Do
  36.   If Exists("Env:QSilver-ICQ") then Do
  37.     SendMessage 'UIN='UIN 'MSG="Sorry, the file server is busy.  Please try again in a few minutes."'
  38.     Exit(0)
  39.   End
  40.   Else Do
  41.     Call Open("E","ENV:QSilver-ICQ","W")
  42.       Call WriteLn("E","UIN "UIN)
  43.     Call Close("E")
  44.   End
  45.   Call Open('Out','T:FileList.'||MyUIN,'W')
  46.     Call WriteLn('Out','Files available from 'UserName' ('MyUIN')')
  47.     Call WriteLn('Out',' ')
  48.   Call Close('Out')
  49.   Address Command 'List >>T:FileList.'MyUIN' 'Path' FILES LFORMAT="%-24N %7L %C"'
  50.   AddFile 'FILE=T:FileList.'||MyUIN
  51.   FileDirect 'UIN='UIN 'SPEED=100' 'DESC="Current Files Available"'
  52.   Call Delete("Env:QSilver-ICQ")
  53.   Exit(0)
  54. End
  55. If Upper(Word(Line,1)) = '!GET' Then Do
  56.   If Exists("Env:QSilver-ICQ") then Do
  57.     SendMessage 'UIN='UIN 'MSG="Sorry, the file server is busy.  Please try again in a few minutes."'
  58.     Exit(0)
  59.   End
  60.   Else Do
  61.     Call Open("E","ENV:QSilver-ICQ","W")
  62.       Call WriteLn("E","UIN "UIN)
  63.     Call Close("E")
  64.   End
  65.   AddFile CLEAR
  66.   Sending = ""
  67.   If Words(Line) - 1 > MaxFiles Then Line = SubWord(Line,1,MaxFiles + 1)
  68.   Do Loop = 2 to Words(Line)
  69.     File = Path || Word(Line,Loop)
  70.     If Exists(File) Then Do
  71.       Sending = Sending||" "||Word(Line,Loop)||";"
  72.       AddFile 'FILE='File
  73.     End
  74.   End
  75.   Sending = Strip(Sending,"T",";")
  76.   If Words(Line) > 2 then Desc = 'Here are the files you requested:'Sending
  77.   Else Desc = 'Here is the file you requested: 'Sending
  78.   FileDirect 'UIN='UIN 'SPEED=100' 'DESC="'Desc'"'
  79.   Call Delete("Env:QSilver-ICQ")
  80.   Exit(0)
  81. End
  82. Exit(0)
  83.