Remove duplicate code
This commit is contained in:
@@ -314,60 +314,31 @@ sub __on_msg {
|
|||||||
my $qname = quotemeta ('@' . $myusername);
|
my $qname = quotemeta ('@' . $myusername);
|
||||||
my $qtname = quotemeta $myfullname;
|
my $qtname = quotemeta $myfullname;
|
||||||
|
|
||||||
|
my $rmsg = clone ($redismsg);
|
||||||
|
$rmsg->{mode} = 'public';
|
||||||
|
$rmsg->{userid} = $userid;
|
||||||
|
$rmsg->{chatid} = $chatid;
|
||||||
|
|
||||||
# phrase directed to bot
|
# phrase directed to bot
|
||||||
if ((lc ($text) =~ /^${qname}[\,|\:]? (.+)/) or (lc ($text) =~ /^${qtname}[\,|\:]? (.+)/)){
|
if ((lc ($text) =~ /^${qname}[\,|\:]? (.+)/) or (lc ($text) =~ /^${qtname}[\,|\:]? (.+)/)){
|
||||||
$phrase = $1;
|
$phrase = $1;
|
||||||
|
|
||||||
my $rmsg = clone ($redismsg);
|
|
||||||
$rmsg->{mode} = 'public';
|
|
||||||
$rmsg->{message} = $phrase;
|
$rmsg->{message} = $phrase;
|
||||||
$rmsg->{userid} = $userid;
|
|
||||||
$rmsg->{chatid} = $chatid;
|
|
||||||
my $pubsub = $main::REDIS->pubsub;
|
|
||||||
$pubsub->json ($c->{'redis_router_channel'})->notify (
|
|
||||||
$c->{'redis_router_channel'} => $rmsg
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
# bot mention by name
|
# bot mention by name
|
||||||
} elsif ((lc ($text) =~ /.+ ${qname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qname$/)) {
|
} elsif ((lc ($text) =~ /.+ ${qname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qname$/)) {
|
||||||
$phrase = $text;
|
$phrase = $text;
|
||||||
|
|
||||||
my $rmsg = clone ($redismsg);
|
|
||||||
$rmsg->{mode} = 'public';
|
|
||||||
$rmsg->{message} = $phrase;
|
$rmsg->{message} = $phrase;
|
||||||
$rmsg->{userid} = $userid;
|
|
||||||
$rmsg->{chatid} = $chatid;
|
|
||||||
my $pubsub = $main::REDIS->pubsub;
|
|
||||||
$pubsub->json ($c->{'redis_router_channel'})->notify (
|
|
||||||
$c->{'redis_router_channel'} => $rmsg
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
# bot mention by telegram name
|
# bot mention by telegram name
|
||||||
} elsif ((lc ($text) =~ /.+ ${qtname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qtname$/)) {
|
} elsif ((lc ($text) =~ /.+ ${qtname}[\,|\!|\?|\.| ]/) or (lc ($text) =~ / $qtname$/)) {
|
||||||
$phrase = $text;
|
$phrase = $text;
|
||||||
|
|
||||||
my $rmsg = clone ($redismsg);
|
|
||||||
$rmsg->{mode} = 'public';
|
|
||||||
$rmsg->{message} = $phrase;
|
$rmsg->{message} = $phrase;
|
||||||
$rmsg->{userid} = $userid;
|
} else {
|
||||||
$rmsg->{chatid} = $chatid;
|
$rmsg->{message} = $text;
|
||||||
my $pubsub = $main::REDIS->pubsub;
|
$rmsg->{misc}->{answer} = 0;
|
||||||
$pubsub->json ($c->{'redis_router_channel'})->notify (
|
|
||||||
$c->{'redis_router_channel'} => $rmsg
|
|
||||||
);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my $rmsg = clone ($redismsg);
|
|
||||||
$rmsg->{mode} = 'public';
|
|
||||||
$rmsg->{message} = $text;
|
|
||||||
$rmsg->{userid} = $userid;
|
|
||||||
$rmsg->{chatid} = $chatid;
|
|
||||||
$rmsg->{misc}->{answer} = 0;
|
|
||||||
my $pubsub = $main::REDIS->pubsub;
|
my $pubsub = $main::REDIS->pubsub;
|
||||||
|
|
||||||
$pubsub->json ($c->{'redis_router_channel'})->notify (
|
$pubsub->json ($c->{'redis_router_channel'})->notify (
|
||||||
$c->{'redis_router_channel'} => $rmsg
|
$c->{'redis_router_channel'} => $rmsg
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user