mirror of
https://github.com/danog/TelegramApiServer.git
synced 2024-11-30 04:19:13 +01:00
Update readme & composer & name
Update response generation
This commit is contained in:
parent
d6b7133700
commit
2cdf37c8e2
@ -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
|
||||
|
||||
@ -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`:
|
||||
|
@ -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')) {
|
||||
if (!file_exists($root . '/vendor/autoload.php')) {
|
||||
$root = __DIR__ . '/../../..';
|
||||
}
|
||||
require $root . '/vendor/autoload.php';
|
||||
chdir($root);
|
||||
}
|
||||
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();
|
||||
|
@ -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/",
|
||||
@ -38,7 +38,7 @@
|
||||
],
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"TelegramSwooleClient\\": "src/"
|
||||
"TelegramApiServer\\": "src/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
composer.lock
generated
2
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "8aee7c1eb22cd664c077c858b8ce8bc7",
|
||||
"content-hash": "411cf9adeea33d6ddccaef5634fcb8a7",
|
||||
"packages": [
|
||||
{
|
||||
"name": "amphp/amp",
|
||||
|
@ -47,5 +47,5 @@ if ($options['session']) {
|
||||
$sessionFile = "{$root}/session.madeline";
|
||||
}
|
||||
|
||||
$client = new \TelegramSwooleClient\Client($sessionFile);
|
||||
new TelegramSwooleClient\Server($client, $options);
|
||||
$client = new TelegramApiServer\Client($sessionFile);
|
||||
new TelegramApiServer\Server($client, $options);
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace TelegramSwooleClient;
|
||||
namespace TelegramApiServer;
|
||||
|
||||
use danog\MadelineProto;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace TelegramSwooleClient;
|
||||
namespace TelegramApiServer;
|
||||
|
||||
|
||||
class Config
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace TelegramSwooleClient;
|
||||
namespace TelegramApiServer;
|
||||
|
||||
class RequestCallback
|
||||
{
|
||||
@ -169,7 +169,7 @@ class RequestCallback
|
||||
$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;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace TelegramSwooleClient;
|
||||
namespace TelegramApiServer;
|
||||
|
||||
class Server
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user