33namespace Bow \Notifier \Adapters ;
44
55use Bow \Database \Barry \Model ;
6+ use Bow \Http \Client \HttpClient ;
67use Bow \Notifier \Contracts \ChannelAdapterInterface ;
78use Bow \Notifier \Notifier ;
89use Exception ;
9- use GuzzleHttp \Client ;
10- use GuzzleHttp \Exception \GuzzleException ;
1110use InvalidArgumentException ;
1211use RuntimeException ;
1312
@@ -38,7 +37,7 @@ public function __construct()
3837 * @param Model $context
3938 * @param Notifier $notifier
4039 * @return void
41- * @throws GuzzleException
40+ * @throws Exception
4241 */
4342 public function send (Model $ context , Notifier $ notifier ): void
4443 {
@@ -52,16 +51,14 @@ public function send(Model $context, Notifier $notifier): void
5251 throw new InvalidArgumentException ('The chat ID and message are required for Telegram ' );
5352 }
5453
55- $ client = new Client ();
54+ $ client = new HttpClient ();
5655 $ endpoint = "https://api.telegram.org/bot {$ this ->botToken }/sendMessage " ;
5756
5857 try {
59- $ client ->post ($ endpoint , [
60- 'json ' => [
61- 'chat_id ' => $ data ['chat_id ' ],
62- 'text ' => $ data ['message ' ],
63- 'parse_mode ' => $ data ['parse_mode ' ] ?? 'HTML '
64- ]
58+ $ client ->acceptJson ()->post ($ endpoint , [
59+ 'chat_id ' => $ data ['chat_id ' ],
60+ 'text ' => $ data ['message ' ],
61+ 'parse_mode ' => $ data ['parse_mode ' ] ?? 'HTML '
6562 ]);
6663 } catch (Exception $ e ) {
6764 throw new RuntimeException ('Error while sending Telegram message: ' . $ e ->getMessage ());
0 commit comments