From df197f91b74397bf2c7936d2e5f3db53882db4dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 22 Aug 2021 12:24:03 +0200 Subject: [PATCH] some tweaks in help --- src/command.rs | 3 ++- src/group_handle.rs | 62 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 49 insertions(+), 16 deletions(-) diff --git a/src/command.rs b/src/command.rs index e699686..5df16a2 100644 --- a/src/command.rs +++ b/src/command.rs @@ -91,7 +91,7 @@ static RE_HELP: once_cell::sync::Lazy = Lazy::new(|| { }); static RE_MEMBERS: once_cell::sync::Lazy = Lazy::new(|| { - command!(r"(?:members)") + command!(r"(?:members|who)") }); static RE_LEAVE: once_cell::sync::Lazy = Lazy::new(|| { @@ -423,6 +423,7 @@ mod test { fn test_members() { assert!(!RE_MEMBERS.is_match("/admin lain@pleroma.soykaf.com")); assert!(RE_MEMBERS.is_match("/members")); + assert!(RE_MEMBERS.is_match("/who")); } #[test] diff --git a/src/group_handle.rs b/src/group_handle.rs index beb4e40..c1f9076 100644 --- a/src/group_handle.rs +++ b/src/group_handle.rs @@ -382,28 +382,54 @@ impl GroupHandle { } } StatusCommand::Help => { + if self.config.is_member_only() { + let mut s = "This is a member-only group. ".to_string(); + if self.config.can_write(¬if_acct) { + s.push_str("*You are not a member, ask one of the admins to add you.*"); + } else { + if is_admin { + s.push_str("*You are an admin.*"); + } else { + s.push_str("*You are a member.*"); + } + } + replies.push(s); + } else { + let mut s = "This is a public-access group. ".to_string(); + if is_admin { + s.push_str("*You are an admin.*"); + } + replies.push(s); + } + replies.push( - "To share an original post with the group, mention the group user.\n\ - Posts with commands won't be shared. Supported commands:\n\ + "\nTo share an original post, mention the group user.\n\ + Posts with commands, and replies, won't be shared.\n\ + \n\ + **Supported commands:**\n\ `/ignore, /i` - make the group completely ignore the post\n\ - `/boost, /b` - boost the replied-to post into the group\n\ - `/leave` - leave the group as a member".to_string()); + `/members, /who` - show group members / admins\n\ + `/boost, /b` - boost the replied-to post into the group".to_string()); + + if self.config.is_member_only() { + replies.push("`/leave` - leave the group".to_string()); + } if is_admin { replies.push( - "`/members` - list members and admins\n\ + "`/add user` - add a member (use e-mail style address)\n\ `/kick, /remove user` - kick a member\n\ - `/add user` - add a member\n\ `/ban x` - ban a user or a server\n\ `/unban x` - lift a ban\n\ - `/op, /admin user` - give admin rights\n\ - `/deop, /deadmin user` - remove admin rights\n\ + `/op, /admin user` - grant admin rights\n\ + `/deop, /deadmin user` - revoke admin rights\n\ `/opengroup` - make member-only\n\ `/closegroup` - make public-access\n\ - `/announce x` - make a public announcement from all that follows".to_string()); + `/announce x` - make a public announcement from the rest of the status".to_string()); } } StatusCommand::ListMembers => { + let mut show_admins = false; if is_admin { if self.config.is_member_only() { replies.push("Group members:".to_string()); @@ -420,12 +446,18 @@ impl GroupHandle { } } } else { - replies.push("Group admins:".to_string()); - let mut admins = self.config.get_admins().collect::>(); - admins.sort(); - for a in admins { - replies.push(format!("{}", a)); - } + show_admins = true; + } + } else { + show_admins = true; + } + + if show_admins { + replies.push("Group admins:".to_string()); + let mut admins = self.config.get_admins().collect::>(); + admins.sort(); + for a in admins { + replies.push(format!("{}", a)); } } }