def send(self, to, from_, body, to_country=None, from_country=None):
        """
        Send properly-formatted numbers to FreeSwitch
        """
	# Internally, our canonical format is E.164 without the leading plus
	# (due to OpenBTS's inability to handle the + symbol).
        if (to_country):
            to = vbts_util.convert_to_e164(to, to_country)
        if (from_country):
            from_ = vbts_util.convert_to_e164(from_, from_country)
        to = vbts_util.strip_number(to)
        from_ = vbts_util.strip_number(from_)
        return self._send_raw_to_freeswitch(to, from_, body)
Esempio n. 2
0
 def send(self, to, from_, body, to_country=None, from_country=None):
     """
     Send properly-formatted numbers to FreeSwitch
     """
     # Internally, our canonical format is E.164 without the leading plus
     # (due to OpenBTS's inability to handle the + symbol).
     if (to_country):
         to = vbts_util.convert_to_e164(to, to_country)
     if (from_country):
         from_ = vbts_util.convert_to_e164(from_, from_country)
     to = vbts_util.strip_number(to)
     from_ = vbts_util.strip_number(from_)
     return self._send_raw_to_freeswitch(to, from_, body)
    def send(self, to, from_, body, to_country="US", from_country="US"):
        """
        Send an SMS to Twilio. Returns true if the message was accepted, false otherwise.
        """
        # Clean up the to number before we send it out.  We always add a plus, and
        # libphonenumber is smart enough to sort it out from there (even if there's
        # already a plus).
        to = vbts_util.convert_to_e164("+" + to, None)

        # Our callerid is always in E.164.
        from_ = vbts_util.convert_to_e164(from_, from_country)
        try:
            message = self.twilio_client.sms.messages.create(to=to, from_=from_, body=body)
        except twilio.TwilioRestException:
            return False
        if message.status != "failed":
            # We consider it a success if Twilio reports message is queued,
            # sending, or sent.
            return True
        return False
Esempio n. 4
0
    def send(self, to, from_, body, to_country="US", from_country="US"):
        """
        Send an SMS to Twilio. Returns true if the message was accepted, false otherwise.
        """
        # Clean up the to number before we send it out.  We always add a plus, and
        # libphonenumber is smart enough to sort it out from there (even if there's
        # already a plus).
        to = vbts_util.convert_to_e164("+" + to, None)

        # Our callerid is always in E.164.
        from_ = vbts_util.convert_to_e164(from_, from_country)
        try:
            message = self.twilio_client.sms.messages.create(to=to,
                                                             from_=from_,
                                                             body=body)
        except twilio.TwilioRestException:
            return False
        if message.status != "failed":
            # We consider it a success if Twilio reports message is queued,
            # sending, or sent.
            return True
        return False
    def send(self, to, from_, body, to_country=None, from_country=None):
        """
        Send an SMS to Nexmo. Returns true if the message was accepted, false otherwise.
        """
        # Convert "to" to e.164 format. We always add a plus, and
        # libphonenumber is smart enough to sort it out from there (even if
        # there's already a plus).
        to = vbts_util.convert_to_e164("+" + to, None)

        msg = {'reqtype': 'json', 'password': self.pw, 'from': from_, 'to': to, 'username': self.un}
        sms = NexmoMessage(msg)
        sms.set_text_info(body)
        res = sms.send_request()
        #we're basically creating aformatting AND here for readability
        if (res['message-count'] == '1'):
            if (res['messages'][0]['status'] == '0'):
                return True
        return False