home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1997-03-20 | 3.8 KB | 140 lines |
- >FloodProt
- Flood Protection by reduced output time
- 23 Sep 1996 - JF: Started v1.00
- 26 Sep 1996 - JF: Linked to the Scheduler v1.01
- 27 Sep 1996 - JF: Will work with cumulative msgs v1.02
- 27 Sep 1996 - JF: Configuration added v1.03
- 0,"This is an IRClient script and cannot be run."
- InitialiseModule
- StartupStatus("Initialising FloodProt...")
- stacktop=0
- stackend=0
- lasttime=0
- cb_active=
- 2floodprot_on=
- DB_ReadConfig("FloodProt_On"))
- 8floodprot_delay=
- DB_ReadConfig("FloodProt_Delay"))
- floodprot_delay<5
- floodprot_delay=33
- Pass on to the next module
- ******* Overloaded configuration options ********
- Give ourselves a sensible name
- Overload_ScriptInfo(num)
- ret$
- num=0
- # ret$="FloodProt v1.03 (Gerph)"
- ret$=
- @(num-1)
- # =ret$
- Overload the main transmit routine
- SendToIRC(a$)
- floodprot_on
- loc=
- Claim(8)
- No end, with data in
- !loc=0
- !(loc+4)=
- Strdup(a$)
- debug
- DisplayWarning("Stack>>"+a$,"##Debug##")
- stackend<>0
- Attach it to the end of the list
- !stackend=loc
- stackend=loc
- stacktop=0
- If nothing on stack, attach
- stacktop=loc
- Now to dispatch the message
- FloodProt_Dispatch
- @(a$)
- FloodProt_Dispatch
- now,a$,loc
- stacktop<>0
- "OS_ReadMonotonicTime"
- now-lasttime>floodprot_delay
- Interval has passed
- loc=stacktop
- a$=$(!(loc+4))
- stacktop=!loc
- stackend=loc
- stackend=0
- Release string
- Release(!(loc+4))
- Release the block
- Release(loc)
- SendString(MasterSocket,a$)
- debug
- R2
- DisplayWarning("Unstack<<"+a$,"##Debug##")
- lasttime=now
- stacktop<>0
- cb_active=
- X?
- AddCallBack("FloodProt",lasttime+floodprot_delay-now,0)
- cb_active=
- Overload the CallBack routine to trap the calls
- Overload_CallBack(name$,private)
- name$="FloodProt"
- cb_active=
- FloodProt_Dispatch
- @(name$,private)
- ****************** Configuration options *******************
- Enumerate module names
- Overload_ConfigModName(count)
- ret$
- count=0
- ret$="FloodProt"
- ret$=
- @(count-1)
- r =ret$
- What options do we provide ?
- Overload_ConfigOptions(module$)
- module$="FloodProt"
- DisplayConfig("")
- DisplayConfig("-- FloodProt configuration --")
- DisplayConfig("You can configure :")
- DisplayConfig(" Prot <boolean> : Whether the protection is active")
- DisplayConfig(" Delay <time> : Delay in centi-seconds")
- @(module$)
- How do we configure things
- Overload_ConfigCommand(module$,com$,str$)
- module$="FloodProt"
- com$
- "DELAY"
- (str$)<5
- .
- DisplayConfig("Syntax: Delay <time>")
- floodprot_delay=
- (str$)
- <
- DB_WriteConfig("FloodProt_Delay",
- floodprot_delay)
- 9
- DisplayConfig("Set Delay to "+
- floodprot_delay)
- "PROT"
- var=
- boolean(str$)
- var
- 0,-1
- floodprot_on=var
- 9
- DB_WriteConfig("FloodProt_Prot",
- floodprot_on)
- ?
- DisplayConfig("Set Prot to "+
- booltext(floodprot_on))
- 1
- DisplayConfig("Syntax: Prot <boolean>")
- "LIST"
- DisplayConfig("")
- DisplayConfig("Prot : "+
- booltext(floodprot_on))
- DisplayConfig("Delay : "+
- floodprot_delay+"cs")
- "HELP"
- Overload_ConfigOptions(module$)
- DisplayConfig("Command not recognised")
- @(module$,com$,str$)
-