D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Asterisk - Blacklist wildcard by area code?

 

On Wed, 11 Jan 2012, Sam Grabham wrote:


Hi

Thanks Gordon

It was in bound sales pest phone calls, and the number had been TPS also.

Many thanks will give it a try.

Hang on - I'm looking at it from the wrong side. (I run an ITSP as part of what I do)

You want to block incoming calls based on partial callerID - then you need a little bit of code. The blacklist function just looks it up in the astdb - it's really just ashort-cut for looking it up yourself, you still need to do something with it - however blacklist() doesn't accept wildcards and there's no easy way to iterate over an entire family in the astdb in the dialplan. (There might be in AEL, but I've never had the need for AEL)


You could hard-code it (if editing the dialplan is your thing) which will work for a small number of cases but is unwieldly for more:

exten => s,n,Noop(Check for blacklisted numbers)

; Individual numbers:
; Those idiots at drogon systems:
exten => s,n,GotoIf(${CALLERID(num)}="01364698123"]?blocked)

; scummy 0845 callers
exten => s,n,GotoIf($[${REGEX("^0845" ${CALLERID(NUM)})}=1]?blocked)

; even scumier 0844 callers:
exten => s,n,GotoIf($[${REGEX("^0844" ${CALLERID(NUM)})}=1]?blocked)

...etc
exten => s,n,Noop(Number OK = ${CALLERID(num)})

...

exten => s,n(blocked),Noop(We're blocking a call from ${CALLERID(num)})
exten => s,n,Answer()
exten => s,n,Playback(weasels-have-eaten-the-staff)
exten => s,n,Hangup()

etc.

Another way might be to GOTO a new context based on the callerID, but I'm not sure if thats better/worse (or just silly!)

[incoming]
exten s,n,GOTO(test,${CALLERID(num)},1)

..

[test]

exten => _0845.,n,Noop(Blocking 0845)
..

exten => i,1,Noop(Not blocked)
exten => i,n,Goto(incoming2,s,1)

Gordon

Ps. For those who think this is a mess of {, [ and ('s then you're right. It is. It's a dreadful example of a "progrmaming language" designed by telephone engineers.

--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq