Skip to content

Commit

Permalink
Update readme & composer & name
Browse files Browse the repository at this point in the history
Update response generation
  • Loading branch information
xtrime-ru committed Jun 9, 2019
1 parent d6b7133 commit 2cdf37c
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 20 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TelegramSwooleClient
# TelegramApiServer
Fast, simple, async php telegram client and parser:
[MadelineProto](https://github.com/danog/MadelineProto) and [Swoole](https://github.com/swoole/swoole-src) Server

Expand All @@ -9,19 +9,19 @@ Fast, simple, async php telegram client and parser:
**Features**

* Fast async swoole server
* Use as micro-service to access telegram api
* Get any telegram posts as json
* Full access to telegram api: bot and user

**Example Architecture**
![Proposed Architecture](https://habrastorage.org/webt/qz/ax/ct/qzaxctkgwehhhsqglgszy4rowwa.png)

**Installation**

1. Get app_id and app_hash at [my.telegram.org](https://my.telegram.org/)
1. Swoole extension required: [Install swoole](https://github.com/swoole/swoole-src#%EF%B8%8F-installation)
1. `composer install` to install required libs
1. Create .env from .env.example
1. Fill variables in .env
1. Fill app_id and app_hash from [my.telegram.org](https://my.telegram.org/)
Or leave blank and MadelineProto will try to generate on start.

_Optional:_
1. Use supervisor to monitor and restart swoole servers. Example of `/etc/supervisor/conf.d/telegram_rss.conf`:
Expand Down
11 changes: 5 additions & 6 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?php
//Check if autoload has been already loaded (in case plugin installed in existing project)
$root = __DIR__;
if (!class_exists('TelegramSwooleClient')) {
if (!file_exists($root . '/vendor/autoload.php')) {
$root = __DIR__ . '/../../..';
}
require $root . '/vendor/autoload.php';
chdir($root);
if (!file_exists($root . '/vendor/autoload.php')) {
$root = __DIR__ . '/../../..';
}
require_once $root . '/vendor/autoload.php';
chdir($root);

//Check if root env file hash been loaded (in case plugin installed in existing project)
if (!getenv('SWOOLE_SERVER_ADDRESS')) {
Dotenv\Dotenv::create($root, '.env')->load();
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "xtrime-ru/telegramswooleclient",
"name": "xtrime-ru/telegramapiserver",
"description": "Fast, simple, async php telegram client and parser: MadelineProto + Swoole Server",
"type": "project",
"homepage": "http://tg.i-c-a.su/",
Expand Down Expand Up @@ -38,7 +38,7 @@
],
"autoload": {
"psr-4": {
"TelegramSwooleClient\\": "src/"
"TelegramApiServer\\": "src/"
}
}
}
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions server.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@
$sessionFile = "{$root}/session.madeline";
}

$client = new \TelegramSwooleClient\Client($sessionFile);
new TelegramSwooleClient\Server($client, $options);
$client = new TelegramApiServer\Client($sessionFile);
new TelegramApiServer\Server($client, $options);
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TelegramSwooleClient;
namespace TelegramApiServer;

use danog\MadelineProto;

Expand Down
2 changes: 1 addition & 1 deletion src/Config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php


namespace TelegramSwooleClient;
namespace TelegramApiServer;


class Config
Expand Down
4 changes: 2 additions & 2 deletions src/RequestCallback.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TelegramSwooleClient;
namespace TelegramApiServer;

class RequestCallback
{
Expand Down Expand Up @@ -169,7 +169,7 @@ public function encodeResponse(): string
$data['success'] = 1;
}

$result = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
$result = json_encode($data, JSON_INVALID_UTF8_SUBSTITUTE|JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

return $result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TelegramSwooleClient;
namespace TelegramApiServer;

class Server
{
Expand Down

0 comments on commit 2cdf37c

Please sign in to comment.