Call login just once, if needed

tags/patrix-0.1.4-1
Daniel Berteaud 7 years ago
parent 650ce57ac6
commit 517771707b
  1. 17
      scripts/patrix

@ -233,27 +233,20 @@ sub list_room(){
} }
} }
if ($opt->{action} eq 'get-access-token'){ if (!$opt->{access_token}){
login(); login();
}
if ($opt->{action} eq 'get-access-token'){
print $opt->{access_token} . "\n"; print $opt->{access_token} . "\n";
} }
elsif ($opt->{action} eq 'get-room-list'){ elsif ($opt->{action} eq 'get-room-list'){
login();
list_room(); list_room();
} }
elsif ($opt->{action} eq 'send-msg'){ elsif ($opt->{action} eq 'send-msg'){
if (defined $opt->{access_token}){ join_room();
join_room(); send_msg();
send_msg();
}
else{
login();
join_room();
send_msg();
}
} }
elsif ($opt->{action} eq 'send-file'){ elsif ($opt->{action} eq 'send-file'){
login();
join_room(); join_room();
send_file(); send_file();
} }

Loading…
Cancel
Save