Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
skrtdev committed Sep 25, 2020
1 parent 9696d6e commit 9d33f1c
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 29 deletions.
28 changes: 23 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ An elegant, Object-Oriented, reliable PHP Telegram Bot Interface
## Features

- All the Methods and Types implemented in Bot Api as of September 2020.
- Typed Properties for each Object (with description too)
- Exactly like Bot Api (so you don't really need documentation)
- [JSON Payload](https://docs.novagram.ga/construct.html#json-payload) implementation, for a faster Bot.
- Auto JSON-Encode in parameters that require it (when passing an array)
Expand All @@ -15,24 +16,41 @@ An elegant, Object-Oriented, reliable PHP Telegram Bot Interface
- Telegram IP check, in order to protect from Fake Update attacks (with Cloudflare too!)
- Optional Telegram Exceptions, for handling Telegram API Errors as you like.
- Global Parse Mode, so you won't need to specify it in each method
- Global disable_web_page_preview, so you won't need to specify it in each method
- Global disable_notification, so you won't need to specify it in each method
- Ability to [retrieve DC](https://docs.novagram.ga/docs.html#getUsernameDC) of Users that has an Username
- Usable with Composer, but also in Hosting Panels that doesn't provide it, with PHPEasyGit

## Being implemented

- Database
- Conversations
- Message Entities -> HTML

## Upcoming Features

- non-dinamic object methods
- Database
- Conversations
- TTL in Conversations
- disable_web_page_preview in settings
- disable_notification in settings
- Long Polling
- Long Polling (async)
- Message Entities to Markdown

### Installation via [Composer](https://getcomposer.org)
If Composer is installed globally:
```
composer require skrtdev/novagram
```

If Composer is installed in the current directory:
```
php composer.phar require skrtdev/novagram
```

### Installation via Composer
`composer require skrtdev/novagram`
After Installation, include NovaGram with:
```php
require __DIR__ . '/vendor/autoload.php';
```

### Example
An example code of a simple bot that just forwards back what you send.
Expand Down
24 changes: 13 additions & 11 deletions docs/construct.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,24 @@ $token is the Bot's token generated by @BotFather
$settings is an array which contains some NovaGram configurations.
> None of these fields is required
| key | value | default | description |
|------------------|---------|---------|----------------------------------------------------------------------------------------------------|
| json_payload | boolean | true | Whether or not print json payload |
| log_updates | integer | false | Chat id where raw json updates will be sent (set to false to disable) |
| debug | integer | false | Chat id where debug logs will be sent if an api error occurs (set to false to disable) |
| disable_ip_check | boolean | false | Whether or not disable telegram ip check (could be useful in case of reverse proxy, such as ngrok) |
| disable_webhook | boolean | false | Whether or not disable update receiving |
| parse_mode | string | no | Parse mode that will be passed to all the methods that require it if not provided |
| exceptions | bool | true | Whether or not throw \skrtdev\Telegram\Exception(s) when API Errors occurs |
| database | array | no | [Database](database.md) connection info |
| key | value | default | description |
|--------------------------|---------|---------|----------------------------------------------------------------------------------------------------|
| json_payload | boolean | true | Whether or not print json payload |
| log_updates | integer | false | Chat id where raw json updates will be sent (set to false to disable) |
| debug | integer | false | Chat id where debug logs will be sent if an api error occurs (set to false to disable) |
| disable_ip_check | boolean | false | Whether or not disable telegram ip check (could be useful in case of reverse proxy, such as ngrok) |
| disable_webhook | boolean | false | Whether or not disable update receiving |
| parse_mode | string | no | Default `parse_mode` for methods that require it |
| disable_web_page_preview | string | no | Default `disable_web_page_preview` for methods that require it |
| disable_notification | string | no | Default `disable_notification` for methods that require it |
| exceptions | bool | true | Whether or not throw \skrtdev\Telegram\Exception(s) when API Errors occurs |
| database | array | no | [Database](database.md) connection info |

### JSON Payload

JSON Payload is a different way to make API Calls.
In Webhooks, you can print a JSON-Encoded request directly in the webhook page, that will be processed by Telegram afterwards, without effectively making an API Call.
> Only One API Call can use JSON Payload in the same execution contest
> Only One API Call can use JSON Payload simultaneously
#### Pro:
* Since no HTTP Request is involved, using Payload speeds up the bot.
Expand Down
9 changes: 6 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ An elegant, Object-Oriented, reliable PHP Telegram Bot Interface

## Features

- All the Methods and Types implemented in Bot Api as of August 2020.
- All the Methods and Types implemented in Bot Api as of September 2020.
- Typed Properties for each Object (with description too)
- Exactly like Bot Api (so you don't really need documentation)
- [JSON Payload](https://docs.novagram.ga/construct.html#json-payload) implementation, for a faster Bot.
- Auto JSON-Encode in parameters that require it (when passing an array)
- [Object Methods](https://docs.novagram.ga/objects.html) for a smarter code (and a nice syntax)
- [JSON based](https://github.com/skrtdev/NovaGram/blob/master/src/json.json), so all methods and types are dinamically created.
- [Object Methods](https://docs.novagram.ga/objects.html#objects-methods) for a smarter code (and a nice syntax)
- [JSON based](https://github.com/skrtdev/NovaGram/blob/master/src/novagram/json.json), so all methods and types are dinamically created.
- Native Debug, so you will be able to fix bugs immediately.
- Telegram IP check, in order to protect from Fake Update attacks (with Cloudflare too!)
- Optional Telegram Exceptions, for handling Telegram API Errors as you like.
- Global Parse Mode, so you won't need to specify it in each method
- Global disable_web_page_preview, so you won't need to specify it in each method
- Global disable_notification, so you won't need to specify it in each method
- Ability to [retrieve DC](https://docs.novagram.ga/docs.html#getUsernameDC) of Users that has an Username
- Usable with Composer, but also in Hosting Panels that doesn't provide it, with PHPEasyGit

Expand Down
12 changes: 5 additions & 7 deletions docs/requests.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ $Bot->sendMessage([
"chat_id" => 01234567,
"text" => "message_text"
]);
// same as
$Bot->sendMessage(01234567, "message_text");
```

This will send a Message in the specified chat with the specified text.
Expand All @@ -24,16 +26,12 @@ This will send a Message in the specified chat with the specified text.
If JSON Payload is enabled in Bot's settings, you can make a Payload request.
When making an API Call, pass `true` in `$payload` (or leave default), and it will be made as payload.

**NOTE: Only one API Call can be made as JSON Payload in the same execution contest.
If there are more than one Payload API Call, only the first one will be made as Payload, while others will be made normally**
**NOTE: Attempt to use payload multiple times will result in a `Trying to use JSON Payload more than one time` Notice**

> Payload API Calls will be executed after the script exits
> Payload API Calls will be executed when script execution finishes
```php
$Bot->sendMessage([
"chat_id" => 01234567,
"text" => "This is a JSON Payload"
], true);
$Bot->sendMessage(01234567, "This is a JSON Payload", true);
```

Argument `$payload` is `true`, so this will be made as Payload (if a Payload wasn't made yet).
Expand Down
2 changes: 1 addition & 1 deletion docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $message = $update->message;
$chat = $message->chat;
$user = $message->from;

$update->message->forward([], true); // forward() with no parameters will forward the Message back to the sender
$message->forward([], true); // forward() with no parameters will forward the Message back to the sender
```

Using `"json_payload" => true` and `true` in forward method, the api call will be print as payload, making the bot faster. Only one Api Call can use json payload
Expand Down
4 changes: 3 additions & 1 deletion examples/EchoBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
require "../PHPEasyGit/autoload.php";
*/

$Bot = new NovaGram\Bot("YOUR_TOKEN", [
use skrtdev\NovaGram\Bot;

$Bot = new Bot("YOUR_TOKEN", [
"debug" => YOURCHATID, // chat id where debug will be sent when api errors occurs
"json_payload" => true, // allow use of json payload (without this, all the api calls will be made normally, even if they should be made as json payload)
]);
Expand Down
4 changes: 3 additions & 1 deletion examples/EncoderBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
require "../PHPEasyGit/autoload.php";
*/

$Bot = new NovaGram\Bot("YOUR_TOKEN", [
use skrtdev\NovaGram\Bot;

$Bot = new Bot("YOUR_TOKEN", [
"debug" => YOURCHATID, // chat id where debug will be sent when api errors occurs
"json_payload" => true, // allow use of json payload (without this, all the api calls will be made normally, even if they should be made as json payload)
"parse_mode" => "HTML" // will set parse_mode automatically in methods that require it if not providedå
Expand Down

0 comments on commit 9d33f1c

Please sign in to comment.