some tweaks in help

master
Ondřej Hruška 3 years ago
parent 482a93c172
commit df197f91b7
Signed by untrusted user: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 3
      src/command.rs
  2. 62
      src/group_handle.rs

@ -91,7 +91,7 @@ static RE_HELP: once_cell::sync::Lazy<Regex> = Lazy::new(|| {
}); });
static RE_MEMBERS: once_cell::sync::Lazy<Regex> = Lazy::new(|| { static RE_MEMBERS: once_cell::sync::Lazy<Regex> = Lazy::new(|| {
command!(r"(?:members)") command!(r"(?:members|who)")
}); });
static RE_LEAVE: once_cell::sync::Lazy<Regex> = Lazy::new(|| { static RE_LEAVE: once_cell::sync::Lazy<Regex> = Lazy::new(|| {
@ -423,6 +423,7 @@ mod test {
fn test_members() { fn test_members() {
assert!(!RE_MEMBERS.is_match("/admin lain@pleroma.soykaf.com")); assert!(!RE_MEMBERS.is_match("/admin lain@pleroma.soykaf.com"));
assert!(RE_MEMBERS.is_match("/members")); assert!(RE_MEMBERS.is_match("/members"));
assert!(RE_MEMBERS.is_match("/who"));
} }
#[test] #[test]

@ -382,28 +382,54 @@ impl GroupHandle {
} }
} }
StatusCommand::Help => { StatusCommand::Help => {
if self.config.is_member_only() {
let mut s = "This is a member-only group. ".to_string();
if self.config.can_write(&notif_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( replies.push(
"To share an original post with the group, mention the group user.\n\ "\nTo share an original post, mention the group user.\n\
Posts with commands won't be shared. Supported commands:\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\ `/ignore, /i` - make the group completely ignore the post\n\
`/boost, /b` - boost the replied-to post into the group\n\ `/members, /who` - show group members / admins\n\
`/leave` - leave the group as a member".to_string()); `/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 { if is_admin {
replies.push( 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\ `/kick, /remove user` - kick a member\n\
`/add user` - add a member\n\
`/ban x` - ban a user or a server\n\ `/ban x` - ban a user or a server\n\
`/unban x` - lift a ban\n\ `/unban x` - lift a ban\n\
`/op, /admin user` - give admin rights\n\ `/op, /admin user` - grant admin rights\n\
`/deop, /deadmin user` - remove admin rights\n\ `/deop, /deadmin user` - revoke admin rights\n\
`/opengroup` - make member-only\n\ `/opengroup` - make member-only\n\
`/closegroup` - make public-access\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 => { StatusCommand::ListMembers => {
let mut show_admins = false;
if is_admin { if is_admin {
if self.config.is_member_only() { if self.config.is_member_only() {
replies.push("Group members:".to_string()); replies.push("Group members:".to_string());
@ -420,12 +446,18 @@ impl GroupHandle {
} }
} }
} else { } else {
replies.push("Group admins:".to_string()); show_admins = true;
let mut admins = self.config.get_admins().collect::<Vec<_>>(); }
admins.sort(); } else {
for a in admins { show_admins = true;
replies.push(format!("{}", a)); }
}
if show_admins {
replies.push("Group admins:".to_string());
let mut admins = self.config.get_admins().collect::<Vec<_>>();
admins.sort();
for a in admins {
replies.push(format!("{}", a));
} }
} }
} }

Loading…
Cancel
Save