Need a simple plan to block incoming via area code

Catalog of dial plans
Post Reply
mrdally204
Posts: 47
Joined: Thu Jan 31, 2008 12:25 pm

Need a simple plan to block incoming via area code

Post by mrdally204 » Wed May 11, 2011 4:45 am

Hello,
set up a sipgate DID and am getting spam calls from the 415 area code. I assume they are trying to reach the former renter of this line. What is the most basic dial plan I can have to simply block the 415 area code and allow all others to pass? Please and thank you!

mnipp
Posts: 192
Joined: Sat Oct 03, 2009 9:48 am
Location: NSW Australia

Re: Need a simple plan to block incoming via area code

Post by mnipp » Wed May 11, 2011 10:29 am

This a example of an inplan that can be used to block numbers and late night calling viewtopic.php?f=5&t=1901

Code: Select all

    # your INCOMING call processing.

# read Time
Tz = +11                      # Time zone (GMT+10)Sydney AEST time change to (+11 ADST for daylight saving time)
t = Time.now.utc + (Tz*60*60) # Get current time in utc+0 and adjust to sydney time utc+10(or utc+11).
sys.Log(t.strftime('Local time: %c')) # log time
hhmm = t.strftime("%H%M")

starttime = '0800'   #  8:00am(0800) to 
stoptime  = '2330'   # 11:30pm(2330) 24 hour time 

openhours = stoptime < starttime ? !((stoptime...starttime) === hhmm) : (starttime...stoptime) === hhmm

 # BLACKLIST of unwanted Callers
       case req.Header.from.FromURI.User.to_s
         when /^415\d{7}/ then sys.Respond(403, "Forbidden")   # block calls from (415)xxxxxxx example
       end

 # WHITELIST of Important  Callers
     case req.Header.from.FromURI.User.to_s
       when '0288888888' then openhours = true   #  0288888888 example can call you anytime.
       when '0377777777' then openhours = true   #  so can 0377777777 example
       when /^0266/ then openhours = true        #  so can local numbers starting with 0266..... example
     end

if sys.IsAvailable() and openhours then    # if online and not midnight

    sys.Dial("#{req.URI.User}@local",60)   # ring your phone for 60 seconds
    sys.Respond(480, "(#{req.URI.User}) Not Available") # response if not answered.
    
else 
    sys.Respond(480, "(#{req.URI.User}) Not Available") if openhours   # response if phone is not online.
   
    hhmm = t.strftime("%I:%M %p")          # Time (HH:MM AM) format
    sys.Respond(480, "(#{hhmm})I'm asleep,call later")                 # response if middle of night.
end
A more basic plan to block numbers

Code: Select all

    # your INCOMING call processing.

# BLACKLIST of unwanted Callers
  case req.Header.from.FromURI.User.to_s
     when /^415\d{7}/ then sys.Respond(403, "Forbidden")   # block calls from (415)xxxxxxx example
  end

sys.Dial("#{req.URI.User}@local",60)   # ring your phone for 60 seconds
sys.Respond(480, "(#{req.URI.User}) Not Available") # response if not answered.

billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)

mrdally204
Posts: 47
Joined: Thu Jan 31, 2008 12:25 pm

Re: Need a simple plan to block incoming via area code

Post by mrdally204 » Wed May 11, 2011 9:30 pm

Thankyou for the simple plan. I will insert it to mine and let you know. Will this block 1415 as well as 415 (I'm not exactly sure how the digits are presented at the moment)

mnipp
Posts: 192
Joined: Sat Oct 03, 2009 9:48 am
Location: NSW Australia

Re: Need a simple plan to block incoming via area code

Post by mnipp » Wed May 11, 2011 9:50 pm

Remove the "start of number(^)" to match 415xxxxxxx in the middle as well as the start of a number.

Code: Select all

     when /415\d{7}/ then sys.Respond(403, "Forbidden")   # block calls from (415)xxxxxxx example
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)

Post Reply