Beispiel #1
0
 private function slackinvite()
 {
     global $slacktoken;
     $slack = new slack();
     $res = $slack->invite($this->email, $this->username, $slacktoken);
     if ($res == "success") {
         echo "Slack invite successful";
     } else {
         echo $res;
     }
 }
Beispiel #2
0
        }
        if (empty($img)) {
            return response::json(":warning: I'll only publish posts with images");
        }
        $page = site()->visit($pageId, $lang);
        $dir = $page->root();
        $ext = preg_replace('/.+?(\\.\\w+)($|[#?].*)/', '$1', $img);
        $file = $dir . DS . $m['ts'] . $ext;
        // Output success message early because of short slackbot timeouts
        $msg = ':metal: *' . r::data('text', 'last') . '* post is now live' . ' on <' . $page->url() . '>';
        echo $msg;
        flush();
        error_log($msg);
        $user = static::api('users.info', ['user' => $m['user']]);
        $meta = ['title' => $a['title'], 'date' => date('d.m.Y', $m['ts']), 'description' => @$a['text'], 'linkurl' => $a['from_url'], 'author' => $user['user']['profile']['real_name'], 'avatar' => $m['user'] . '.jpg', 'comment' => static::format(@$m['text']), 'slack' => '1'];
        data::write($file . '.txt', $meta, 'kd');
        // Download the avatar image
        $avatar = $dir . DS . $meta['avatar'];
        static::download($user['user']['profile']['image_72'], $avatar);
        // Download the image
        static::download($img, $file);
        // Response has already been sent
        return false;
    }
}
kirby()->routes([['pattern' => c::get('slack.route', 'hooks/slack/(:all)'), 'method' => 'POST', 'action' => function ($page) {
    $m = [];
    // Extract the optional language suffix
    preg_match('/(.*?)(?:\\.(.+?))?$/', $page, $m);
    return slack::handle($m[1], $m[2]);
}]]);
Beispiel #3
0
 *
 * You should have received a copy of the GNU General Public License
 * along with Jeedom. If not, see <http://www.gnu.org/licenses/>.
 */
header('Content-type: application/json');
require_once dirname(__FILE__) . "/../../../../core/php/core.inc.php";
if (init('apikey') != config::byKey('api') || config::byKey('api') == '') {
    connection::failed();
    echo 'Clef API non valide, vous n\'etes pas autorisé à effectuer cette action (jeeApi)';
    die;
}
if (init('user_name') == 'slackbot' || init('user_id') == 'USLACKBOT') {
    echo json_encode(array('text' => ''));
    die;
}
$eqLogic = slack::byLogicalId(init('team_domain'), 'slack');
if (!is_object($eqLogic)) {
    echo json_encode(array('text' => __('Domaine inconnue : ', __FILE__) . init('team_domain')));
    die;
}
$parameters = array();
$user = user::byLogin(init('user_name'));
if (is_object($user)) {
    $parameters['profile'] = init('user_name');
}
$cmd_text = $eqLogic->getCmd('info', 'text');
$cmd_text->event(trim(init('text')));
$cmd_sender = $eqLogic->getCmd('info', 'sender');
$cmd_sender->event(init('user_name'));
$reply = interactQuery::tryToReply(trim(init('text')), $parameters);
echo json_encode(array('text' => $reply));