/** * Get the responses of a plurk. This method will load "temporary" friends * who have responded to the plurk. * * @param int $int_plurk_id The plurk ID * * @return array The array of responses. */ function plurk_response_get($int_plurk_id) { $this->plurk_post($this->plurk_paths['plurk_response_get'], array('plurk_id' => $int_plurk_id)); $data = $this->plurk_response(); $string_response = $data['body']; $data = explode('"responses": ', $string_response); preg_match('/\\{"friends": \\{"\\d+": (.*)\\}, "responses/', $data[0], $local_friend); if (isset($local_friend[1])) { $temp_friends = array(); $each_friend_almost_json = preg_split('/\\}, "\\d+": \\{/', $local_friend[1]); foreach ($each_friend_almost_json as $friend_data) { if (substr($friend_data, 0, 1) != '{') { $friend_data = '{' . $friend_data; } if (substr($friend_data, strlen($friend_data) - 1, strlen($friend_data)) != '}') { $friend_data = $friend_data . '}'; } $temp_friends = array_merge($temp_friends, al_plurk_api::dejsonize($friend_data)); } $this->friends = array_merge($this->friends, $temp_friends); } $responses = array(); if (isset($data[1])) { $response_data = substr($data[1], 0, strlen($data[1]) - 1); $responses = al_plurk_api::dejsonize($response_data); foreach ($responses as &$each_response) { $each_response['nick_name'] = $this->uid_to_nickname($each_response['user_id']); } } return $responses; }
<?php /* * acebot.php -- a php plurk bot * * Copyright 2009 AceLan Kao(Chia-Lin Kao) * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive for * more details. */ require_once dirname(__FILE__) . '/../config.php'; require_once dirname(__FILE__) . '/../alplurkapi/al_plurk_api.php'; date_default_timezone_set('Asia/Taipei'); $plurk_api = new al_plurk_api($api_key); $plurk_api->login($username, $password); function help() { return; } function response_plurk($plurk) { global $plurk_api; if (preg_match("/^@acebot *: +(.+) +(.+) +(.+\$)/iU", $plurk['content_raw'], $match)) { if ($plurk['is_unread'] == 2) { // muted return; } $function_name = $match[1]; $plugin_filename = dirname(__FILE__) . '/plugin/' . $function_name . ".php"; if (file_exists($plugin_filename)) {