diff --git a/src/Telegram/Client.php b/src/Telegram/Client.php new file mode 100644 index 00000000..cf2d19a9 --- /dev/null +++ b/src/Telegram/Client.php @@ -0,0 +1,17 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram; + +class Client extends \Guanguans\Notify\Foundation\Client +{ +} diff --git a/src/Telegram/Credential.php b/src/Telegram/Credential.php new file mode 100644 index 00000000..8c9d6f88 --- /dev/null +++ b/src/Telegram/Credential.php @@ -0,0 +1,19 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram; + +use Guanguans\Notify\Foundation\UriTemplateTokenCredential; + +class Credential extends UriTemplateTokenCredential +{ +} diff --git a/src/Telegram/Messages/AnimationMessage.php b/src/Telegram/Messages/AnimationMessage.php new file mode 100644 index 00000000..465f0c44 --- /dev/null +++ b/src/Telegram/Messages/AnimationMessage.php @@ -0,0 +1,36 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class AnimationMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'animation', + 'duration', + 'width', + 'height', + 'thumb', + 'caption', + 'parse_mode', + 'caption_entities', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/AudioMessage.php b/src/Telegram/Messages/AudioMessage.php new file mode 100644 index 00000000..9af122b3 --- /dev/null +++ b/src/Telegram/Messages/AudioMessage.php @@ -0,0 +1,36 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class AudioMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'audio', + 'caption', + 'parse_mode', + 'caption_entities', + 'duration', + 'performer', + 'title', + 'thumb', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/ChatActionMessage.php b/src/Telegram/Messages/ChatActionMessage.php new file mode 100644 index 00000000..73beb7e5 --- /dev/null +++ b/src/Telegram/Messages/ChatActionMessage.php @@ -0,0 +1,24 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class ChatActionMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'action', + ]; +} diff --git a/src/Telegram/Messages/ContactMessage.php b/src/Telegram/Messages/ContactMessage.php new file mode 100644 index 00000000..1bbac3a3 --- /dev/null +++ b/src/Telegram/Messages/ContactMessage.php @@ -0,0 +1,32 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class ContactMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'phone_number', + 'first_name', + 'last_name', + 'vcard', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/DiceMessage.php b/src/Telegram/Messages/DiceMessage.php new file mode 100644 index 00000000..0a42027e --- /dev/null +++ b/src/Telegram/Messages/DiceMessage.php @@ -0,0 +1,29 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class DiceMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'emoji', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/DocumentMessage.php b/src/Telegram/Messages/DocumentMessage.php new file mode 100644 index 00000000..b5c49591 --- /dev/null +++ b/src/Telegram/Messages/DocumentMessage.php @@ -0,0 +1,34 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class DocumentMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'document', + 'thumb', + 'caption', + 'parse_mode', + 'caption_entities', + 'disable_content_type_detection', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/LocationMessage.php b/src/Telegram/Messages/LocationMessage.php new file mode 100644 index 00000000..4c885cb4 --- /dev/null +++ b/src/Telegram/Messages/LocationMessage.php @@ -0,0 +1,34 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class LocationMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'latitude', + 'longitude', + 'horizontal_accuracy', + 'live_period', + 'heading', + 'proximity_alert_radius', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/MediaGroupMessage.php b/src/Telegram/Messages/MediaGroupMessage.php new file mode 100644 index 00000000..43550148 --- /dev/null +++ b/src/Telegram/Messages/MediaGroupMessage.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class MediaGroupMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'media', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + ]; +} diff --git a/src/Telegram/Messages/Message.php b/src/Telegram/Messages/Message.php new file mode 100644 index 00000000..7c85dc58 --- /dev/null +++ b/src/Telegram/Messages/Message.php @@ -0,0 +1,28 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +use Guanguans\Notify\Foundation\Concerns\AsJson; +use Guanguans\Notify\Foundation\Concerns\AsPost; +use Guanguans\Notify\Telegram\Credential; + +class Message extends \Guanguans\Notify\Foundation\Message +{ + use AsPost; + use AsJson; + + public function httpUri() + { + return sprintf('https://api.telegram.org/bot%s/sendMessage', Credential::TEMPLATE_TOKEN); + } +} diff --git a/src/Telegram/Messages/PhotoMessage.php b/src/Telegram/Messages/PhotoMessage.php new file mode 100644 index 00000000..791cf8a0 --- /dev/null +++ b/src/Telegram/Messages/PhotoMessage.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class PhotoMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'photo', + 'caption', + 'parse_mode', + 'caption_entities', + 'disable_web_page_preview', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/PollMessage.php b/src/Telegram/Messages/PollMessage.php new file mode 100644 index 00000000..c547e0f8 --- /dev/null +++ b/src/Telegram/Messages/PollMessage.php @@ -0,0 +1,40 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class PollMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'question', + 'options', + 'is_anonymous', + 'type', + 'allows_multiple_answers', + 'correct_option_id', + 'explanation', + 'explanation_parse_mode', + 'explanation_entities', + 'open_period', + 'close_date', + 'is_closed', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/TextMessage.php b/src/Telegram/Messages/TextMessage.php new file mode 100644 index 00000000..3041f561 --- /dev/null +++ b/src/Telegram/Messages/TextMessage.php @@ -0,0 +1,51 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class TextMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'text', + 'parse_mode', + 'entities', + 'disable_web_page_preview', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; + + /** + * @var \string[][] + */ + protected $allowedValues = [ + 'parse_mode' => ['HTML', 'Markdown', 'MarkdownV2'], + ]; + + /** + * @var array + */ + protected $allowedTypes = [ + 'entities' => 'array', + 'disable_web_page_preview' => 'bool', + 'disable_notification' => 'bool', + 'protect_content' => 'bool', + 'allow_sending_without_reply' => 'bool', + 'reply_markup' => 'array', + ]; +} diff --git a/src/Telegram/Messages/VenueMessage.php b/src/Telegram/Messages/VenueMessage.php new file mode 100644 index 00000000..a816d0ce --- /dev/null +++ b/src/Telegram/Messages/VenueMessage.php @@ -0,0 +1,36 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class VenueMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'latitude', + 'longitude', + 'title', + 'address', + 'foursquare_id', + 'foursquare_type', + 'google_place_id', + 'google_place_type', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/VideoMessage.php b/src/Telegram/Messages/VideoMessage.php new file mode 100644 index 00000000..f90190a6 --- /dev/null +++ b/src/Telegram/Messages/VideoMessage.php @@ -0,0 +1,37 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class VideoMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'video', + 'duration', + 'width', + 'height', + 'thumb', + 'caption', + 'parse_mode', + 'caption_entities', + 'supports_streaming', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/VideoNoteMessage.php b/src/Telegram/Messages/VideoNoteMessage.php new file mode 100644 index 00000000..a19c3659 --- /dev/null +++ b/src/Telegram/Messages/VideoNoteMessage.php @@ -0,0 +1,32 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class VideoNoteMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'video_note', + 'duration', + 'length', + 'thumb', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +} diff --git a/src/Telegram/Messages/VoiceMessage.php b/src/Telegram/Messages/VoiceMessage.php new file mode 100644 index 00000000..6b4d4380 --- /dev/null +++ b/src/Telegram/Messages/VoiceMessage.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled. + */ + +namespace Guanguans\Notify\Telegram\Messages; + +class VoiceMessage extends Message +{ + /** + * @var string[] + */ + protected $defined = [ + 'chat_id', + 'voice', + 'caption', + 'parse_mode', + 'caption_entities', + 'duration', + 'disable_notification', + 'protect_content', + 'reply_to_message_id', + 'allow_sending_without_reply', + 'reply_markup', + ]; +}