auto-invite-matrix-bot

A small bot to redirect people.
git clone git://archive.git.mtrnord.blog/MTRNord/auto-invite-matrix-bot.git
Log | Files | Refs | README | LICENSE

commit 97488cf8a06be5474a68a2d3a1391d14df21ce91
parent 3f14e5a32986957d110c4bb667711c83ea438da0
Author: Marcel <mtrnord1@gmail.com>
Date:   Mon, 17 Feb 2020 19:30:27 +0100

Add config option for the target user

Took 5 minutes

Diffstat:
Mconfig_example.yml | 1+
Msrc/config.rs | 1+
Msrc/main.rs | 3++-
3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/config_example.yml b/config_example.yml @@ -1,5 +1,6 @@ --- message: "This is an automated message. You seem to have invited one of my other Matrix Accounts. A Bot has now invited the correct user. Please be patient until I respond!" +target_user: "@MTRNord:matrix.ffslfl.net" servers: - address: "https://mozilla.modular.im" mxid: "@mtrnord:mozilla.org" diff --git a/src/config.rs b/src/config.rs @@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Config { pub message: String, + pub target_user: String, pub servers: Vec<Homeserver>, } diff --git a/src/main.rs b/src/main.rs @@ -62,6 +62,7 @@ async fn do_stuff(config: &Config, server: &Homeserver) -> Result<(), ruma_clien let mut sync_stream = Box::pin(client.sync(None, None, false)); let message = config.message.clone(); + let target_user = config.target_user.clone(); while let Some(response) = sync_stream.try_next().await? { let res: IncomingResponse = response; for (room_id, _room) in res.rooms.invite { @@ -77,7 +78,7 @@ async fn do_stuff(config: &Config, server: &Homeserver) -> Result<(), ruma_clien let response = client .request(invite_user::Request { room_id: room_id.clone(), - user_id: UserId::try_from("@MTRNord:matrix.ffslfl.net").unwrap(), + user_id: UserId::try_from(target_user.clone().as_str()).unwrap(), }) .await?; println!("Invited correct user {:?}", response);