line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Telebot::Task::Update; |
2
|
1
|
|
|
1
|
|
1365
|
use Mojo::Base 'Minion::Job', -signatures; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
3
|
|
|
|
|
|
|
|
4
|
0
|
|
|
0
|
1
|
|
sub run ($job, $payload) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
0
|
|
|
|
|
|
my $app = $job->app; |
6
|
0
|
0
|
|
|
|
|
if ($payload->{update_id}) { |
7
|
0
|
0
|
|
|
|
|
if (my $handler = $app->tg->handler('update')) { |
8
|
|
|
|
|
|
|
$handler->new( |
9
|
|
|
|
|
|
|
app => $app, |
10
|
|
|
|
|
|
|
update_id => $payload->{update_id}, |
11
|
0
|
|
|
|
|
|
payload => $payload, |
12
|
|
|
|
|
|
|
)->run; |
13
|
|
|
|
|
|
|
} |
14
|
0
|
|
|
|
|
|
for ($app->tg->allowed_updates->each) { |
15
|
|
|
|
|
|
|
$app->minion->enqueue($_ => [ |
16
|
|
|
|
|
|
|
$payload->{$_}, |
17
|
|
|
|
|
|
|
$payload->{update_id} |
18
|
0
|
0
|
|
|
|
|
]) if exists $payload->{$_}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
else { |
22
|
0
|
|
|
|
|
|
$job->note(warning => 'No update_id'); |
23
|
|
|
|
|
|
|
} |
24
|
0
|
|
|
|
|
|
return $job->finish; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=pod |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=encoding utf8 |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 NAME |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Telebot::Task::Update - Minion job for processing update. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 SYNOPSIS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
use Telebot::Task::Update; |
40
|
|
|
|
|
|
|
$app->minion->add_task(update => 'Telebot::Task::Update'); |
41
|
|
|
|
|
|
|
$app->minion->enqueue(update => [$payload]); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 DESCRIPTION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
L is the task for processing incoming telegram update. |
46
|
|
|
|
|
|
|
This task is executed if app have handler for update. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
L inherits all attributes from L. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 METHODS |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
L inherits all methods from L. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 run |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$job->run($payload); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
This is overloaded method which creates instance of update handler |
61
|
|
|
|
|
|
|
and call handler's B with payload. After executing handler, task |
62
|
|
|
|
|
|
|
enqueues tasks for parts of update with this part payload and update_id. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Copyright (C) 2022, Igor Lobanov. |
67
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version |
68
|
|
|
|
|
|
|
2.0. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 SEE ALSO |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L, L, L, |
73
|
|
|
|
|
|
|
L. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |