12345678910111213141516171819202122232425262728293031 |
- <?php
- if (!defined('GNUSOCIAL')) {
- exit(1);
- }
- require_once("util/arduino.php");
- class BlinkPlugin extends Plugin
- {
- const VERSION = '0.0.1';
- public function onPluginVersion(array &$versions)
- {
- $versions[] = ['name' => 'Blink',
- 'version' => self::VERSION,
- 'author' => 'Hackers at Porto',
- 'homepage' => 'https://notabug.org/',
- 'description' => _m('Plugin that switches a led when a note asks for it.')];
- return true;
- }
- public function onStartNoticeSave(Notice $notice)
- {
- $on = preg_match(".*light.*", notice.getContent());
- $off = preg_match(".*darkness.*", notice.getContent());
- arduino.send($on << 1 | $off << 2);
- }
- }
|