示例#1
0
function testAutoreply($selfurl)
{
    $form = new HTML_QuickForm('autoreply_test', 'post', "{$selfurl}&op=test");
    // Add some elements to the form
    $form->addElement('textarea', 'message', 'Test Message:');
    setupSmsCounting($form, 'message', null);
    $form->addElement('submit', 'submit', 'Test');
    if ($form->validate()) {
        $match = matchAutoreply($form->exportValue('message'), false);
        echo "<b>reply:</b> <br/>" . nl2br($match['autoreply_scenario_result']);
        exit;
    }
    $form->display();
}
示例#2
0
function processAutoreply($sms_datetime, $sms_sender, $message, $simple = true)
{
    global $datetime_now;
    // find the autoreply
    $match = matchAutoreply($message, $simple);
    if (!$match) {
        return false;
    }
    // save a log of the match
    $log = DB_DataObject::factory('playsms_featAutoreply_log');
    $log->sms_sender = $sms_sender;
    $log->autoreply_log_datetime = $datetime_now;
    $log->autoreply_log_code = $match['keywords'][0];
    $log->autoreply_log_request = $message;
    $ok = $log->insert();
    if (!$ok) {
        return $ok;
    }
    // send the autoreply
    $c_username = uid2username($match['uid']);
    $ok = websend2pv($c_username, $sms_sender, $match['autoreply_scenario_result']);
    if (!$ok) {
        return false;
    }
    // since unknown matches are
    // really error messages, we
    // count them as failures
    //
    if ($match[UNKNOWN]) {
        $ok = false;
    }
    return $ok;
}