home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / programs / comms_networking / irclient / !IRClient / Scripts / Modules / FloodProt (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1997-03-20  |  3.8 KB  |  140 lines

  1.  >FloodProt
  2.  Flood Protection by reduced output time
  3.  23 Sep 1996 - JF: Started                               v1.00
  4.  26 Sep 1996 - JF: Linked to the Scheduler               v1.01
  5.  27 Sep 1996 - JF: Will work with cumulative msgs        v1.02
  6.  27 Sep 1996 - JF: Configuration added                   v1.03
  7.  0,"This is an IRClient script and cannot be run."
  8. InitialiseModule
  9. StartupStatus("Initialising FloodProt...")
  10. stacktop=0
  11. stackend=0
  12. lasttime=0
  13. cb_active=
  14. 2floodprot_on=
  15. DB_ReadConfig("FloodProt_On"))
  16. 8floodprot_delay=
  17. DB_ReadConfig("FloodProt_Delay"))
  18.  floodprot_delay<5 
  19.  floodprot_delay=33
  20.  Pass on to the next module
  21.  ******* Overloaded configuration options ********
  22.  Give ourselves a sensible name
  23. Overload_ScriptInfo(num)
  24.  ret$
  25.  num=0 
  26. # ret$="FloodProt v1.03 (Gerph)"
  27.  ret$=
  28. @(num-1)
  29. #    =ret$
  30.  Overload the main transmit routine
  31. SendToIRC(a$)
  32.  floodprot_on 
  33.  loc=
  34. Claim(8)
  35.  No end, with data in
  36.  !loc=0
  37.  !(loc+4)=
  38. Strdup(a$)
  39.  debug 
  40. DisplayWarning("Stack>>"+a$,"##Debug##")
  41.  stackend<>0 
  42.  Attach it to the end of the list
  43.   !stackend=loc
  44.  stackend=loc
  45.  stacktop=0 
  46.  If nothing on stack, attach
  47.   stacktop=loc
  48.  Now to dispatch the message
  49. FloodProt_Dispatch
  50. @(a$)
  51. FloodProt_Dispatch
  52.  now,a$,loc
  53.  stacktop<>0 
  54.  "OS_ReadMonotonicTime" 
  55.  now-lasttime>floodprot_delay 
  56.  Interval has passed
  57.   loc=stacktop
  58.   a$=$(!(loc+4))
  59.   stacktop=!loc
  60.  stackend=loc 
  61.    stackend=0
  62.  Release string
  63. Release(!(loc+4))
  64.  Release the block
  65. Release(loc)
  66. SendString(MasterSocket,a$)
  67.  debug 
  68. R2   
  69. DisplayWarning("Unstack<<"+a$,"##Debug##")
  70.   lasttime=now
  71.  stacktop<>0 
  72.  cb_active=
  73. X?   
  74. AddCallBack("FloodProt",lasttime+floodprot_delay-now,0)
  75.    cb_active=
  76.  Overload the CallBack routine to trap the calls
  77. Overload_CallBack(name$,private)
  78.  name$="FloodProt" 
  79.  cb_active=
  80. FloodProt_Dispatch
  81. @(name$,private)
  82.  ****************** Configuration options *******************
  83.  Enumerate module names
  84. Overload_ConfigModName(count)
  85.  ret$
  86.  count=0 
  87.  ret$="FloodProt"
  88.  ret$=
  89. @(count-1)
  90. r    =ret$
  91.  What options do we provide ?
  92. Overload_ConfigOptions(module$)
  93.  module$="FloodProt" 
  94. DisplayConfig("")
  95. DisplayConfig("-- FloodProt configuration --")
  96. DisplayConfig("You can configure :")
  97. DisplayConfig("  Prot <boolean> : Whether the protection is active")
  98. DisplayConfig("  Delay <time>   : Delay in centi-seconds")
  99. @(module$)
  100.  How do we configure things
  101. Overload_ConfigCommand(module$,com$,str$)
  102.  module$="FloodProt" 
  103.  com$ 
  104.  "DELAY"
  105. (str$)<5 
  106. .    
  107. DisplayConfig("Syntax: Delay <time>")
  108.     floodprot_delay=
  109. (str$)
  110. <    
  111. DB_WriteConfig("FloodProt_Delay",
  112.  floodprot_delay)
  113. 9    
  114. DisplayConfig("Set Delay to "+
  115.  floodprot_delay)
  116.  "PROT"
  117.    var=
  118. boolean(str$)
  119.  var 
  120.  0,-1
  121.      floodprot_on=var
  122. 9     
  123. DB_WriteConfig("FloodProt_Prot",
  124.  floodprot_on)
  125. ?     
  126. DisplayConfig("Set Prot to "+
  127. booltext(floodprot_on))
  128. 1     
  129. DisplayConfig("Syntax: Prot <boolean>")
  130.  "LIST"
  131. DisplayConfig("")
  132. DisplayConfig("Prot   : "+
  133. booltext(floodprot_on))
  134. DisplayConfig("Delay  : "+
  135.  floodprot_delay+"cs")
  136.  "HELP"
  137. Overload_ConfigOptions(module$)
  138. DisplayConfig("Command not recognised")
  139. @(module$,com$,str$)
  140.