Skip to content

Commit

Permalink
feat(skeleton): skeleton and basic function
Browse files Browse the repository at this point in the history
  • Loading branch information
indes committed Nov 25, 2018
1 parent 93c86d7 commit 5f911d4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
1 change: 0 additions & 1 deletion logs/README.md

This file was deleted.

34 changes: 22 additions & 12 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,14 @@
use Slim\Http\Response;
use Longman\TelegramBot\Telegram;

// Routes
//$app->get('/[{name}]', function (Request $request, Response $response, array $args) {
// // Sample log message
// $this->logger->info("Slim-Skeleton '/' route");
//
// // Render index view
// return $this->renderer->render($response, 'index.phtml', $args);
//});


$app->get("/", function (Request $request, Response $response, array $args) {
$response->getBody()->write(":)");
$response->getBody()->write("<h1>:)</h1>");
return $response;
});


$app->get("/send", function (Request $request, Response $response, array $args) {
$app->get("/ping", function (Request $request, Response $response, array $args) {

$telegram = new Telegram(getenv('BOT_TOKEN'));
if (getenv('PROXY')) {
Expand All @@ -32,10 +23,29 @@
);
}

$result = Longman\TelegramBot\Request::sendMessage([
'chat_id' => (int)getenv('OWNER_ID'),
'text' => "ping"
]);
$response->getBody()->write("ping");
return $response;
});

$app->get("/api/send", function (Request $request, Response $response, array $args) {

$telegram = new Telegram(getenv('BOT_TOKEN'));
if (getenv('PROXY')) {
Longman\TelegramBot\Request::setClient(
new \GuzzleHttp\Client([
'base_uri' => 'https://api.telegram.org',
'proxy' => getenv('PROXY')
])
);
}

$result = Longman\TelegramBot\Request::sendMessage([
'chat_id' => (int)getenv('OWNER_ID'),
'text' => (int)getenv('OWNER_ID')
'text' => $request->getQueryParam("msg")
]);
$response->getBody()->write("ok");
return $response;
Expand Down

0 comments on commit 5f911d4

Please sign in to comment.