Commit 02c121f2 authored by MBoretto's avatar MBoretto

All types implemented and stored

parent ada86a45
......@@ -124,7 +124,7 @@ The bot can handle updates with **webhook** or **getUpdate** method:
## Webhook installation
You need server with https and composer support.
You must set a [WebHook](https://core.telegram.org/bots/api#setwebhook)
You must set a [WebHook](https://core.telegram.org/bots/api#setwebhook).
Create *set.php* (just edit *example-set.php*) and put into it:
```php
<?php
......@@ -145,14 +145,12 @@ try {
} catch (Longman\TelegramBot\Exception\TelegramException $e) {
echo $e;
}
```
And open your *set.php* via browser.
After create *hook.php* (just edit *example-hook.php*) and put:
After, create *hook.php* (or just edit *example-hook.php*) and put:
```php
<?php
$loader = require __DIR__.'/vendor/autoload.php';
......@@ -171,11 +169,10 @@ try {
// echo $e;
}
```
## getUpdate installation NEW!
## getUpdate installation
You need the database Mysql active.
Create *getUpdateCLI.php* (just edit *example-getUpdateCLI.php*) and
put into it:
Create *getUpdateCLI.php* (just edit *example-getUpdateCLI.php*) and put into it:
```php
#!/usr/bin/env php
<?php
......@@ -223,6 +220,8 @@ You can set a custom prefix to all the tables while you are enabling Mysql:
```php
$telegram->enableMySQL($credentials, $BOT_NAME.'_');
```
### Types New!
All types implemented (except InputFile) according to Telegram API (2015 September 18).
### Commands
The bot is able to recognise commands in chat with multiple bot(
......@@ -241,16 +240,15 @@ Favourite colour? **/black, /red**
Favourite number? **/1, /134**
Maybe you would like to develop your own commands. A good practice is
to store them outside vendor/. This can be done adding the method:
to store them outside *vendor/*. This can be done adding the method:
```php
$COMMANDS_FOLDER = __DIR__.'/Commands/';
$telegram->addCommandsPath($COMMANDS_FOLDER);
```
### Admin Commands (new!)
Enabling this feature, the admin bot can perform some super user
command like send message to all.
### Admin Commands
Enabling this feature, the admin bot can perform some super user command like send message to all.
You can specify one or more admin with this option:
```php
......@@ -286,12 +284,13 @@ print_r($results);
```
### Logging
Thrown Exception are stored in TelegramException.log file.
You can also log incoming messages on a text file, set this option with the methods:
```php
$telegram->setLogRequests(true);
$telegram->setLogPath($BOT_NAME.'.log');
```
Thrown Exception are stored in TelegramException.log file.
-----
This code is available on
......
This diff is collapsed.
......@@ -29,10 +29,9 @@ class Document extends Entity
}
$this->thumb = isset($data['thumb']) ? $data['thumb'] : null;
if (empty($this->file_id)) {
throw new TelegramException('thumb is empty!');
if (!empty($this->thumb)) {
$this->thumb = new PhotoSize($this->thumb);
}
$this->thumb = new PhotoSize($this->thumb);
$this->file_name = isset($data['file_name']) ? $data['file_name'] : null;
$this->mime_type = isset($data['mime_type']) ? $data['mime_type'] : null;
......
......@@ -122,9 +122,9 @@ class Message extends Entity
$this->photo = isset($data['photo']) ? $data['photo'] : null; //array of photosize
if (!empty($this->photo)) {
foreach($this->photo as $photo){
if(!empty($photo)) {
$photos[] = new PhotoSize($photo);
foreach ($this->photo as $photo) {
if (!empty($photo)) {
$photos[] = new PhotoSize($photo);
}
}
$this->photo = $photos;
......
......@@ -3,24 +3,24 @@ CREATE TABLE `messages` (
`message_id` bigint COMMENT 'Unique message identifier',
`user_id` bigint COMMENT 'User identifier',
`date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Date the message was sent in timestamp format',
`chat_id` bigint NOT NULL DEFAULT '0' COMMENT 'User or GroupChat object. Conversation the message belongs to — user in case of a private message, GroupChat in case of a group',
`forward_from` VARCHAR(511) DEFAULT '' COMMENT 'User object. For forwarded messages, sender of the original message',
`forward_date` int(511) UNSIGNED DEFAULT 0 COMMENT 'For forwarded messages, date the original message was sent in Unix time',
`chat_id` bigint NOT NULL DEFAULT '0' COMMENT 'Chat identifier.',
`forward_from` bigint NOT NULL DEFAULT '0' COMMENT 'User id. For forwarded messages, sender of the original message',
`forward_date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'For forwarded messages, date the original message was sent in Unix time',
`reply_to_message` LONGTEXT COMMENT 'Message object. For replies, the original message. Note that the Message object in this field will not contain further reply_to_message fields even if it itself is a reply.',
`text` LONGTEXT COMMENT 'For text messages, the actual UTF-8 text of the message',
`audio` VARCHAR(511) DEFAULT '' COMMENT 'Audio object. Message is an audio file, information about the file',
`document` VARCHAR(511) DEFAULT '' COMMENT 'Document object. Message is a general file, information about the file',
`photo` VARCHAR(511) DEFAULT '' COMMENT 'Array of PhotoSize objects. Message is a photo, available sizes of the photo',
`sticker` VARCHAR(511) DEFAULT '' COMMENT 'Sticker object. Message is a sticker, information about the sticker',
`video` VARCHAR(511) DEFAULT '' COMMENT 'Video object. Message is a video, information about the video',
`voice` VARCHAR(511) DEFAULT '' COMMENT 'Voice Object. Message is a Voice, information about the Voice',
`audio` TEXT DEFAULT '' COMMENT 'Audio object. Message is an audio file, information about the file',
`document` TEXT DEFAULT '' COMMENT 'Document object. Message is a general file, information about the file',
`photo` TEXT DEFAULT '' COMMENT 'Array of PhotoSize objects. Message is a photo, available sizes of the photo',
`sticker` TEXT DEFAULT '' COMMENT 'Sticker object. Message is a sticker, information about the sticker',
`video` TEXT DEFAULT '' COMMENT 'Video object. Message is a video, information about the video',
`voice` TEXT DEFAULT '' COMMENT 'Voice Object. Message is a Voice, information about the Voice',
`caption` LONGTEXT COMMENT 'For message with caption, the actual UTF-8 text of the caption',
`contact` VARCHAR(511) DEFAULT '' COMMENT 'Contact object. Message is a shared contact, information about the contact',
`location` VARCHAR(511) DEFAULT '' COMMENT 'Location object. Message is a shared location, information about the location',
`new_chat_participant` VARCHAR(511) COMMENT 'User object. A new member was added to the group, information about them (this member may be bot itself)',
`left_chat_participant` VARCHAR(511) COMMENT 'User object. A member was removed from the group, information about them (this member may be bot itself)',
`new_chat_title` VARCHAR(511) DEFAULT '' COMMENT 'A group title was changed to this value',
`new_chat_photo` VARCHAR(511) DEFAULT '' COMMENT 'Array of PhotoSize objects. A group photo was change to this value',
`contact` TEXT DEFAULT '' COMMENT 'Contact object. Message is a shared contact, information about the contact',
`location` TEXT DEFAULT '' COMMENT 'Location object. Message is a shared location, information about the location',
`new_chat_participant` bigint NOT NULL DEFAULT '0' COMMENT 'User id. A new member was added to the group, information about them (this member may be bot itself)',
`left_chat_participant` bigint NOT NULL DEFAULT '0' COMMENT 'User id. A member was removed from the group, information about them (this member may be bot itself)',
`new_chat_title` CHAR(255) DEFAULT '' COMMENT 'A group title was changed to this value',
`new_chat_photo` TEXT DEFAULT '' COMMENT 'Array of PhotoSize objects. A group photo was change to this value',
`delete_chat_photo` tinyint(1) DEFAULT 0 COMMENT 'Informs that the group photo was deleted',
`group_chat_created` tinyint(1) DEFAULT 0 COMMENT 'Informs that the group has been created',
PRIMARY KEY (`update_id`),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment