Exemplo n.º 1
0
 /**
  * Fetches data from $uri
  *
  * @param string $uri
  * @return string
  */
 protected function fetch($uri)
 {
     $this->bot->log("Fetching from URI: " . $uri);
     // create curl resource
     $ch = curl_init();
     // set url
     curl_setopt($ch, CURLOPT_URL, $uri);
     // Set a user agent. Some sites require it (e.g. GitHub API).
     curl_setopt($ch, CURLOPT_USERAGENT, 'WildPHP/IRCBot');
     //return the transfer as a string
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
     // $output contains the output string
     $output = curl_exec($ch);
     // close curl resource to free up system resources
     curl_close($ch);
     $this->bot->log("Data fetched: " . $output);
     return $output;
 }
Exemplo n.º 2
0
 /**
  * Sends PRIVMSG to source with $msg
  *
  * @param string $msg
  */
 protected function say($msg, $source)
 {
     $message = 'PRIVMSG ' . $source . ' :' . $msg;
     $this->connection->sendData($message);
     $this->bot->log($message, 'COMMAND');
 }