Add possibility to delete room aliases

tags/patrix-0.1.4-1
Daniel Berteaud 7 years ago
parent f0a49c9dc4
commit 1adadbeb6c
  1. 1
      README.md
  2. 1
      TODO
  3. 18
      scripts/patrix

@ -43,6 +43,7 @@ Here're the vailable options:
* send-file: send a binary file. --file must be set
* create-room: create a new room
* modify-room: change an existing room (add an alias, set name, topic, join_rules, invite)
* del-room-alias: remove an existing room alias
* get-access-token: just login and print the access token
* get-room-list: prints the list of public rooms of this server
* get-room-id: resolve a room alias to its ID

@ -5,5 +5,4 @@
* Set room avatar
* Configure user profile (name, avatar)
* Follow discussion of a room (like a tail -f of the room discussion)
* Delete a room alias
* Ban / Kick users

@ -101,6 +101,9 @@ if ($opt->{action} eq 'send-file' && $opt->{file} && !-e $opt->{file}){
if ($opt->{action} eq 'modify-room' && !$opt->{room}){
die "You need to specify the room to modify\n\n";
}
if ($opt->{action} =~ m/^(remove|delete|del)\-room\-alias$/ and !$opt->{alias}){
die "You must specify the alias to remove\n\n";
}
# Print debug info if debug is enabled
sub debug {
@ -452,6 +455,16 @@ sub modify_room {
}
}
sub del_room_alias {
debug("Removing room alias $opt->{alias}");
my $uri = $opt->{server} . "/_matrix/client/r0/directory/room/" . uri_escape($opt->{alias}) . '?access_token=' . $opt->{access_token};
my $resp = send_request({
method => 'DELETE',
uri => $uri
});
die "Error removing the alias\n" unless ($resp->is_success);
}
# Should we logout at the end ? Only if we used login and pass
# If we used an access_token, we don't want it to be invalidated
my $must_logout = ($opt->{access_token}) ? 0 : 1;
@ -469,7 +482,7 @@ elsif ($opt->{action} eq 'get-room-list'){
elsif ($opt->{action} eq 'get-room-id'){
print room_alias_to_id($opt->{room}) . "\n";
}
elsif ($opt->{action} =~ m/send\-(msg|message|notice)/){
elsif ($opt->{action} =~ m/^send\-(msg|message|notice)$/){
join_room();
send_msg();
}
@ -483,6 +496,9 @@ elsif ($opt->{action} eq 'create-room'){
elsif ($opt->{action} eq 'modify-room'){
modify_room();
}
elsif ($opt->{action} =~ m/^(remove|delete|del)\-room\-alias$/){
del_room_alias();
}
logout() if $must_logout;

Loading…
Cancel
Save