Permalink
Browse files

Merge branch 'master' of git://github.com/elazar/phergie

  • Loading branch information...
2 parents a92fa59 + 878fbdd commit 8eb11b77f68fb1b393adbc13215b2724c0ca5f21 @zburnham zburnham committed Apr 10, 2012
Showing with 7,687 additions and 1,571 deletions.
  1. +1 −1 LICENSE
  2. +23 −4 Phergie/Autoload.php
  3. +57 −12 Phergie/Bot.php
  4. +1 −1 Phergie/Config.php
  5. +1 −1 Phergie/Config/Exception.php
  6. +11 −8 Phergie/Connection.php
  7. +6 −6 Phergie/Connection/Exception.php
  8. +20 −16 Phergie/Connection/Handler.php
  9. +10 −8 Phergie/Driver/Abstract.php
  10. +3 −14 Phergie/Driver/Exception.php
  11. +86 −88 Phergie/Driver/Streams.php
  12. +5 −5 Phergie/Event/Abstract.php
  13. +1 −1 Phergie/Event/Command.php
  14. +1 −1 Phergie/Event/Exception.php
  15. +2 −2 Phergie/Event/Handler.php
  16. +175 −13 Phergie/Event/Request.php
  17. +4 −4 Phergie/Event/Response.php
  18. +4 −4 Phergie/Exception.php
  19. +11 −11 Phergie/Hostmask.php
  20. +4 −4 Phergie/Hostmask/Exception.php
  21. +30 −1 Phergie/Plugin/Abstract.php
  22. +3 −3 Phergie/Plugin/Acl.php
  23. +111 −0 Phergie/Plugin/Ai.php
  24. 0 Phergie/Plugin/Ai/Markov.class.php
  25. 0 Phergie/Plugin/Ai/Multi.class.php
  26. +86 −0 Phergie/Plugin/Ai/Pandora.class.php
  27. 0 Phergie/Plugin/Ai/markov.sql
  28. +9 −9 Phergie/Plugin/AltNick.php
  29. +20 −20 Phergie/Plugin/AudioScrobbler.php
  30. +14 −10 Phergie/Plugin/AutoJoin.php
  31. +2 −2 Phergie/Plugin/Beer.php
  32. BIN Phergie/Plugin/Beer/beer.db
  33. +61 −22 Phergie/Plugin/Beer/db.php
  34. +11 −11 Phergie/Plugin/BeerScore.php
  35. +17 −14 Phergie/Plugin/Cache.php
  36. +2 −2 Phergie/Plugin/Caffeine.php
  37. BIN Phergie/Plugin/Caffeine/caffeine.db
  38. +24 −6 Phergie/Plugin/Caffeine/db.php
  39. +16 −14 Phergie/Plugin/Censor.php
  40. +2 −2 Phergie/Plugin/Cocktail.php
  41. +41 −11 Phergie/Plugin/Cocktail/db.php
  42. +42 −3 Phergie/Plugin/Command.php
  43. +2 −2 Phergie/Plugin/Cookie.php
  44. +21 −6 Phergie/Plugin/Cookie/db.php
  45. +5 −5 Phergie/Plugin/Cron.php
  46. +1 −1 Phergie/Plugin/Ctcp.php
  47. +1 −1 Phergie/Plugin/Daddy.php
  48. +257 −0 Phergie/Plugin/Db.php
  49. +79 −0 Phergie/Plugin/Dice.php
  50. +32 −24 Phergie/Plugin/Encoding.php
  51. +1 −1 Phergie/Plugin/Exception.php
  52. +526 −0 Phergie/Plugin/FeedManager.php
  53. +179 −0 Phergie/Plugin/FeedParser.php
  54. +459 −0 Phergie/Plugin/FeedTicker.php
  55. +14 −12 Phergie/Plugin/Google.php
  56. +13 −12 Phergie/Plugin/Handler.php
  57. +5 −8 Phergie/Plugin/Help.php
  58. +3 −3 Phergie/Plugin/Http.php
  59. +2 −2 Phergie/Plugin/Http/Response.php
  60. +12 −11 Phergie/Plugin/Ideone.php
  61. +4 −4 Phergie/Plugin/Invisible.php
  62. +1 −1 Phergie/Plugin/Iterator.php
  63. +9 −5 Phergie/Plugin/Join.php
  64. +46 −36 Phergie/Plugin/Karma.php
  65. BIN Phergie/Plugin/Karma/karma.db
  66. +58 −35 Phergie/Plugin/Lart.php
  67. +21 −9 Phergie/Plugin/Message.php
  68. +178 −178 Phergie/Plugin/NickServ.php
  69. +4 −4 Phergie/Plugin/Part.php
  70. +14 −9 Phergie/Plugin/Php.php
  71. +33 −0 Phergie/Plugin/Php/Exception.php
  72. +9 −9 Phergie/Plugin/Php/Source.php
  73. +33 −0 Phergie/Plugin/Php/Source/Exception.php
  74. +59 −33 Phergie/Plugin/Php/Source/Local.php
  75. BIN Phergie/Plugin/Php/functions.db
  76. +2 −11 Phergie/Plugin/Ping.php
  77. +5 −5 Phergie/Plugin/Pong.php
  78. +9 −9 Phergie/Plugin/Prioritize.php
  79. +4 −4 Phergie/Plugin/Puppet.php
  80. +8 −3 Phergie/Plugin/Quit.php
  81. +25 −8 Phergie/Plugin/Reload.php
  82. +2 −2 Phergie/Plugin/Remind.php
  83. +9 −8 Phergie/Plugin/Serve.php
  84. +1 −1 Phergie/Plugin/SpellCheck.php
  85. +2 −2 Phergie/Plugin/Tea.php
  86. +21 −6 Phergie/Plugin/Tea/db.php
  87. +3 −2 Phergie/Plugin/Temperature.php
  88. +2 −2 Phergie/Plugin/TerryChay.php
  89. +1 −1 Phergie/Plugin/TheFuckingWeather.php
  90. +7 −7 Phergie/Plugin/Time.php
  91. +10 −10 Phergie/Plugin/Tld.php
  92. +23 −4 Phergie/Plugin/Tld/db.php
  93. +79 −71 Phergie/Plugin/Twitter.php
  94. +47 −10 Phergie/Plugin/Twitter/laconica.class.php
  95. +182 −57 Phergie/Plugin/Twitter/twitter.class.php
  96. +158 −147 Phergie/Plugin/Url.php
  97. +30 −6 Phergie/Plugin/Url/Shorten/Abstract.php
  98. +15 −7 Phergie/Plugin/Url/Shorten/{Trim.php → Isgd.php}
  99. +58 −31 Phergie/Plugin/UserInfo.php
  100. +216 −64 Phergie/Plugin/Weather.php
  101. +2 −2 Phergie/Plugin/Wine.php
  102. +30 −8 Phergie/Plugin/Wine/db.php
  103. +12 −12 Phergie/Plugin/Youtube.php
  104. +2 −2 Phergie/Process/Abstract.php
  105. +21 −15 Phergie/Process/Async.php
  106. +4 −4 Phergie/Process/Exception.php
  107. +1 −1 Phergie/Process/Standard.php
  108. 0 Phergie/Tools/LogViewer/INSTALL
  109. +133 −85 Phergie/Tools/LogViewer/index.php
  110. 0 Phergie/Tools/README
  111. +16 −16 Phergie/Ui/Abstract.php
  112. +24 −24 Phergie/Ui/Console.php
  113. +82 −31 PhergiePackageTask.php
  114. +1 −1 README
  115. +1 −1 Settings.php.dist
  116. +4 −0 Tests/Phergie/Autoload/_ClassNotInFileTest/Phergie/Missing/Class.php
  117. +7 −0 Tests/Phergie/Autoload/_ExistingClassesTest/Phergie/Valid/Class.php
  118. +7 −0 Tests/Phergie/Autoload/_ExistingClassesTest/Phergie/Valid/Interface.php
  119. +103 −22 Tests/Phergie/AutoloadTest.php
  120. +500 −0 Tests/Phergie/BotTest.php
  121. +19 −5 Tests/Phergie/ConfigTest.php
  122. +219 −0 Tests/Phergie/Connection/HandlerTest.php
  123. +5 −4 Tests/Phergie/ConnectionTest.php
  124. +81 −0 Tests/Phergie/Driver/AbstractTest.php
  125. +1,004 −0 Tests/Phergie/Driver/StreamsTest.php
  126. +1 −1 Tests/Phergie/Event/AbstractTest.php
  127. +1 −1 Tests/Phergie/Event/CommandTest.php
  128. +77 −8 Tests/Phergie/Event/HandlerTest.php
  129. +5 −1 Tests/Phergie/Event/RequestTest.php
  130. +1 −1 Tests/Phergie/Event/ResponseTest.php
  131. +39 −23 Tests/Phergie/HostmaskTest.php
  132. +94 −0 Tests/Phergie/Plugin/CacheTest.php
  133. +165 −0 Tests/Phergie/Plugin/DiceTest.php
  134. +43 −20 Tests/Phergie/Plugin/HandlerTest.php
  135. +9 −1 Tests/Phergie/Plugin/IteratorTest.php
  136. +11 −5 Tests/Phergie/Plugin/KarmaTest.php
  137. +97 −0 Tests/Phergie/Plugin/MessageTest.php
  138. +1 −1 Tests/Phergie/Plugin/Mock.php
  139. +7 −3 Tests/Phergie/Plugin/PingTest.php
  140. +1 −1 Tests/Phergie/Plugin/PongTest.php
  141. +7 −4 Tests/Phergie/Plugin/SpellCheckTest.php
  142. +92 −0 Tests/Phergie/Plugin/TemperatureTest.php
  143. +13 −11 Tests/Phergie/Plugin/TerryChayTest.php
  144. +123 −17 Tests/Phergie/Plugin/TestCase.php
  145. +1 −1 Tests/Phergie/Plugin/TestNonInstantiablePluginFromFile.php
  146. +56 −0 Tests/Phergie/Plugin/TwitterTest.php
  147. +81 −0 Tests/Phergie/Plugin/Weather/_files/atlanta/conditions.xml
  148. +21 −0 Tests/Phergie/Plugin/Weather/_files/atlanta/config.php
  149. +18 −0 Tests/Phergie/Plugin/Weather/_files/atlanta/location1.xml
  150. +18 −0 Tests/Phergie/Plugin/Weather/_files/atlanta/location2.xml
  151. +72 −0 Tests/Phergie/Plugin/Weather/_files/silverSpring/conditions.xml
  152. +21 −0 Tests/Phergie/Plugin/Weather/_files/silverSpring/config.php
  153. +8 −0 Tests/Phergie/Plugin/Weather/_files/silverSpring/location1.xml
  154. +6 −0 Tests/Phergie/Plugin/Weather/_files/silverSpring/location2.xml
  155. +211 −0 Tests/Phergie/Plugin/WeatherTest.php
  156. +81 −4 Tests/Phergie/TestCase.php
  157. +90 −0 Tests/Phergie/TestCase/BenchmarkListener.php
  158. +7 −1 Tests/TestHelper.php
  159. +1 −1 Tests/phpunit.xml
  160. +10 −7 build.xml
  161. +3 −3 phergie.php
View
@@ -1,4 +1,4 @@
-Copyright (c) 2010, Phergie Development Team
+Copyright (c) 2008-2011, Phergie Development Team
All rights reserved.
Redistribution and use in source and binary forms, with or without
View
27 Phergie/Autoload.php 100755 → 100644
@@ -14,7 +14,7 @@
* @category Phergie
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
- * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
+ * @copyright 2008-2011 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
@@ -37,8 +37,7 @@ class Phergie_Autoload
*/
public function __construct()
{
- self::addPath(realpath(dirname(__FILE__) . '/..'));
-
+ self::addPath(dirname(dirname(__FILE__)));
}
/**
@@ -50,7 +49,27 @@ public function __construct()
*/
public function load($class)
{
- include str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
+ $paths = explode(PATH_SEPARATOR, get_include_path());
+
+ foreach ($paths as $path) {
+ $fileName = $path . DIRECTORY_SEPARATOR
+ . str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
+
+ if (file_exists($fileName)) {
+ include $fileName;
+
+ if (class_exists($class, false)
+ || interface_exists($class, false)
+ ) {
+ return;
+ }
+
+ throw new Phergie_Exception(
+ 'Expected class ' . $class
+ . ' in ' . $fileName . ' not found'
+ );
+ }
+ }
}
/**
View
69 Phergie/Bot.php 100755 → 100644
@@ -14,7 +14,7 @@
* @category Phergie
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
- * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
+ * @copyright 2008-2011 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
@@ -33,7 +33,7 @@ class Phergie_Bot
/**
* Current version of Phergie
*/
- const VERSION = '2.0.1';
+ const VERSION = '2.0.5';
/**
* Current driver instance
@@ -135,6 +135,27 @@ public function setConfig(Phergie_Config $config)
}
/**
+ * Tries to locate the default configuration file
+ *
+ * @return string|bool Returns false when no file was found
+ */
+ public function getDefaultConfiguration()
+ {
+ $paths = array(
+ dirname(__FILE__) . '/../Settings.php',
+ dirname(__FILE__) . '/Settings.php'
+ );
+
+ foreach ($paths as $path) {
+ if (file_exists($path)) {
+ return $path;
+ }
+ }
+
+ return false;
+ }
+
+ /**
* Returns the entire configuration in use or the value of a specific
* configuration setting.
*
@@ -148,9 +169,18 @@ public function setConfig(Phergie_Config $config)
public function getConfig($index = null, $default = null)
{
if (empty($this->config)) {
+ $config = $this->getDefaultConfiguration();
+ if (false === $config) {
+ throw new Exception(
+ 'Phergie could not locate file Settings.php, '
+ . 'try "phergie path/to/file/Settings.php"'
+ );
+ }
+
$this->config = new Phergie_Config;
- $this->config->read('Settings.php');
+ $this->config->read($config);
}
+
if ($index !== null) {
if (isset($this->config[$index])) {
return $this->config[$index];
@@ -255,7 +285,10 @@ public function getUi()
{
if (empty($this->ui)) {
$this->ui = new Phergie_Ui_Console;
+ $this->ui->setEnabled($this->getConfig('ui.enabled'));
+ $this->getConfig('ui.format', false) && $this->ui->setFormat($this->getConfig('ui.format'));
}
+
return $this->ui;
}
@@ -316,19 +349,28 @@ public function setProcessor(Phergie_Process_Abstract $processor)
protected function loadPlugins()
{
$config = $this->getConfig();
- $plugins = $this->getPluginHandler();
+ if (!isset($config['plugins'])
+ || !is_array($config['plugins'])
+ ) {
+ return;
+ }
+
+ if (isset($config['plugins.autoload'])) {
+ $autoload = (bool) $config['plugins.autoload'];
+ } else {
+ $autoload = false;
+ }
+
$ui = $this->getUi();
+ $plugins = $this->getPluginHandler();
+ $plugins->setAutoload($autoload);
- $plugins->setAutoload($config['plugins.autoload']);
foreach ($config['plugins'] as $name) {
try {
$plugin = $plugins->addPlugin($name);
$ui->onPluginLoad($name);
} catch (Phergie_Plugin_Exception $e) {
$ui->onPluginFailure($name, $e->getMessage());
- if (!empty($plugin)) {
- $plugins->removePlugin($plugin);
- }
}
}
}
@@ -341,6 +383,12 @@ protected function loadPlugins()
protected function loadConnections()
{
$config = $this->getConfig();
+ if (!isset($config['connections'])
+ || !is_array($config['connections'])
+ ) {
+ return;
+ }
+
$driver = $this->getDriver();
$connections = $this->getConnectionHandler();
$plugins = $this->getPluginHandler();
@@ -370,9 +418,6 @@ public function run()
$timezone = $this->getConfig('timezone', 'UTC');
date_default_timezone_set($timezone);
- $ui = $this->getUi();
- $ui->setEnabled($this->getConfig('ui.enabled'));
-
$this->loadPlugins();
$this->loadConnections();
@@ -383,7 +428,7 @@ public function run()
$processor->handleEvents();
}
- $ui->onShutdown();
+ $this->getUi()->onShutdown();
return $this;
}
View
2 Phergie/Config.php 100755 → 100644
@@ -14,7 +14,7 @@
* @category Phergie
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
- * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
+ * @copyright 2008-2011 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
@@ -14,7 +14,7 @@
* @category Phergie
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
- * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
+ * @copyright 2008-2011 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
View
19 Phergie/Connection.php 100755 → 100644
@@ -14,7 +14,7 @@
* @category Phergie
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
- * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
+ * @copyright 2008-2011 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
@@ -55,9 +55,9 @@ class Phergie_Connection
/**
* Encoding method for the connection, defaults to ISO-8859-1 but can
- * be set to UTF8 if necessary
+ * be set to UTF-8 if necessary
*
- * @var strng
+ * @var string
*/
protected $encoding;
@@ -109,7 +109,8 @@ public function __construct(array $options = array())
$this->transport = 'tcp';
$this->encoding = 'ISO-8859-1';
// @note this may need changed to something different, for broader support.
- // @note also may need to make use of http://us.php.net/manual/en/function.stream-encoding.php
+ // @note also may need to make use of
+ // http://us.php.net/manual/en/function.stream-encoding.php
$this->setOptions($options);
}
@@ -243,16 +244,18 @@ public function getTransport()
/**
* Sets the encoding for the connection to use.
*
- * @param string $encoding Encoding to use (ex: ASCII, ISO-8859-1, UTF8, etc.)
+ * @param string $encoding Encoding to use (ex: ASCII, ISO-8859-1, UTF-8, etc.)
*
* @return Phergie_Connection Provides a fluent interface
*/
public function setEncoding($encoding)
{
$this->encoding = (string) $encoding;
- if (!extension_loaded('mbstring')
- xor !in_array($this->encoding, mb_list_encodings())) {
+ $mbStringIsLoaded = extension_loaded('mbstring');
+ $encodingIsValid = in_array($this->encoding, mb_list_encodings());
+
+ if (!$mbStringIsLoaded xor !$encodingIsValid) {
throw new Phergie_Connection_Exception(
'Encoding ' . $this->encoding . ' is not supported',
Phergie_Connection_Exception::ERR_ENCODING_NOT_SUPPORTED
@@ -265,7 +268,7 @@ public function setEncoding($encoding)
/**
* Returns the encoding in use by the connection.
*
- * @return string Encoding (ex: ASCII, ISO-8859-1, UTF8, etc.)
+ * @return string Encoding (ex: ASCII, ISO-8859-1, UTF-8, etc.)
*/
public function getEncoding()
{
@@ -1,6 +1,6 @@
<?php
/**
- * Phergie
+ * Phergie
*
* PHP version 5
*
@@ -11,18 +11,18 @@
* It is also available through the world-wide-web at this URL:
* http://phergie.org/license
*
- * @category Phergie
+ * @category Phergie
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
- * @copyright 2008-2010 Phergie Development Team (http://phergie.org)
+ * @copyright 2008-2011 Phergie Development Team (http://phergie.org)
* @license http://phergie.org/license New BSD License
* @link http://pear.phergie.org/package/Phergie
*/
/**
* Exception related to a connection to an IRC server.
*
- * @category Phergie
+ * @category Phergie
* @package Phergie
* @author Phergie Development Team <team@phergie.org>
* @license http://phergie.org/license New BSD License
@@ -31,13 +31,13 @@
class Phergie_Connection_Exception extends Phergie_Exception
{
/**
- * Error indicating that an operation was attempted requiring a value
+ * Error indicating that an operation was attempted requiring a value
* for a specific configuration setting, but none was set
*/
const ERR_REQUIRED_SETTING_MISSING = 1;
/**
- * Error indicating that a connection is configured to use a transport,
+ * Error indicating that a connection is configured to use a transport,
* but that transport is not supported by the current PHP installation
*/
const ERR_TRANSPORT_NOT_SUPPORTED = 2;
Oops, something went wrong. Retry.

0 comments on commit 8eb11b7

Please sign in to comment.