BlinkPlugin.php 743 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. if (!defined('GNUSOCIAL')) {
  3. exit(1);
  4. }
  5. require_once("util/arduino.php");
  6. class BlinkPlugin extends Plugin
  7. {
  8. const VERSION = '0.0.1';
  9. public function onPluginVersion(array &$versions)
  10. {
  11. $versions[] = ['name' => 'Blink',
  12. 'version' => self::VERSION,
  13. 'author' => 'Hackers at Porto',
  14. 'homepage' => 'https://notabug.org/',
  15. 'description' => _m('Plugin that switches a led when a note asks for it.')];
  16. return true;
  17. }
  18. public function onStartNoticeSave(Notice $notice)
  19. {
  20. $on = preg_match(".*light.*", notice.getContent());
  21. $off = preg_match(".*darkness.*", notice.getContent());
  22. arduino.send($on << 1 | $off << 2);
  23. }
  24. }