ADD alarmerbot

This commit is contained in:
Krivchikov Dmitry 2016-02-28 16:48:10 +03:00
parent 8383af2730
commit 85a4f66695
5 changed files with 28 additions and 3 deletions

21
classes/Alarmer.php Normal file
View File

@ -0,0 +1,21 @@
<?php
class Alarmer
{
static public function send($message)
{
if (App::getConfig('alarmerKey')) {
$ch = curl_init("https://alarmerbot.ru/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_POSTFIELDS, array(
"key" => App::getConfig('alarmerKey'),
"message" => 'WIKIPOINTS: '.$message,
));
curl_exec($ch);
curl_close($ch);
}
}
}

View File

@ -18,5 +18,6 @@ return array(
'metrika' => true, 'metrika' => true,
'ganalytics' => true, 'ganalytics' => true,
'disableSMS' => false, 'disableSMS' => false,
'alarmerKey' => '02f559-a3c1f3-44d756', // key OR FALSE
); );

View File

@ -142,7 +142,8 @@ class ArticleController extends Controller
$article->pubDate = time(); $article->pubDate = time();
} }
$article->status = 'published'; $article->status = 'published';
SMS::send('Статья: ' . $title . ' :: ' . App::$user->nick); // SMS::send('Статья: ' . $title . ' :: ' . App::$user->nick);
Alarmer::send('новая статья "' . $title . '" от ' . App::$user->nick);
} }
$article->title = $title ? $title : 'Без названия'; $article->title = $title ? $title : 'Без названия';

View File

@ -66,7 +66,8 @@ class CommentsController extends Controller
} }
} }
SMS::send('Новый комментарий от '.App::$user->nick, '79046106141'); // SMS::send('Новый комментарий от '.App::$user->nick, '79046106141');
Alarmer::send('Новый комментарий от '.App::$user->nick);
App::redirect('/' . $_POST['parentType'] . '/' . $_POST['parentId'] . '#comment' . $comment->id); App::redirect('/' . $_POST['parentType'] . '/' . $_POST['parentId'] . '#comment' . $comment->id);
} }

View File

@ -308,7 +308,8 @@ class JsonController extends Controller
die('Error 500 - Internal Server Error'); die('Error 500 - Internal Server Error');
} }
SMS::send('#' . $point->id . ' ' . $point->name . ' :: ' . App::$user->nick); // SMS::send('#' . $point->id . ' ' . $point->name . ' :: ' . App::$user->nick);
Alarmer::send('Новая точка #' . $point->id . ' "' . $point->name . '" от ' . App::$user->nick);
} }
self::renderPartial('json.php', array( self::renderPartial('json.php', array(