blob: c87af306c9bc12cf0341e935df8c340c72c66df4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package TgLib;
use TgLib::Env qw<$CONFIG_HOME>;
use parent qw<Exporter>;
our @EXPORT = qw<fetch_token>;
sub fetch_token {
my $token = $ENV{'TGUTILS_TOKEN'};
unless ($token) {
open(my $cfg, "<", "$CONFIG_HOME/tgutils_token") or return;
$token = <$cfg>;
chomp $token;
close $cfg;
}
$token =~ /^[0-9]+:[a-zA-Z0-9_]+$/ or die "Invalid bot token ($token)";
return $token;
}
1;
|