// Versioning should following the semantic versioning guidelines outlined here: http://semver.org/ define('USER_AGENT', 'User-Agent: locationbot/' . VERSION . ' by ianp'); require_once 'reddit.php'; // Methods for Authentication, Getting Posts, and Posting require_once 'data.php'; // Simple factory for getting a database connection. require_once 'credentials.php'; // Credentials for the database and user. require_once 'action.php'; // Action to take when we post a reply. require_once 'mention_action.php'; // Action to take when our name is mentioned. // Start doing "bot" stuff. $data_connection = Data::GetConnection(); $reddit = new Reddit(REDDIT_USERNAME, REDDIT_PASSWORD); $reddit->Login(); // Get collections of subreddits that we should be monitoring. $query = "SELECT rec_id, name FROM Subreddit WHERE active=1"; $result = $data_connection->query($query); $subreddit = array(); while ($row = $result->fetch_assoc()) { $subreddit[$row['name']] = $row['rec_id']; } // Get list of locations that we should look for. $query = "SELECT name FROM Location"; $result = $data_connection->query($query); $location = array(); while ($row = $result->fetch_assoc()) { array_push($location, "\\b({$row['name']})\\b"); } // Create a regular expression based on the locations array.