%
% retrieve image(s) from url(s) within Twilio MMS message
%
% stack: msg-xml dest-spec
%
!Twi.Dest
empty !Shooter.AdjCap
false !Shooter.Baby
_Twi
"setwi" log)(
dup !Shooter.Twi
"Mode" *aamgnums
empty !builder
%
% extract extra information Tem/Prod ranks
%
empty !Msg.extra
dup "" right$
any?
{
"" left$ !Msg.extra
} if
%
% record the ranks defaulting to zero
%
% extract the images from mms message
%
"" right$
"" slice
exch dup !Twi.NumMedia
countup
{
- dup !idxr
^"" right$
"<" slicex "Twi.MMType" &_idxr !
">" right$
"" right$
"<" slicex hex2asc
"Twi.MMUrl" &_idxr !
">" right$
_builder
"Twi.MMType" &_idxr sval
"Twi.MMUrl" &_idxr sval
!builder
} for
pop
_builder
"Twi.NumMedia" sval
"Msg.extra" sval
"_twi" text!bin
%
% response.txt in connector has response of tell
%
empty !Twi.MMlog
_Twi.NumMedia countup
{
- !idxr
"geturl&format="
"Twi.MMType" _idxr & _ "jpeg" found)?
{
"jpg" dup !Twi.MMx &
}
{
"png" dup !Twi.MMx &
} ifelse
&"&body="
"Twi.MMUrl" _idxr & _
asc2hex &
&"&dest="
_Twi.Dest
*smsdecod
_Shooter.Subject ^"+1" !Sms.From
%
% decode and remove phosend routing message
%
*fuplrtep
_Fup.Msg dup !Shooter.AdjCap
">>>?>>v>?" &_Fup.PhoSend log)(
%
% in twiltemd the decision is made for tem assignment
%
*custxcap
60 left
%
% create a route back based on message xact
%
&" "
_Fup.PhoSend
{
&_Msg.xact
&_Shooter.Subject &"*"
dup logs
asc2hex
}
{
} ifelse
exch
&_Shooter.Tem
&"_" &_Twi
&"_" &_Shooter.Color
&"_" &_Arching.Vtype
&"_" ^
&"_" &_Shooter.Crop
dup &"." &_Twi.MMx !Twi.Mfile
asc2hex
&
dup logs
"Local" *webtelln
"response" text_conn &:Twi.MMlog
_Twi.Mfile exists
{
}
{
"Error* no file" &:Twi.MMlog
} ifelse
} for
_Twi.MMlog
"Error*" found? dup !Twi.Error
{
}
{
*twilimgu
/*
_Arching.Atype
">>>?>>>?" log)(
<
|PhoSend
*twilimgu
> not
{
*smsdecod 1 right "*" eq$
_Shooter.Baby or
{
}
{
"Mtext" *aamgnums
_Msg.Thank
"cvp" log)(
*twilrcvd
} ifelse
} if
*/
} ifelse
_Twi.Dest &"_" +mcounter 3 prezero & &".log"
write