Comments (9)
Wow thank you @irazasyed for the fast response. I referred to that docs as they are linked inside "Available Methods" section.
Ok I'll have a look at the Laravel 10 version (https://laravel.com/docs/10.x/notifications#notification-events) and see what I can come up with. Tku very much.
from telegram.
Updated links!
from telegram.
No. You need to listen to the NotificationSent event.
// EventServiceProvider.php
use App\Listeners\LogTelegramNotification;
use Illuminate\Notifications\Events\NotificationSent;
/**
* The event listener mappings for the application.
*
* @var array
*/
protected $listen = [
NotificationSent::class => [
LogTelegramNotification::class,
],
];
// LogTelegramNotification
/**
* Handle the event.
*/
public function handle(NotificationSent $event): void
{
// $event->channel
// $event->notifiable
// $event->notification
// $event->response
}
There is no need for you to dispatch or do anything. Just listen to the standard notification sent event and you'll get complete data in your listener such as the channel, notifiable, the response from Telegram (or any other channel -- you should filter based on this available data).
from telegram.
That's not supported. You'll have to either use the Telegram Bot SDK for that or create a helper yourself. The core idea of this channel is to deliver one-way notifications.
The channel cannot be used to support full Telegram API methods as that's not the purpose of this package.
from telegram.
You should use notification events, more on this in the docs: handling response.
Also, those docs you've mentioned are not related to this package.
from telegram.
No problem :)
It's actually linked to refer supported parameters which can be used with the options method to pass any additional params.
Probably should just replace the link to official documentation. Thanks for highlighting.
from telegram.
I have trouble in implementing it.
So do I have to create a TelegramMessageSentEvent
event, then add it to EventServiceProvider
inside $listen
array like this with a listener connected:
protected $listen = [
//other methods
TelegramMessageSentEvent::class => [
TelegramNotificationStatus::class
]
];
Then inside Notifications\TelegramNotification
add the event()
helper:
public function toTelegram()
{
$msg = TelegramMessage::create();
if ($this->reply_to_message_id) {
$msg = $msg->options(['reply_to_message_id' => $this->reply_to_message_id]);
}
event(new TelegramMessageSentEvent($msg));
return $msg->content($this->text);
}
I'm lost what to do inside TelegramMessageSentEvent::class
and TelegramNotificationStatus::class
:(
from telegram.
There's also Notification Failed event which if you listen to that event will get some useful data to help you debug the issues or take appropriate action. https://github.com/laravel-notification-channels/telegram/blob/master/src/TelegramChannel.php#L59-L63
from telegram.
Amazing, I was able to log the message_id
!
Now I noticed the API have the deleteMessage('message_id')
method, but I don't see them in this package. Did I missed them?
I would like to delete a specific message after some seconds, so once is sent, inside LogTelegramNotification::class
I can probably just do:
public function handle(NotificationSent $event): void
{
//some logic
sleep(60);
deleteMessage($event->response['result']['message_id']);
}
from telegram.
Related Issues (20)
- CouldNotSendNotification. cURL error 60: SSL certificate problem HOT 1
- Call to undefined method NotificationChannels\Telegram\TelegramMessage::file() HOT 4
- Telegram responded with an error `400 - Bad Request: group chat was upgraded to a supergroup chat`
- Laravel 10 compatibility HOT 5
- How to add message_thread_id to TelegramMessage::create() HOT 1
- update message(Custom endpoint overwriting needed) HOT 1
- The communication with Telegram failed HOT 3
- Posting in topics HOT 2
- sending album photos HOT 1
- How to send to multiple Telegram bots HOT 1
- Error: Call to a member function toNotGiven() on null HOT 2
- Is there a way to send multiple images in one message? HOT 2
- it.tdlight.client.TelegramError: 400: Chat not found HOT 3
- Latest Commit isn't included in a tagged version HOT 1
- Telegram responded with an error `403 - Forbidden: bots can't send messages to bots HOT 1
- Please support laravel 11 HOT 1
- Unable to retrieve chat id or full request from Exception
- Expand TelegramMessage class
- Telegram responded with an error `403 - Forbidden: bot was blocked by the user`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram.