Discussion:
[asterisk-users] how to strip + from the caller-ID
Szasz Szabolcs
2010-01-14 09:55:15 UTC
Permalink
Hi,

How can I strip + from the front of the caller ID?
I have tried this:
exten => s/_+X.,1,Set(CALLERID(name)=${CALLERID(name):1})

But it is not working.


Szasz Szabolcs
Leif Madsen
2010-01-14 13:52:23 UTC
Permalink
Post by Szasz Szabolcs
How can I strip + from the front of the caller ID?
exten => s/_+X.,1,Set(CALLERID(name)=${CALLERID(name):1})
But it is not working.
I thought that worked, but I haven't tested it in quite some time.

How about setting the value to a temporary variable, then stripping from that
when you reassign it to CALLERID() ?

Also, you're using name, and I think you meant CALLERID(num)?

exten => s/_+X.,1,Set(TMP_CID_NUM=${CALLERID(num)})
exten => s/_+X.,n,Set(CALLERID(num)=${TMP_CID_NUM:1})

Leif Madsen.
Danny Nicholas
2010-01-14 14:11:35 UTC
Permalink
I saw something like this in another answer, but here's an example that
should work (would on 1.4)

exten => s/_+X.,1,Set(TMPNAME=${CALLERID(name)})

exten => s/_+X.,n,Set(CLEANNAME=CUT(TMPNAME|\+|2))

exten => s/_+X.,n,Set(CALLERID(name)=${CLEANNAME})



in my installations ${X:1} is a hit or miss proposition; CUT is a Known
quantity.



_____

From: asterisk-users-***@lists.digium.com
[mailto:asterisk-users-***@lists.digium.com] On Behalf Of Szasz Szabolcs
Sent: Thursday, January 14, 2010 3:55 AM
To: asterisk-***@lists.digium.com
Subject: [asterisk-users] how to strip + from the caller-ID



Hi,

How can I strip + from the front of the caller ID?
I have tried this:
exten => s/_+X.,1,Set(CALLERID(name)=${CALLERID(name):1})

But it is not working.


Szasz Szabolcs
David Kerr
2010-01-14 20:46:00 UTC
Permalink
Are you actually trying to strip off the + or are you doing it as part of
trying to check the callerid number to see if it is valid. If the later,
then consider REGEX()... here is a snippet from my privacy manager script...

; First lookup number in asterisk DB for a Caller ID name. exten =
s,n,Set(CALLERID(name)=${IF(${DB_EXISTS(cidname/${CALLERID(num)})}?${DB_RESULT}:${CALLERID(name)})})
; Now check against whitelist. exten =
s,n,GotoIf(${DB_EXISTS(whitelist/${CALLERID(num)})}?onwhitelist) ; Not on
whitelist, check it against blacklist exten =
s,n,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?onblacklist) ; Not on
blacklist either, check Caller ID number for anonymous conditions... ; If
all zeros (with or without international dialing + sign) then caller is
anonymous. exten = s,n,GotoIf($[${REGEX("^[+]?0+$" ${CALLERID(num)})} =
1]?unknown) ; If Caller ID is not a number at least 4 digits long (with or
without + sign) ; then caller is assumed to be anonymous. Alphabetic Caller
ID "numbers" ; will therefore be considered anonymous. Common numbers for
anonymous callers ; are: "asterisk, unknown, anonymous, private,
unavailable" which may be upper, lower ; or mixed case. The regular
expression catches everything non-numeric. ; If you want to permit a
specific non-numeric Caller ID "number" add it to whitelist. exten =
s,n,GotoIf($[${REGEX("^[+]?[0-9]{4\,}$" ${CALLERID(num)})} != 1]?unknown) ;
Caller ID looks good.
I saw something like this in another answer, but here’s an example that
should work (would on 1.4)
exten => s/_+X.,1,Set(TMPNAME=${CALLERID(name)})
exten => s/_+X.,n,Set(CLEANNAME=CUT(TMPNAME|\+|2))
exten => s/_+X.,n,Set(CALLERID(name)=${CLEANNAME})
in my installations ${X:1} is a hit or miss proposition; CUT is a Known
quantity.
------------------------------
*Sent:* Thursday, January 14, 2010 3:55 AM
*Subject:* [asterisk-users] how to strip + from the caller-ID
Hi,
How can I strip + from the front of the caller ID?
exten => s/_+X.,1,Set(CALLERID(name)=${CALLERID(name):1})
But it is not working.
Szasz Szabolcs
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-users mailing list
http://lists.digium.com/mailman/listinfo/asterisk-users
joern
2010-01-15 11:02:50 UTC
Permalink
Post by Szasz Szabolcs
Hi,
How can I strip + from the front of the caller ID?
exten => s/_+X.,1,Set(CALLERID(name)=${CALLERID(name):1})
Hi,

what about:
exten => _+[1-9].,1,Dial(Local/${EXTEN:1}@context
to proceed your call without leading "+" in your dialplan?

Cheers
Joern

Loading...