From 517771707b4253752b15b05dc2d20e6c3bd33b25 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Thu, 7 Sep 2017 12:50:43 +0200 Subject: [PATCH] Call login just once, if needed --- scripts/patrix | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/scripts/patrix b/scripts/patrix index c032a33..843ce23 100644 --- a/scripts/patrix +++ b/scripts/patrix @@ -233,27 +233,20 @@ sub list_room(){ } } -if ($opt->{action} eq 'get-access-token'){ +if (!$opt->{access_token}){ login(); +} +if ($opt->{action} eq 'get-access-token'){ print $opt->{access_token} . "\n"; } elsif ($opt->{action} eq 'get-room-list'){ - login(); list_room(); } elsif ($opt->{action} eq 'send-msg'){ - if (defined $opt->{access_token}){ - join_room(); - send_msg(); - } - else{ - login(); - join_room(); - send_msg(); - } + join_room(); + send_msg(); } elsif ($opt->{action} eq 'send-file'){ - login(); join_room(); send_file(); }