diff --git a/README.md b/README.md index 711da3f..a9ebcbe 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Here're the vailable options: * send-msg (default): send the text message * send-message: an alias for send-msg * send-notice: send a notice. Very similar to send-msg but the client may display it differently. Eg Riot will not notify you for notices + * send-code: same as send-msg, but text will be presented like code (
text
)
* 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)
diff --git a/scripts/patrix b/scripts/patrix
index 73f50c7..5ce6407 100644
--- a/scripts/patrix
+++ b/scripts/patrix
@@ -30,6 +30,7 @@ GetOptions(
"action=s" => \$opt->{action},
"send-msg|send-message" => \$opt->{'send-msg'},
"send-notice" => \$opt->{'send-notice'},
+ "send-code" => \$opt->{'send-code'},
"send-file" => \$opt->{'send-file'},
"create-room" => \$opt->{'create-room'},
"modify-room" => \$opt->{'modify-room'},
@@ -62,6 +63,7 @@ if ($opt->{conf} && -e $opt->{conf}){
my @actions = qw(
send-msg
send-notice
+ send-code
send-file
create-room
modify-room
@@ -228,6 +230,11 @@ sub send_msg {
msgtype => ($opt->{action} eq 'send-notice') ? 'm.notice' : 'm.text',
body => $opt->{message}
};
+ # If we send code, we have to format it correctly
+ if ($opt->{action} eq 'send-code'){
+ $json->{formatted_body} = '' . $opt->{message} . '
';
+ $json->{format} = 'org.matrix.custom.html';
+ }
my $resp = send_request({
uri => $uri,
content => to_json($json)
@@ -549,7 +556,7 @@ elsif ($opt->{action} eq 'get-room-list'){
elsif ($opt->{action} eq 'get-room-id'){
print $opt->{room} . "\n";
}
-elsif ($opt->{action} =~ m/^send\-(msg|message|notice)$/){
+elsif ($opt->{action} =~ m/^send\-(msg|message|notice|code)$/){
join_room();
send_msg();
}