Пример #1
0
def send_message_out(message):
    print "[%s] Processing message %s" % (str(datetime.now()), message.text)
    msg = [(message.urn, message.text)]
    y = YowsupSendStack(msg)
    y.start()
    message.status = Message.SENT
    message.save()
Пример #2
0
def push_out(messages=None, limit=30):
    if not messages:
        messages = Message.objects.filter(status=Message.QUEUED, direction=Message.OUTGOING).order_by('created_on')[
                   :limit]
    else:
        messages = Message.objects.filter(pk__in=messages)
    msg = list(messages.values_list('urn', 'text'))
    y = YowsupSendStack(msg)
    y.start()
    messages.update(status=Message.SENT)
Пример #3
0
def push_out(limit=30):
    messages = Message.objects.filter(direction=Message.OUTGOING, status=Message.QUEUED).order_by('created_on')

    # somebody already handled these messages, move on
    if not messages:
        logger.debug("No more messages, now taking a 10 second nap")
        return

    for message in messages:
        logger.debug("[%s] Processing message %s" % (str(datetime.now()), message.text))
        msg = [(message.urn, message.text)]
        y = YowsupSendStack(msg)
        y.start()
        message.status = Message.SENT
        message.save()
        logger.debug("Message sent, now taking a 2 seconds nap")
Пример #4
0
def push_out(limit=30):
    messages = Message.objects.filter(
        direction=Message.OUTGOING,
        status=Message.QUEUED).order_by('created_on')

    # somebody already handled these messages, move on
    if not messages:
        logger.debug("No more messages, now taking a 10 second nap")
        return

    for message in messages:
        logger.debug("[%s] Processing message %s" %
                     (str(datetime.now()), message.text))
        msg = [(message.urn, message.text)]
        y = YowsupSendStack(msg)
        y.start()
        message.status = Message.SENT
        message.save()
        logger.debug("Message sent, now taking a 2 seconds nap")
Пример #5
0
    def handle(self, *args, **options):
        messages = Message.objects.filter(direction=Message.OUTGOING, status=Message.QUEUED).order_by('created_on')[:6]

        # somebody already handled these messages, move on
        if not messages:
            print "No more messages"
            return

        for message in messages:
            try:
                print "[%s] Processing message %s" % (str(datetime.now()), message.text)
                msg = [(message.urn, message.text)]
                y = YowsupSendStack(msg)
                y.start()
            except KeyboardInterrupt:
                message.status = Message.SENT
                message.save()
                print "Message sent to %s" % message.urn
                continue
            except Exception as e:
                message.status = Message.SENT
                message.save()
                print "Message message to %s failed: %s" % (message.urn, str(e))