Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d9b45c1
added contact driver
Sep 25, 2018
a1fdc56
removed self-generated files
Sep 25, 2018
5ced159
added contact driver (#52)
hanc2006 Sep 28, 2018
de13e6b
extended TelegramDriver with Contact
Oct 7, 2018
812fb55
added Contact namespace
Oct 7, 2018
a9d9f5a
Add configuration option for throw_http_exceptions to ensure that the…
sh41 Mar 19, 2020
0980c48
Filter telegram token from exception message. Prevent a credential leak!
sh41 Mar 19, 2020
5a8d1ca
Fix bug in sending Contact and update tests to test both with and wit…
sh41 Mar 15, 2020
272e4d8
Cs Fixer
sh41 Mar 15, 2020
1abc3bd
The documentation for the free styleCI config is here: https://docs.s…
sh41 Mar 15, 2020
48baadd
Add option to retry for server failures and 429 rate warnings.
sh41 Apr 4, 2020
72971b5
Change .styleci to match PSR2 as stated in contributing guidelines, a…
sh41 Apr 4, 2020
c4f2494
Merge pull request #73 from sh41/feature/http_error_checking
feralheart May 22, 2020
21b424e
Fix bug and failing tests in sendContact (#71)
sh41 May 22, 2020
7e6499a
Add configuration option to enable setting of default additional opti…
sh41 May 22, 2020
8917d9c
Create ISSUE_TEMPLATE.md (#59)
antimech May 22, 2020
22cae51
Fix repo link in CONTRIBUTING.md (#57)
antimech May 22, 2020
a7e8c52
Add channel_post to buildPayload (#69)
feralheart May 22, 2020
86cf951
Update book link (#58)
antimech May 22, 2020
da9a9cb
Don't remove inline keyboard automatically (Closes #44, closes #29, a…
May 22, 2020
8a6d163
Added Hall-of-fame to README (#78)
feralheart May 22, 2020
15dce4c
Merge branch 'master' into contact-driver
feralheart Jun 5, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
preset: laravel

enabled:
- unalign_double_arrow

linting: true
preset: psr2
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing

Contributions are **welcome** and will be fully **credited**. We accept contributions via Pull Requests on [Github](https://github.com/botman/driver-facebook).
Contributions are **welcome** and will be fully **credited**. We accept contributions via Pull Requests on [Github](https://github.com/botman/driver-telegram).

## Pull Requests

Expand All @@ -10,7 +10,7 @@ Contributions are **welcome** and will be fully **credited**. We accept contribu
- **Consider our release cycle.** We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
- **Create feature branches.** Don't ask us to pull from your master branch.
- **One pull request per feature.** If you want to do more than one thing, send multiple pull requests.
- **Send coherent history.** Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
- **Send coherent history.** Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.

## Running Tests

Expand All @@ -19,4 +19,4 @@ $ phpunit
```


*Happy coding!*
*Happy coding!*
20 changes: 20 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- If this is a feature request or idea, please remove all the text below this line before writing. -->

<!-- If this is a bug report or support request, please fill in the info below as accurately as you can. -->

### Required Information
<!-- Please enter exact version numbers, not just "latest" etc.! -->
- BotMan version:
- BotMan Telegram Driver version:

### Expected behaviour
<!-- What SHOULD be happening? -->

### Actual behaviour
<!-- What IS happening? -->

### Steps to reproduce
<!-- Explain how to reproduce the issue -->

### Extra details
<!-- Please post any extra details that might help solve the issue (e.g. logs) -->
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ BotMan driver to connect Telegram with [BotMan](https://github.com/botman/botman

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

[![](https://sourcerer.io/fame/feralheart/botman/driver-telegram/images/0)](https://sourcerer.io/fame/feralheart/botman/driver-telegram/links/0)[![](https://sourcerer.io/fame/feralheart/botman/driver-telegram/images/1)](https://sourcerer.io/fame/feralheart/botman/driver-telegram/links/1)[![](https://sourcerer.io/fame/feralheart/botman/driver-telegram/images/2)](https://sourcerer.io/fame/feralheart/botman/driver-telegram/links/2)[![](https://sourcerer.io/fame/feralheart/botman/driver-telegram/images/3)](https://sourcerer.io/fame/feralheart/botman/driver-telegram/links/3)[![](https://sourcerer.io/fame/feralheart/botman/driver-telegram/images/4)](https://sourcerer.io/fame/feralheart/botman/driver-telegram/links/4)[![](https://sourcerer.io/fame/feralheart/botman/driver-telegram/images/5)](https://sourcerer.io/fame/feralheart/botman/driver-telegram/links/5)[![](https://sourcerer.io/fame/feralheart/botman/driver-telegram/images/6)](https://sourcerer.io/fame/feralheart/botman/driver-telegram/links/6)[![](https://sourcerer.io/fame/feralheart/botman/driver-telegram/images/7)](https://sourcerer.io/fame/feralheart/botman/driver-telegram/links/7)

## Security Vulnerabilities

If you discover a security vulnerability within BotMan, please send an e-mail to Marcel Pociot at m.pociot@gmail.com. All security vulnerabilities will be promptly addressed.
Expand Down
1 change: 1 addition & 0 deletions discovery.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"BotMan\\Drivers\\Telegram\\TelegramAudioDriver",
"BotMan\\Drivers\\Telegram\\TelegramFileDriver",
"BotMan\\Drivers\\Telegram\\TelegramLocationDriver",
"BotMan\\Drivers\\Telegram\\TelegramContactDriver",
"BotMan\\Drivers\\Telegram\\TelegramPhotoDriver",
"BotMan\\Drivers\\Telegram\\TelegramVideoDriver"
],
Expand Down
9 changes: 9 additions & 0 deletions src/Exceptions/TelegramConnectionException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace BotMan\Drivers\Telegram\Exceptions;

use BotMan\BotMan\Exceptions\Base\DriverException;

class TelegramConnectionException extends DriverException
{
}
2 changes: 2 additions & 0 deletions src/Providers/TelegramServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use BotMan\Drivers\Telegram\TelegramVideoDriver;
use BotMan\Studio\Providers\StudioServiceProvider;
use BotMan\Drivers\Telegram\TelegramLocationDriver;
use BotMan\Drivers\Telegram\TelegramContactDriver;
use BotMan\Drivers\Telegram\Console\Commands\TelegramRegisterCommand;

class TelegramServiceProvider extends ServiceProvider
Expand Down Expand Up @@ -46,6 +47,7 @@ protected function loadDrivers()
DriverManager::loadDriver(TelegramAudioDriver::class);
DriverManager::loadDriver(TelegramFileDriver::class);
DriverManager::loadDriver(TelegramLocationDriver::class);
DriverManager::loadDriver(TelegramContactDriver::class);
DriverManager::loadDriver(TelegramPhotoDriver::class);
DriverManager::loadDriver(TelegramVideoDriver::class);
}
Expand Down
68 changes: 68 additions & 0 deletions src/TelegramContactDriver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

namespace BotMan\Drivers\Telegram;

use BotMan\BotMan\Messages\Incoming\IncomingMessage;
use BotMan\BotMan\Messages\Attachments\Contact;

class TelegramContactDriver extends TelegramDriver
{
const DRIVER_NAME = 'TelegramContact';

/**
* Determine if the request is for this driver.
*
* @return bool
*/
public function matchesRequest()
{
return ! is_null($this->event->get('from')) && ! is_null($this->event->get('contact'));
}

/**
* @return bool
*/
public function hasMatchingEvent()
{
return false;
}

/**
* Retrieve the chat message.
*
* @return array
*/
public function getMessages()
{
if (empty($this->messages)) {
$this->loadMessages();
}

return $this->messages;
}

/**
* Load Telegram messages.
*/
public function loadMessages()
{
$message = new IncomingMessage(Contact::PATTERN, $this->event->get('from')['id'], $this->event->get('chat')['id'], $this->event);
$message->setContact(new Contact(
$this->event->get('contact')['phone_number'],
$this->event->get('contact')['first_name'],
$this->event->get('contact')['last_name'],
$this->event->get('contact')['user_id'],
$this->event->get('contact')['vcard']
));

$this->messages = [$message];
}

/**
* @return bool
*/
public function isConfigured()
{
return false;
}
}
Loading