Re: [asterisk-users] Get context with hangup handler

2022-01-09 Thread Dovid Bender
It seems like this would work and I appreciate the code but I doubt it
would make it into the main branch. I think I am stuck with setting it in
the context.


On Thu, Jan 6, 2022 at 8:26 AM  wrote:

> I'm not sure what other implications this might have, but does something
> like this work for you? You would need to apply the following patch[1].
>
> Manually trying to save the last context/exten/etc. in the dialplan itself
> is guaranteed to be an ugly solution. Let Asterisk do it for you.
>
> [f1]
> exten => s,1,NoOp(${CONTEXT})
> same => n,NoOp(${CONTEXT} / ${LASTCONTEXT})
> same => n,Goto(f2,s,1)
> [f2]
> exten => s,1,NoOp(${CONTEXT} / ${LASTCONTEXT})
> same => n,NoOp(${CONTEXT} / ${LASTCONTEXT})
> same => n,Hangup()
>
> pbxdev*CLI> channel originate Local/s@f1 application Wait 30
> [Jan  6 08:19:30] -- Called s@f1
> [Jan  6 08:19:30] -- Executing [s@f1:1] NoOp("Local/s@f1-0002;2",
> "f1") in new stack
> [Jan  6 08:19:30] -- Executing [s@f1:2] NoOp("Local/s@f1-0002;2",
> "f1 / ") in new stack
> [Jan  6 08:19:30] -- Executing [s@f1:3] Goto("Local/s@f1-0002;2",
> "f2,s,1") in new stack
> [Jan  6 08:19:30] -- Goto (f2,s,1)
> [Jan  6 08:19:30] -- Executing [s@f2:1] NoOp("Local/s@f1-0002;2",
> "f2 / f1") in new stack
> [Jan  6 08:19:30] -- Executing [s@f2:2] NoOp("Local/s@f1-0002;2",
> "f2 / f1") in new stack
> [Jan  6 08:19:30] -- Executing [s@f2:3] Hangup("Local/s@f1-0002;2",
> "") in new stack
> [Jan  6 08:19:30]   == Spawn extension (f2, s, 3) exited non-zero on
> 'Local/s@f1-0002;2'
>
> [1] https://code.phreaknet.org/asterisk/lastcontext.diff
> On 1/5/2022 10:22 PM, Dovid Bender wrote:
>
> Steve,
>
> I thought of this but that would mean I would need to add this to the
> beginning of every context which I can do, but I was trying to avoid.
>
>
> On Wed, Jan 5, 2022 at 10:06 PM Steve Edwards 
> wrote:
>
>> On Wed, 5 Jan 2022, Steve Edwards wrote:
>>
>> >   same = n,   set(LAST-CONTEXT=${context}
>>
>> Double damn. I munged the case on ${CONTEXT}. I give up for today :)
>>
>> --
>> Thanks in advance,
>> -
>> Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
>>  https://www.linkedin.com/in/steve-edwards-4244281
>>
>> --
>> _
>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>>
>> Check out the new Asterisk community forum at:
>> https://community.asterisk.org/
>>
>> New to Asterisk? Start here:
>>   https://wiki.asterisk.org/wiki/display/AST/Getting+Started
>>
>> asterisk-users mailing list
>> To UNSUBSCRIBE or update options visit:
>>http://lists.digium.com/mailman/listinfo/asterisk-users
>
>
>
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Get context with hangup handler

2022-01-05 Thread Eric Wieling
This might not help, but you don't have to use different contexts when 
using GoSub, here is an example:  https://pastebin.com/ftwWwpKt


On 1/5/22 22:22, Dovid Bender wrote:

Steve,

I thought of this but that would mean I would need to add this to the 
beginning of every context which I can do, but I was trying to avoid.



On Wed, Jan 5, 2022 at 10:06 PM Steve Edwards > wrote:


On Wed, 5 Jan 2022, Steve Edwards wrote:

 >       same = n,                       set(LAST-CONTEXT=${context}

Double damn. I munged the case on ${CONTEXT}. I give up for today :)

-- 
Thanks in advance,

-
Steve Edwards sedwa...@sedwards.com  
     Voice: +1-760-468-3867 PST

https://www.linkedin.com/in/steve-edwards-4244281


-- 
_

-- Bandwidth and Colocation Provided by http://www.api-digital.com
 --

Check out the new Asterisk community forum at:
https://community.asterisk.org/ 

New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started


asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users





--
http://help.nyigc.net/

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
 https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Get context with hangup handler

2022-01-05 Thread Steve Edwards

On Wed, 5 Jan 2022, Dovid Bender wrote:

I thought of this but that would mean I would need to add this to the 
beginning of every context which I can do, but I was trying to avoid.


Every extension in every context.

Or maybe get funky with a wildcard extension with priority = 1 and 
starting all of your real extensions with priority = 3. Something like 
this (which uses gosub() just for ease of testing):


; test wildcard extension
same = n,   gosub(wildcard-extension,1234,1)
same = n,   gosub(wildcard-extension,s,1)
same = n,   gosub(wildcard-extension,testing,1)
same = n,   hangup()

[wildcard-extension]
; save the current context so it can be used in the hangup handler
exten = _!.,1,  verbose(1,[${EXTEN}@${CONTEXT}])
same = n,   set(LAST-CONTEXT=${CONTEXT})
same = 4,   return

; note all the 'real' extensions start with priority = 3
exten = 1234,3, 
verbose(1,[${EXTEN}@${CONTEXT}!${PRIORITY}])

exten = s,3,
verbose(1,[${EXTEN}@${CONTEXT}!${PRIORITY}])

exten = testing,3,  
verbose(1,[${EXTEN}@${CONTEXT}!${PRIORITY}])

; be explicit with 'h' so it doesn't get handled by the wildcard extension
exten = h,1,verbose(1,[${EXTEN}@${CONTEXT}])
same = n,   hangup()

Hopefully somebody else has a more elegant solution.

--
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
https://www.linkedin.com/in/steve-edwards-4244281

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
 https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Get context with hangup handler

2022-01-05 Thread Dovid Bender
Steve,

I thought of this but that would mean I would need to add this to the
beginning of every context which I can do, but I was trying to avoid.


On Wed, Jan 5, 2022 at 10:06 PM Steve Edwards 
wrote:

> On Wed, 5 Jan 2022, Steve Edwards wrote:
>
> >   same = n,   set(LAST-CONTEXT=${context}
>
> Double damn. I munged the case on ${CONTEXT}. I give up for today :)
>
> --
> Thanks in advance,
> -
> Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
>  https://www.linkedin.com/in/steve-edwards-4244281
>
> --
> _
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>
> Check out the new Asterisk community forum at:
> https://community.asterisk.org/
>
> New to Asterisk? Start here:
>   https://wiki.asterisk.org/wiki/display/AST/Getting+Started
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>http://lists.digium.com/mailman/listinfo/asterisk-users
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Get context with hangup handler

2022-01-05 Thread Steve Edwards

On Wed, 5 Jan 2022, Steve Edwards wrote:


same = n,   set(LAST-CONTEXT=${context}


Double damn. I munged the case on ${CONTEXT}. I give up for today :)

--
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
https://www.linkedin.com/in/steve-edwards-4244281

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
 https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Get context with hangup handler

2022-01-05 Thread Steve Edwards

On Wed, 5 Jan 2022, Steve Edwards wrote:


same = n,   set(LAST-CONTEXT=${context}


Damn. forgot the closing parentheses :)

--
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
https://www.linkedin.com/in/steve-edwards-4244281

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
 https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] Get context with hangup handler

2022-01-05 Thread Steve Edwards

On Wed, 5 Jan 2022, Dovid Bender wrote:

I have a hangup handler that's added at the beginning of a call. It logs 
all the call details. Using the CONTEXT variable I am always going to 
get the context where the code is being ran and not the last context 
that the caller is in. Is there any creative way to get the last context 
at the call was in?


At the start of each context/priority...

exten = ,1, verbose(1,[${EXTEN}@${CONTEXT}])
same = n,   set(LAST-CONTEXT=${context}

--
Thanks in advance,
-
Steve Edwards   sedwa...@sedwards.com  Voice: +1-760-468-3867 PST
https://www.linkedin.com/in/steve-edwards-4244281-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

[asterisk-users] Get context with hangup handler

2022-01-05 Thread Dovid Bender
Hi,

I have a hangup handler that's added at the beginning of a call. It logs
all the call details. Using the CONTEXT variable I am always going to get
the context where the code is being ran and not the last context that the
caller is in. Is there any creative way to get the last context at the call
was in?
-- 
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

Check out the new Asterisk community forum at: https://community.asterisk.org/

New to Asterisk? Start here:
  https://wiki.asterisk.org/wiki/display/AST/Getting+Started

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users