From 0576a1ea573f28dda4344a5aebc7dcc9da1aa7d0 Mon Sep 17 00:00:00 2001 From: eleksir Date: Fri, 30 Oct 2020 13:10:33 +0300 Subject: [PATCH] Implement getChat() with inline POD --- lib/Teapot/Bot/Brain.pm | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/Teapot/Bot/Brain.pm b/lib/Teapot/Bot/Brain.pm index 9c0f663..a43ca4b 100644 --- a/lib/Teapot/Bot/Brain.pm +++ b/lib/Teapot/Bot/Brain.pm @@ -109,6 +109,23 @@ sub getChatMember { } +sub getChat { + my $self = shift; + my $args = shift || {}; + + my $send_args = {}; + croak "no chat_id supplied" unless $args->{chat_id}; + $send_args->{chat_id} = $args->{chat_id}; + + my $token = $self->token || croak "no token?"; + + my $url = "https://api.telegram.org/bot${token}/getChat"; + my $api_response = $self->_post_request($url); + + return Teapot::Bot::Object::Chat->create_from_hash($api_response, $self); +} + + sub sendMessage { my $self = shift; my $args = shift || {}; @@ -415,8 +432,17 @@ L. Takes chat_id, and user_id as arguments. -Returns the L that -represents properties of Chat User. +Returns the L that represents properties +of Chat User. + +=head2 getChat + +This is the wrapper around the C API method. See +L. + +Takes chat_id as argument. + +Returns the L that represents properties of Chat. =head2 sendMessage