| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 | use Modern::Perl;use utf8;use Mojo::Base -strict, -signatures, -async_await;our $redis;our $client;our $config;package abon_client;use darsan_client;my $auth = abon_auth->new;sub new($class){  my $client = darsan_client->new(undef, $config->{darsan}->{servers});  $client->map($config->{darsan_map}) if $config->{darsan_map};  return bless {client => $client}, $class;}our $AUTOLOAD;sub AUTOLOAD($self, $info, @rest){  # Remove qualifier from original method name...  my $called =  $AUTOLOAD =~ s/.*:://r;      return $self->{client}->auth($auth->telegram($info->{id}))->$called(@rest);}package abon_auth;sub new($class){  return bless {telegram=>undef}, $class;}sub telegram($self, $tel_id){  $self->{telegram} = $tel_id;  return $self;}async sub token_p{  my $self = shift;  my $key = "ab-$self->{telegram}-token";    my $tok = $redis->get($key);  return $tok if $tok;    my $res = await $client->post_p("client", "/telegram/$self->{telegram}/token");  $redis->set($key, $res->{token});  $redis->expireat($key, darsan_auth::parse_time($res->{expires})-5);    return $res->{token};}1;
 |