Message::reply()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 11
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
4
namespace Sysbot\Telegram\ExtendedTypes;
5
6
7
use GuzzleHttp\Promise\PromiseInterface;
8
use Sysbot\Telegram\Types\InlineKeyboardMarkup;
9
use Sysbot\Telegram\Types\InputMedia;
10
11
trait Message
12
{
13
14
    use BaseType;
15
16
    public function delete(): PromiseInterface
17
    {
18
        return $this->api->deleteMessage(chatId: $this->chat->id, messageId: $this->messageId);
19
    }
20
21
    public function reply(
22
        string $text,
23
        string $parseMode = null,
24
        bool $allowSendingWithoutReply = false
25
    ): PromiseInterface {
26
        return $this->api->sendMessage(
27
            chatId: $this->chat->id,
28
            text: $text,
29
            parseMode: $parseMode,
30
            replyToMessageId: $this->messageId,
31
            allowSendingWithoutReply: $allowSendingWithoutReply
32
        );
33
    }
34
35
    public function pin(bool $disableNotification = false): PromiseInterface
36
    {
37
        return $this->api->pinChatMessage(
38
            chatId: $this->chat->id,
39
            messageId: $this->messageId,
40
            disableNotification: $disableNotification
41
        );
42
    }
43
44
    public function unpin(): PromiseInterface
45
    {
46
        return $this->api->unpinChatMessage(
47
            chatId: $this->chat->id,
48
            messageId: $this->messageId
49
        );
50
    }
51
52
    public function editText(string $text, string $parseMode = null): PromiseInterface
53
    {
54
        return $this->api->editMessageText(
55
            text: $text,
56
            chatId: $this->chat->id,
57
            messageId: $this->messageId,
58
            parseMode: $parseMode,
59
        );
60
    }
61
62
    public function editCaption(string $caption): PromiseInterface
63
    {
64
        return $this->api->editMessageCaption(chatId: $this->chat->id, messageId: $this->messageId, caption: $caption);
65
    }
66
67
    public function editMedia(InputMedia $media, ?InlineKeyboardMarkup $replyMarkup = null): PromiseInterface
68
    {
69
        return $this->api->editMessageMedia(
70
            media: $media,
71
            chatId: $this->chat->id,
72
            messageId: $this->messageId,
73
            replyMarkup: $replyMarkup
74
        );
75
    }
76
77
    public function editReplyMarkup(?InlineKeyboardMarkup $replyMarkup = null): PromiseInterface
78
    {
79
        return $this->api->editMessageReplyMarkup(
80
            chatId: $this->chat->id,
81
            messageId: $this->messageId,
82
            replyMarkup: $replyMarkup
83
        );
84
    }
85
86
    public function stopPoll(?InlineKeyboardMarkup $replyMarkup = null): PromiseInterface
87
    {
88
        return $this->api->stopPoll(chatId: $this->chat->id, messageId: $this->messageId, replyMarkup: $replyMarkup);
89
    }
90
91
}