Some tidying.
This commit is contained in:
parent
406679ae2e
commit
a42d6e91dd
@ -36,12 +36,10 @@ sub new {
|
||||
my $Self = {};
|
||||
bless( $Self, $Type );
|
||||
|
||||
$Self->{LogLevel} = $Param{LogLevel} || 'info';
|
||||
$Self->{LogObject} = Log::Log4perl->get_logger('TelegramBot');
|
||||
$Self->{Token} = 'bot5868933096:AAE8Oe-AxU6m_yCWfpqTqwwjERqnRpBGJtE';
|
||||
$Self->{URL} = {
|
||||
Telegram => 'https://api.telegram.org',
|
||||
};
|
||||
$Self->{LogLevel} = $Param{LogLevel} || 'info';
|
||||
$Self->{LogObject} = Log::Log4perl->get_logger('TelegramBot');
|
||||
$Self->{Token} = 'bot5868933096:AAE8Oe-AxU6m_yCWfpqTqwwjERqnRpBGJtE';
|
||||
$Self->{TelegramURL} = 'https://api.telegram.org';
|
||||
|
||||
# load remembered update ids
|
||||
$Self->{MessageIDs} = YAML::LoadFile("$FindBin::Bin/message_ids.yml");
|
||||
@ -105,7 +103,7 @@ sub build {
|
||||
else {
|
||||
# for now, testing fallback
|
||||
my $ResponseResult = plain POST(
|
||||
join( '/', ( $Self->{URL}{Telegram}, $Self->{Token}, 'sendMessage' ) ),
|
||||
join( '/', ( $Self->{TelegramURL}, $Self->{Token}, 'sendMessage' ) ),
|
||||
{
|
||||
'chat_id' => $Param{Message}->{callback_query}->{from}->{id},
|
||||
'reply_to_message_id' => $Param{Message}->{callback_query}->{message}->{message_id},
|
||||
@ -141,7 +139,7 @@ sub build {
|
||||
$KeyboardData,
|
||||
);
|
||||
my $ResponseResult = plain POST(
|
||||
join( '/', ( $Self->{URL}{Telegram}, $Self->{Token}, 'sendMessage' ) ),
|
||||
join( '/', ( $Self->{TelegramURL}, $Self->{Token}, 'sendMessage' ) ),
|
||||
{
|
||||
'chat_id' => $Param{Message}->{chat}->{id},
|
||||
'reply_to_message_id' => $Param{Message}->{id},
|
||||
@ -217,7 +215,7 @@ sub processMessage {
|
||||
}
|
||||
|
||||
my $ResponseResult = plain POST(
|
||||
join( '/', ( $Self->{URL}{Telegram}, $Self->{Token}, 'sendMessage' ) ),
|
||||
join( '/', ( $Self->{TelegramURL}, $Self->{Token}, 'sendMessage' ) ),
|
||||
{
|
||||
chat_id => $Param{Message}->{message}->{chat}->{id},
|
||||
$ResponseData->%*,
|
||||
@ -229,7 +227,7 @@ sub processMessage {
|
||||
|
||||
# mark message as read
|
||||
my $SeenResult = plain POST(
|
||||
join( '/', ( $Self->{URL}{Telegram}, $Self->{Token}, 'readMessageContents' ) ),
|
||||
join( '/', ( $Self->{TelegramURL}, $Self->{Token}, 'readMessageContents' ) ),
|
||||
{
|
||||
id => $Param{Message}->{message}->{id},
|
||||
}
|
||||
@ -253,7 +251,7 @@ sub fetchMessages {
|
||||
$Self->{LogObject}->info('fetchMessages: Initiating getUpdates');
|
||||
|
||||
my $MessageDataRaw =
|
||||
json GET( join( '/', ( $Self->{URL}{Telegram}, $Self->{Token}, $Method ) ), {} );
|
||||
json GET( join( '/', ( $Self->{TelegramURL}, $Self->{Token}, $Method ) ), {} );
|
||||
$Self->{LogObject}
|
||||
->info( 'fetchMessages: Messages raw are ' . Dumper($MessageDataRaw) );
|
||||
my @Messages = $MessageDataRaw->{result}->@*;
|
||||
|
Loading…
Reference in New Issue
Block a user