Exemplo n.º 1
0
 function process_query($twitter_query)
 {
     if ($this->debug) {
         echo "Processing query {$twitter_query}<br/>";
     }
     $twitter_query = trim(str_replace("@twitlookup", "", $twitter_query));
     $lookup_object = ActionFactory::get_lookup_object($twitter_query, "twitter");
     $type = $lookup_object->get_type();
     if ($this->debug) {
         echo "Type: {$type}<br/>";
     }
     $actual_search_term = $lookup_object->get_actual_search_term();
     if ($this->debug) {
         echo "Getting message<br/>";
     }
     $message = $this->get_message($lookup_object);
     if ($this->debug) {
         echo "<b>Message is</b> {$message}<br/>";
     }
     if ($message) {
         if (is_array($message)) {
             foreach ($message as $mess) {
                 $mess = trim($lookup_object->get_hash_tags . " " . $mess);
                 echo "{$mess}<br/>";
             }
         } else {
             $message = trim($lookup_object->get_hash_tags . " " . $message);
             echo "{$message}<br/>";
         }
     }
     $message = "";
     unset($lookup_object);
 }
Exemplo n.º 2
0
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
* 
*****/
require_once "class.ActionFactory.php";
$search_phrase = $_REQUEST['msg'];
$lookup_object = ActionFactory::get_lookup_object($search_phrase, "cricket");
echo "SEARCH PHRASE " . $search_phrase . "<br>";
$type = $lookup_object->get_type();
echo "TYPE " . $type . "<br>";
switch ($type) {
    case "cricket":
        perform_cricket_search($lookup_object);
        break;
    case "help":
        echo $lookup_object->the_output();
        break;
    case "credits":
        echo $lookup_object->the_output();
        break;
    default:
        $lookup_object = new DefaultLookup($search_phrase, "cricket");
Exemplo n.º 3
0
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
* 
*****/
require_once "class.ActionFactory.php";
$search_phrase = $_REQUEST['msg'];
$lookup_object = ActionFactory::get_lookup_object($search_phrase, "twitter");
$type = $lookup_object->get_type();
echo "<a href='form.php'>NEXT SEARCH</a><br />";
echo get_output($lookup_object);
unset($lookup_object);
function get_output($lookup_object)
{
    $got_errors = false;
    if ($lookup_object->is_ready() && $lookup_object->is_search()) {
        $got_results = $lookup_object->_perform();
        if ($got_results) {
            $defintions = $lookup_object->the_output();
            if (is_array($defintions)) {
                //Util::print_array($defintions);
                if ($defintions[$lookup_object->get_type()]) {
                    foreach ($defintions[$lookup_object->get_type()] as $defi) {
Exemplo n.º 4
0
 function process_query($status_id, $twitter_query, $twitter_user_id, $twitter_screen_name, $direct_message = false)
 {
     //moron caller you should have taken a break, go f**k yourself now
     if ($this->take_a_break && !$this->debug) {
         return;
     }
     if ($twitter_screen_name == ME) {
         return;
     }
     //have we replied to this message already, if so flag to terminate request
     if (!$this->debug || $this->send) {
         if ($this->is_replied($status_id)) {
             $this->take_a_break = true;
             return;
         }
     }
     if ($this->debug) {
         echo "Processing {$status_id} from {$twitter_user_id} for quert {$twitter_query}<br>";
     }
     $internal_user_id = $this->twitter_user_info($twitter_user_id, $twitter_screen_name);
     if (!$internal_user_id) {
         if ($this->debug) {
             echo "user is blocked or something wrong with registration code<br>";
         }
         //TODO log this request
         return;
     }
     $twitter_query = trim(str_replace("@twitlookup", "", $twitter_query));
     $lookup_object = ActionFactory::get_lookup_object($twitter_query, "twitter");
     $type = $lookup_object->get_type();
     if ("default" == $type) {
         return;
     }
     if ($this->debug) {
         echo "Type: {$type}<br>";
     }
     $actual_search_term = $lookup_object->get_actual_search_term();
     if ($this->debug) {
         echo "Getting message<br>";
     }
     $message = $this->get_message($lookup_object);
     if ($this->debug) {
         echo "<b>Message is</b> {$message}<br>";
     }
     if ($message) {
         if (!$this->debug || $this->send) {
             $this->add_stats($internal_user_id, $status_id, $twitter_query, $this->messagestatus, $direct_message);
         }
         if ($this->debug) {
             echo "added status<br>";
         }
         if (is_array($message)) {
             foreach ($message as $mess) {
                 if (!$this->debug || $this->send) {
                     if ($this->debug) {
                         echo "SENDING Message NOw<br>";
                     }
                     $mess = trim($lookup_object->get_hash_tags . " " . $mess);
                     if ($direct_message) {
                         $response = $this->send_message($this->prepare_message($mess, $twitter_screen_name, true), $twitter_user_id);
                     } else {
                         $response = $this->update_status($this->prepare_message($mess, $twitter_screen_name));
                     }
                     if ($this->debug) {
                         echo $response->getData();
                     }
                 }
                 if ($this->debug) {
                     echo "DM: {$direct_message} sending message {$mess}<br><br>{$response}";
                 }
             }
         } else {
             if (!$this->debug || $this->send) {
                 if ($this->debug) {
                     echo "SENDING Message NOw<br>";
                 }
                 $message = trim($lookup_object->get_hash_tags . " " . $message);
                 if ($direct_message) {
                     $response = $this->send_message($this->prepare_message($message, $twitter_screen_name, true), $twitter_user_id);
                 } else {
                     $response = $this->update_status($this->prepare_message($message, $twitter_screen_name));
                 }
                 if ($this->debug) {
                     echo $response->getData();
                 }
             }
             if ($this->debug) {
                 echo "DM: {$direct_message} sending message {$message}<br><br>{$response}";
             }
         }
     }
     $message = "";
     unset($lookup_object);
 }
Exemplo n.º 5
0
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*      http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
* 
*****/
require_once "class.ActionFactory.php";
$search_phrase = $_REQUEST['msg'];
$lookup_object = ActionFactory::get_lookup_object($search_phrase, "dictbot");
$type = $lookup_object->get_type();
switch ($type) {
    case "dictionary":
        perform_dict_search($lookup_object);
        break;
    case "help":
        echo $lookup_object->the_output();
        break;
    case "credits":
        echo $lookup_object->the_output();
        break;
    default:
        $lookup_object = new DefaultLookup($search_phrase, "dictbot");
        echo $lookup_object->the_output();
        break;