File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change 1+ use crate :: {
2+ rpc:: { self } ,
3+ Result ,
4+ } ;
5+ use clap:: Args ;
6+ use serde_json:: json;
7+
8+ #[ derive( Args ) ]
9+ pub struct SendMatrixMessageArgs {
10+ pub room_id : String ,
11+ pub message : String ,
12+ }
13+
14+ pub fn send_matrix_message ( args : & SendMatrixMessageArgs ) -> Result < ( ) > {
15+ let params = json ! ( {
16+ "room_id" : args. room_id,
17+ "message" : args. message,
18+ } ) ;
19+ rpc:: call ( "send_matrix_message" , params) ?. print ( )
20+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ pub mod common;
55pub mod element;
66pub mod event;
77pub mod import;
8+ pub mod matrix;
89pub mod report;
910pub mod setup;
1011pub mod user;
Original file line number Diff line number Diff line change @@ -118,14 +118,16 @@ enum Commands {
118118 RevokeSubmittedPlace ( command:: import:: RevokeSubmittedPlaceArgs ) ,
119119
120120 SetApiKey ( command:: admin:: SetApiKeyArgs ) ,
121+
122+ SendMatrixMessage ( command:: matrix:: SendMatrixMessageArgs ) ,
121123}
122124
123125type Result < T > = std:: result:: Result < T , Box < dyn Error > > ;
124126
125127fn main ( ) -> Result < ( ) > {
126128 let cli = Cli :: parse ( ) ;
127129
128- std:: env:: set_var ( "VERBOSITY" , cli. verbose . to_string ( ) ) ;
130+ unsafe { std:: env:: set_var ( "VERBOSITY" , cli. verbose . to_string ( ) ) } ;
129131
130132 if let Some ( Commands :: SetServer ( args) ) = & cli. command {
131133 return command:: setup:: set_server ( args) ;
@@ -222,6 +224,8 @@ fn main() -> Result<()> {
222224 Commands :: RevokeSubmittedPlace ( args) => command:: import:: revoke_submitted_place ( args) ,
223225
224226 Commands :: SetApiKey ( args) => command:: admin:: set_api_key ( args) ,
227+
228+ Commands :: SendMatrixMessage ( args) => command:: matrix:: send_matrix_message ( args) ,
225229 }
226230}
227231
You can’t perform that action at this time.
0 commit comments