function processContent($tweet) { global $preferences; // get the type of content (book/movie/etc) $type = $tweet->information->contenttype; // see if we can find any other information $amount = $tweet->information->amount; $title = $tweet->information->title; // default our amount, if there's none specified if ($amount == 0) { $amount = $preferences->TARGETS[$type]; } // if ammount is still zero, something went wrong! if ($amount == 0) { loginfo("something went wrong processing content : " . $tweet->text); return; } // return something nice $replyoptions = array('book' => "read {$amount} pages of " . ($title ? $title : "a book"), 'film' => "watched {$amount} minutes of " . ($title ? $title : "a film")); $replystring = $replyoptions[$type] . ($tweet->information->language ? " in " . $tweet->information->language['Name'] : "") . "."; // increment the content in the database insertActionRecord($tweet->id_str, $preferences->ACTIONS[$type], $tweet->entryid, $amount, $title); incrementEntryRecord($tweet->entryid, $preferences->ENTRYCONTENT[$type], $amount); // can be used to return the total amount // say something nice to the person replyTweet($tweet, $replystring); }
function incrementMinutesWatched($actionid, $entryid, $minutes, $title = "") { insertActionRecord($actionid, 'inc_minuteswatched', $entryid, $minutes, $title); return incrementEntryRecord($entryid, 'MinutesWatched', $minutes); }