mirror of https://github.com/dani/patrix.git
Add support for --send-code
This commit is contained in:
parent
0e867c76c9
commit
5207d794b5
|
@ -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 (<pre><code>text</code></pre>)
|
||||
* 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)
|
||||
|
|
|
@ -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} = '<pre><code>' . $opt->{message} . '</code></pre>';
|
||||
$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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue